NetBSD-Announce archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

NetBSD Security Advisory 2018-001: Several vulnerabilities in context handling



-----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:		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


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-----

iQIcBAEBAgAGBQJaS73UAAoJEAZJc6xMSnBu3f8QAIaR/so5X+rylr+0pzRytdjx
xqBwbvepMoJzVC6gftxxtHy+BEtFiVmDFAX2de1GhvKmjCpZHAk9wPzdB97Xr5Vq
t1zPBz9fUkPtFHG+/G4S8k+SLaz1v2qklakvpCyVMjWeNuKKUz9Y5iG3zIVUv90T
fYcVPu6zW46NX3HG/JvnMoxaVNhk6CKbchYrQBmWCx24jpBXU/LA0iuxJjYm3UYp
uJ7F+BJXy30xVs6x+hd4Qa+h/WNFDsi3bJBmwkuWafp2QLf9mMnAk8O8M3Ynf/MG
9jz5o9K4neh92oSRgL+5MEvWPDNIU6GGlZ+3UYoJOMGKJxVhsj6UHW/rclKxrGpP
2dt0Ge2DcOXHL7MsTFsPerwY/N87G1SFVIz59pJzn9shXxQ82+JcNC2ICXRDf0AH
BHry8owRvwefXTfOAWW8JcoyYx4apUR5hCatsZ6rK7otcxVzhZa5QQZXqsZMhbxE
C5/CxWgeIDZDslWMlOJaol38zlo019ZEActi5eVMfv7KfTq/TTgLaUEZgofLKx3R
3Yfv0lWKcKdW4QL01qsiucQb5tFGjLFuc7BAS8I5hLaVIwaJTHrByJJVjxqS5cbB
hPlJRYtyLsOXFS8cuPzrp7pmwiWj5ck0ba+JkRvMQwm4Qv+AFOxkUVL6VvL4WxG/
1CAvMaO/BGunH17VHpYI
=QqHl
-----END PGP SIGNATURE-----


Home | Main Index | Thread Index | Old Index