-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 NetBSD Security Advisory 2018-001 ================================= Topic: Several vulnerabilities in context handling Version: NetBSD-current: source prior to Sat, Sep 2nd 2017 NetBSD 7.1.1: not affected NetBSD 7.1: affected NetBSD 7.0 - 7.0.2: affected NetBSD 6.1 - 6.1.4: affected NetBSD 6.0 - 6.0.5: affected Severity: Privilege escalation / Local DoS Fixed: NetBSD-current: Sat, Sep 2nd 2017 NetBSD-7-1 branch: Sun, Oct 1st 2017 NetBSD-7-0 branch: Sun, Oct 1st 2017 NetBSD-7 branch: Sun, Oct 1st 2017 NetBSD-6-1 branch: Fri, Oct 13th 2017 NetBSD-6-0 branch: Fri, Oct 13th 2017 NetBSD-6 branch: Fri, Oct 13th 2017 Teeny versions released later than the fix date will contain the fix. Please note that NetBSD releases prior to 6.0 are no longer supported. It is recommended that all users upgrade to a supported release. Abstract ======== Several issues were discovered in several ports of NetBSD: 1) sparc64: A missing mask in a syscall could allow userland to control a few bits from a privileged register, allowing privilege escalations. 2) amd64: A subtle mistake in compat_linux32 could allow userland to generate a particular fault in kernel mode, which caused the kernel to get confused and re-enter itself in kernel mode but with the userland Thread-Local Storage. This allowed privilege escalations. 3) i386: An instruction in the #UD exception handler was implicitly using the userland %ds register without sanitizing it. This allowed at least local DoSes. Technical Details ================= 1) A mistake in a syscall allowed an unprivileged user process to set privileged bits, such as PSTATE_PRIV, in the %pstate register. Upon return to userland the process would then be granted kernel privileges on the hardware. 2) The handling of the GDT on amd64 creates a condition where a page fault can be generated if a segment register is reloaded with a "high" selector, located near the end of the GDT. An incorrect check in a linux32 syscall allowed unprivileged user processes to have the kernel page fault in such a condition. However, the kernel does not correctly handle such exceptions: it re-enters itself but does not switch to the kernel TLS, and instead uses userland's. Userland therefore had a way to control a generic kernel pointer, which allowed for full privilege escalation. 3) The #UD exception handler was implicitly using the %ds register, before it actually initialized it to the kernel value. This allowed userland to crash the system. Solutions and Workarounds ========================= For all NetBSD versions, you need to obtain fixed kernel sources, rebuild and install the new kernel, and reboot the system. The fixed source may be obtained from the NetBSD CVS repository. The following instructions briefly summarize how to upgrade your kernel. In these instructions, replace: ARCH with your architecture (from uname -m), KERNCONF with the name of your kernel configuration file and VERSION with the file version below File versions containing the fixes: FILE HEAD netbsd-7 netbsd-7-0 netbsd-7-1 ---- ---- -------- ---------- ---------- sys/arch/sparc64/sparc64/compat_13_machdep.c 1.24 1.23.38.1 1.23.42.1 1.23.50.1 sys/compat/linux32/arch/amd64/linux32_machdep.c 1.39 1.36.4.1 1.36.8.1 1.36.14.1 sys/arch/i386/i386/i386_trap.S 1.12 1.5.6.1 1.5.12.1 1.5.20.1 FILE netbsd-6 netbsd-6-0 netbsd-6-1 ---- -------- ---------- ---------- sys/arch/sparc64/sparc64/compat_13_machdep.c 1.23.18.1 1.23.24.1 1.23.32.1 sys/compat/linux32/arch/amd64/linux32_machdep.c 1.29.10.1 1.29.14.1 1.29.16.1 sys/arch/i386/i386/vector.S 1.59.8.1 1.59.12.1 1.59.14.1 Note: in NetBSD 6, the fix for 3) is in a different file. To update from CVS, re-build, and re-install the kernel: # cd src # cvs update -d -P -r VERSION sys/arch/sparc64/sparc64/compat_13_machdep.c # cvs update -d -P -r VERSION sys/compat/linux32/arch/amd64/linux32_machdep.c then, either # cvs update -d -P -r VERSION sys/arch/i386/i386/i386_trap.S or # cvs update -d -P -r VERSION sys/arch/i386/i386/vector.S # ./build.sh kernel=KERNCONF # mv /netbsd /netbsd.old # cp sys/arch/ARCH/compile/obj/KERNCONF/netbsd /netbsd # shutdown -r now For more information on how to do this, see: http://www.NetBSD.org/guide/en/chap-kernel.html Thanks To ========= Maxime Villard for finding and fixing the issues. Revision History ================ 2018-01-02 Initial release 2018-03-09 Note that NetBSD 7.1.1 is not affected More Information ================ Advisories may be updated as new information becomes available. The most recent version of this advisory (PGP signed) can be found at http://ftp.NetBSD.org/pub/NetBSD/security/advisories/NetBSD-SA2018-001.txt.asc Information about NetBSD and NetBSD security can be found at http://www.NetBSD.org/ and http://www.NetBSD.org/Security/ . Copyright 2018, The NetBSD Foundation, Inc. All Rights Reserved. Redistribution permitted only in full, unmodified form. -----BEGIN PGP SIGNATURE----- iQIcBAEBAgAGBQJaov4fAAoJEAZJc6xMSnBuv8EQAMJvex7cNGjODVH1X/djX5R8 PJUcFPQITG/kWq6+pSEzqbVDhciy+ljL4XOeBETqqOMNXUnMn8dlMkbWTEiXLFdo NjFNU3q2YsUEctKgvS7LB8LMrMJg/yFd8kcf+jQzhbH0tHLGAfhL36pNbEHrkfGm kaNdiyinK9ttyvi39uIL5m6FFqbAnI6g7DAfplCQRF6bbxoVw1VWaFwfRhJcgbu7 O4PdWUZzWZ3P/MfNfn4ZXvDx85HInVachXnFjuzARqMR5G/3K6SZqdumja7g4oFX PkaC0yuCQRlK7o+JstQtM3Kt7lPMPXY+f5CS2NaCVm/SH/OO90+eKbAFO9l86qZ3 V1eVH5im1melwsQ816fFLSZRmEGR9pn3AyKsJJWo2XGSficMwJQHDlezlbHgS7Y2 KeoAp45BFQ51RHXjF00gzI9ht+p8OUNQH8gCnyWbjjcvQEiZd2jb40Wr8MpKH7hy kU5+ighPddPUCRZKZkv/PcKhs6sD6LACBxdT6XMV+DZcElmBlrGwwIJIcAPIBixm nXiy6ru5XYnXmMRbvQjGz4GZqvN8bJ1hkf/PO0BiLwzeVZa+fJUat3FNR3qQ8vqV h45cyU5w1Mc/y8YQCqNhLK5+WW7ACGp/DRjfeNgZbYffz+tMnffcQsK9y88VQnu+ zjfvVv4lmFVBm4jXY82/ =oWAn -----END PGP SIGNATURE-----