[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
NetBSD Security Advisory 2017-003: Xen-amd64: weak privilege separation
-----BEGIN PGP SIGNED MESSAGE-----
NetBSD Security Advisory 2017-00X
Topic: Xen-amd64: weak privilege separation
Version: NetBSD-current: source prior to Sun, Mar 5th 2017
NetBSD 7.1: not 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
Fixed: NetBSD-current: Sun, Mar 5th 2017
NetBSD-7-0 branch: Mon, Mar 6th 2017
NetBSD-7 branch: Mon, Mar 6th 2017
NetBSD-6-0 branch: Mon, Mar 6th 2017
NetBSD-6-1 branch: Mon, Mar 6th 2017
NetBSD-6 branch: Mon, Mar 6th 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.
A design mistake in the Xen-amd64 port allows userland to read and write to
several kernel pages. An unprivileged user can therefore modify critical kernel
structures in order to escalate privileges.
Under a Xen hypervisor, any 64bit para-virtualized OS runs in ring3, the same
privilege level as userland. In order to provide privilege separation, Xen
intercepts the syscalls and traps, switches the virtual memory (VM) space to
map the system kernel, and manually jumps into it. Later, when returning to
userland, Xen switches back to the userland-only VM space, and flushes the
Translation Look-Aside Buffer (TLB).
TLB flushes are costly from a performance point of view, so in order to optimize
VM space switches Xen marks the userland pages as "global" - which means they
are not flushed under a local TLB flush -, while keeping the kernel pages as
"local". This way, when returning to userland from a syscall or a trap, the
userland pages are not cleared from the TLB.
In order to differentiate userland pages from kernel pages, Xen looks at the
PG_u ("userland") bit in the Page Table Directory (PTD) created by the OS: if a
page has PG_u, Xen believes the page in question is for userland so it marks it
as global, otherwise it is a kernel page and Xen adds PG_u but keeps the page as
local. In either case the page ends up with the PG_u bit set, since everything
runs in ring3.
Therefore, the privilege separation regarding memory relies solely on the fact
that the kernel pages are never present in the VM space when running in
A subtle mistake existed in NetBSD that caused this separation to be flawed:
the kernel pages in the OS PTD had the PG_u bit, which made Xen mark them as
global. When returning to userland, the VM space was indeed switched as
expected, but the TLB flush would not remove the kernel pages from the cache.
Userland thus had a small window where it could read or write to kernel pages
that were still cached and accessible to the CPU, even if not present in the
It has been demonstrated that userland can exploit this bug to patch the kernel
syscall array, and have code injected in the kernel.
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 summarise 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-6 netbsd-6-1 netbsd-6-0
---- ---- -------- ---------- -------- ---------- ----------
1.63 22.214.171.124 126.96.36.199.2.2 188.8.131.52 184.108.40.206.6.1 220.127.116.11.4.1
1.241 18.104.22.168 22.214.171.124.2.3 126.96.36.199 188.8.131.52.6.2 184.108.40.206.4.2
To update from CVS, re-build, and re-install the kernel:
# cd src
# cvs update -d -P -r VERSION sys/arch/x86/include/pmap.h
# cvs update -d -P -r VERSION sys/arch/x86/x86/pmap.c
# ./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:
Maxime Villard for finding the issue and writing a fix.
2017-03-24 Initial release
Advisories may be updated as new information becomes available.
The most recent version of this advisory (PGP signed) can be found at
Information about NetBSD and NetBSD security can be found at
http://www.NetBSD.org/ and http://www.NetBSD.org/Security/ .
Copyright 2017, The NetBSD Foundation, Inc. All Rights Reserved.
Redistribution permitted only in full, unmodified form.
-----BEGIN PGP SIGNATURE-----
-----END PGP SIGNATURE-----
Main Index |
Thread Index |