ESB-2017.2286 - [NetBSD] kernel: Execute arbitrary code/commands - Existing account 2017-09-11

Printable version
PGP/GPG verifiable version

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

===========================================================================
             AUSCERT External Security Bulletin Redistribution

                               ESB-2017.2286
                 x86: vulnerabilities in context handling
                             11 September 2017

===========================================================================

        AusCERT Security Bulletin Summary
        ---------------------------------

Product:           kernel
Publisher:         NetBSD
Operating System:  NetBSD
Impact/Access:     Execute Arbitrary Code/Commands -- Existing Account
                   Increased Privileges            -- Existing Account
                   Denial of Service               -- Existing Account
Resolution:        Patch/Upgrade
CVE Names:         CVE-2012-0217  

Reference:         ASB-2012.0143
                   ESB-2012.0694
                   ESB-2012.0610
                   ESB-2012.0554.2

Original Bulletin: 
   http://ftp.NetBSD.org/pub/NetBSD/security/advisories/NetBSD-SA2017-00X.txt.asc

- --------------------------BEGIN INCLUDED TEXT--------------------

- -----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

		NetBSD Security Advisory 2017-005
		=================================

Topic:		x86: vulnerabilities in context handling


Version:	NetBSD-current:		source prior to Sun, Jul 1st 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:		Sun, Jul 1st 2017
		NetBSD-7-1 branch:	Thu, Jul 20th 2017
		NetBSD-7-0 branch:	Thu, Jul 20th 2017
		NetBSD-7 branch:	Thu, Jul 20th 2017
		NetBSD-6-1 branch:	Tue, Aug 8th 2017
		NetBSD-6-0 branch:	Tue, Aug 8th 2017
		NetBSD-6 branch:	Tue, Aug 8th 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
========

Three issues were discovered in the i386 and amd64 ports of NetBSD:

 1) A missing check in the trap handler could allow userland to panic an i386
    kernel.
 2) A race condition could allow userland to panic an i386 kernel, and
    escalate privileges on amd64.
 3) A missing check in the Linux compatibility layer could allow userland to
    exploit the Intel Sysret Vulnerability on amd64.


Technical Details
=================

 1) Under certain circumstances, userland can legitimately make the kernel
    generate a stack fault when executing 'iret'. However, in the trap handler,
    the appropriate check was missing, and this fault could lead to a panic.
 2) The same call gate existed on i386 and amd64 that allowed binaries from
    previous releases to perform syscalls. However, call gates do not
    automatically disable interrupts when entering the target function.
    Therefore, there was a condition where the kernel would be executed with
    userland registers loaded and interrupts enabled, which breaks a certain
    number of assumptions in the i386 and amd64 implementations. On i386 this
    can lead to a panic, and on amd64 to a privilege escalation.
 3) A missing check in the trap frame could allow userland to have the kernel
    execute 'sysret' with a fully-controllable %rip, thereby allowing the
    exploitation of the Intel Sysret Vulnerability (see NetBSD-SA2012-003).


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-7-1
 ----     ----     --------     ----------     ----------
 sys/arch/i386/i386/trap.c
          1.288    1.272.4.2    1.272.6.2      1.272.10.2
 sys/arch/i386/i386/locore.S
          1.146    1.112.4.1    1.112.6.1      1.112.10.1
 sys/arch/i386/i386/machdep.c
          1.783    1.752.4.1    1.752.8.1      1.752.12.1
 sys/arch/amd64/amd64/trap.c
          1.96     1.78.4.3     1.78.6.3       1.78.10.3
 sys/arch/amd64/amd64/locore.S
          1.124    1.76.2.2     1.76.4.2       1.76.8.2
 sys/arch/amd64/amd64/machdep.c
          1.254    1.211.2.1    1.211.6.1      1.211.10.1
 sys/compat/linux/arch/amd64/linux_machdep.c
          1.51     1.48.4.1     1.48.8.1       1.48.4.1

 FILE              netbsd-6     netbsd-6-0     netbsd-6-1
 ----              --------     ----------     ----------
 sys/arch/i386/i386/trap.c
                   1.262.8.2    1.262.12.2     1.262.14.2
 sys/arch/i386/i386/locore.S
                   1.95.10.4    1.95.10.2.4.1  1.95.10.3.2.1
 sys/arch/i386/i386/machdep.c
                   1.717.2.8    1.717.2.7.4.1  1.717.2.7.6.1
 sys/arch/amd64/amd64/trap.c
                   1.69.2.3     1.69.2.1.4.2   1.69.2.1.6.2
 sys/arch/amd64/amd64/locore.S
                   1.66.2.2     1.66.2.1.4.1   1.66.2.1.6.1
 sys/arch/amd64/amd64/machdep.c
                   1.175.2.9    1.175.2.7.2.2  1.175.2.8.2.1
 sys/compat/linux/arch/amd64/linux_machdep.c
                   1.39.6.1     1.39.10.1      1.39.12.1

To update from CVS, re-build, and re-install the kernel:

	# cd src
	# cvs update -d -P -r VERSION sys/arch/i386/i386/trap.c
	# cvs update -d -P -r VERSION sys/arch/i386/i386/locore.S
	# cvs update -d -P -r VERSION sys/arch/i386/i386/machdep.c
	# cvs update -d -P -r VERSION sys/arch/amd64/amd64/trap.c
	# cvs update -d -P -r VERSION sys/arch/amd64/amd64/locore.S
	# cvs update -d -P -r VERSION sys/arch/amd64/amd64/machdep.c
	# cvs update -d -P -r VERSION sys/compat/linux/arch/amd64/linux_machdep.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:

   http://www.NetBSD.org/guide/en/chap-kernel.html


Thanks To
=========

Maxime Villard for finding and fixing the issues, Chuck Silvers for proposing
a better fix for issue 2).


Revision History
================

	2017-09-08	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-SA2017-00X.txt.asc

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

iQIcBAEBAgAGBQJZsqiyAAoJEAZJc6xMSnBuCOwQAMKKCxNKpCLLfgA8LZZTxQz5
WnzV6J3iAa7G7LPPgkGIHi87o0pgMhQf3YpWwrhI1sevHvX+bAk13HZSTNeLENnE
a08hZALZbk9BzVZK3tzSYNJMjZcXGmk1R9du5OV4H53ApGQrpDn6K/RdVp5YdJps
iPk20i9lUZC00SYEO96/nVuLU0FcC4wQrdXa7iK4pi62KhYhmSwVTk6NIBA0NWta
rW/emzUAspriW8l13WTRYOew0R5W2EMOvpJZoaCHaPW/MKDeQK0N8YSlRXiBJQuT
ehb9+7Z01RbAWxt8a7Xv/kZVe/ibttKgAa2LJ/rrG5Og0Jg2m+eCEq66m3gMyAbR
+OzGmWk598hJ//SeykHYtV/7zfMznI/JLMldxD4X2zp5nC5kalIfkSNVXi50dsDv
UhizH1GVw2ZMzlAKRu7QqeuhFNF4PmOi+3DW1FkDckcf/FOIgfafmh6TqSSayQYS
vyUmGiUPL71+bcVzKttYz/P3NsFvjge9rFS881+//F73IEiZkPIts/Gus9cgORST
DaRe2mpGpHtnvVjCaEnj2JnDfA6wn2LqqYjv9eZ/sx7cEdVq5+lYFsE1ioP3WdCA
MKtGTxalKeFP4lF7LVMlbgH9bX2mS2CvJAkGSyfeHmZ+tDP8mpUXHAa038Mmpf3R
iBZDxJx7PCwzYGLRMMDl
=Ew1W
- -----END PGP SIGNATURE-----

- --------------------------END INCLUDED TEXT--------------------

You have received this e-mail bulletin as a result of your organisation's
registration with AusCERT. The mailing list you are subscribed to is
maintained within your organisation, so if you do not wish to continue
receiving these bulletins you should contact your local IT manager. If
you do not know who that is, please send an email to auscert@auscert.org.au
and we will forward your request to the appropriate person.

NOTE: Third Party Rights
This security bulletin is provided as a service to AusCERT's members.  As
AusCERT did not write the document quoted above, AusCERT has had no control
over its content. The decision to follow or act on information or advice
contained in this security bulletin is the responsibility of each user or
organisation, and should be considered in accordance with your organisation's
site policies and procedures. AusCERT takes no responsibility for consequences
which may arise from following or acting on information or advice contained in
this security bulletin.

NOTE: This is only the original release of the security bulletin.  It may
not be updated when updates to the original are made.  If downloading at
a later date, it is recommended that the bulletin is retrieved directly
from the author's website to ensure that the information is still current.

Contact information for the authors of the original document is included
in the Security Bulletin above.  If you have any questions or need further
information, please contact them directly.

Previous advisories and external security bulletins can be retrieved from:

        http://www.auscert.org.au/render.html?cid=1980

===========================================================================
Australian Computer Emergency Response Team
The University of Queensland
Brisbane
Qld 4072

Internet Email: auscert@auscert.org.au
Facsimile:      (07) 3365 7031
Telephone:      (07) 3365 4417 (International: +61 7 3365 4417)
                AusCERT personnel answer during Queensland business hours
                which are GMT+10:00 (AEST).
                On call after hours for member emergencies only.
===========================================================================
-----BEGIN PGP SIGNATURE-----
Comment: http://www.auscert.org.au/render.html?it=1967

iQIVAwUBWbXxYox+lLeg9Ub1AQiZYBAAlD/e78MV8K3bE95nDuuumKEfklbOROrb
n2Ap9yrSHC6eKN9X7M5sF9y8IChQ5bZYee7QniaaKGYD1kih8gYJaYwflKRNPgdD
mB86kWQGYvG1cc2H5BKH6nr3aF5h7Yk9nZAt67w3LxSJ7vcJWpXzDOMdT9d5D9cp
b6Tu3lQdk4T4s1tBkp6KH5hl6U4yMFAz1TxJQQY/2xE5a8zN5ok0dHnnJ/yBdJ3w
VsrBHibhkmxFTPc2BzxILPkWiZkfVic2ou9Wr4aiIWDE/YAy9HwKHdVkKY1nky7/
/82dRxKhdNnbGOGrvE+Kk+oZiIlKga7GtxZMYt1i+s0zJeS0rr+1+l3p2bcH8/AS
WbdF5hQGqKLhduSH7hDUzHemUG39jfiV6gjfWt4bnwXKXYFVtjRIQU1q+pDEMvdq
xDVGAx5gydkVoJKdPXn6L8pa9tNO/h3qvoDgfv/lbg5COZgd99ATCh9bZPGh9imu
eRAtRSfXFRo+W8PMIo5O+S+wiuKxI9MmAdeV/CeQ5fjPqW7ETtOJA+vZGb3jAjQV
AjUtaq8gCprgBezmVFWBbgllwVD24cRY0maPXOOUjcAQKUB1S74pB8mm/BbLv3Iq
Tioxz/B5Igs7dEQDaYiC9zl+IlIJ5bK/EaNmr1RzbeHmA1VvvnY3zoUWQsLyS13S
jbirdbYsQcA=
=kRNH
-----END PGP SIGNATURE-----

« Back to bulletins