ESB-2018.1129 - [NetBSD] kernel: Increased privileges - Existing account 2018-04-12

Printable version
PGP/GPG verifiable version

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

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

                               ESB-2018.1129
                   Privilege separation bug in Xen-amd64
                               12 April 2018

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

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

Product:           kernel
Publisher:         NetBSD
Operating System:  NetBSD
Impact/Access:     Increased Privileges -- Existing Account
Resolution:        Patch/Upgrade

Original Bulletin: 
   ftp://ftp.netbsd.org/pub/NetBSD/security/advisories/NetBSD-SA2018-005.txt.asc

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

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


		NetBSD Security Advisory 2018-005
		=================================

Topic:		Privilege separation bug in Xen-amd64

Version:	NetBSD-current:		source prior to Sun, Dec 31st 2017
		NetBSD 7.1.2:		not affected
		NetBSD 7.1 - 7.1.1:	affected
		NetBSD 7.0 - 7.0.2:	affected
		NetBSD 6.1 - 6.1.5:	affected
		NetBSD 6.0 - 6.0.6:	affected

Severity:	Privilege escalation / Local DoS

Fixed:		NetBSD-current:		Sun, Dec 31st 2017
		NetBSD-7-1 branch:	Mon, Jan 22nd 2018
		NetBSD-7-0 branch:	Mon, Jan 22nd 2018
		NetBSD-7 branch:	Mon, Jan 22nd 2018
		NetBSD-6-1 branch:	Mon, Feb 19th 2018
		NetBSD-6-0 branch:	Mon, Feb 19th 2018
		NetBSD-6 branch:	Mon, Feb 19th 2018

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

A mistake the Xen-amd64 port of NetBSD allowed unprivileged users to
read from and write to the CPU's I/O ports. This could be used to
escalate privileges.


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

The kernel uses several flags that define CPU protections, and in particular,
SEL_KPL and SEL_UPL, that respectively define "kernel" privileges and "user"
privileges in the %cs register.

64bit Xen PV guests run, by design, in ring3, the same protection level as
userland. As a result, SEL_KPL equals SEL_UPL.

Xen uses a specific iopl privilege mechanism to control access rights to
the CPU I/O ports: it expects the iopl value to match the intended privilege,
and not the hardware privilege. Therefore, if the kernel wanted to prevent
userland from accessing the CPU I/O ports, it had to set the iopl to ring0,
even if the kernel actually runs in ring3.

A mistake existed in NetBSD, where iopl was unintentionally set to ring3,
allowing userland to access CPU I/O ports. The mistake in question was a
confusion with the privilege flags: iopl was set to SEL_KPL, but in the case
of Xen-amd64 this was equal to SEL_UPL, which meant ring3.


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
 ----     ----     --------     ----------     ----------
 src/sys/arch/amd64/amd64/machdep.c
          1.280    1.211.2.2    1.211.6.2      1.211.10.2
 src/sys/arch/amd64/include/segments.h
          1.34     1.24.12.1    1.24.16.1      1.24.22.1
 src/sys/arch/i386/i386/machdep.c
          1.800    1.752.4.2    1.752.8.2      1.752.12.2
 src/sys/arch/i386/include/segments.h
          1.64     1.54.30.1    1.54.34.1      1.54.38.1
 src/sys/arch/x86/x86/vm_machdep.c
          1.30     1.25.4.2     1.25.8.2       1.25.4.1.2.1

 FILE              netbsd-6     netbsd-6-0     netbsd-6-1
 ----              --------     ----------     ----------
 src/sys/arch/amd64/amd64/machdep.c
                   1.175.2.10   1.175.2.7.2.3  1.175.2.8.2.2
 src/sys/arch/amd64/include/segments.h
                   1.22.10.1    1.22.14.1      1.22.16.1
 src/sys/arch/i386/i386/machdep.c
                   1.717.2.9    1.717.2.7.4.2  1.717.2.7.6.2
 src/sys/arch/i386/include/segments.h
                   1.54.10.1    1.54.16.1      1.54.24.1
 src/sys/arch/x86/x86/vm_machdep.c
                   1.14.2.1     1.14.6.1       1.14.8.1


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

	# cd src
	# cvs update -d -P -r VERSION sys/arch/amd64/amd64/machdep.c
	# cvs update -d -P -r VERSION sys/arch/amd64/include/segments.h
	# cvs update -d -P -r VERSION sys/arch/i386/i386/machdep.c
	# cvs update -d -P -r VERSION sys/arch/i386/include/segments.h
	# cvs update -d -P -r VERSION sys/arch/x86/x86/vm_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 issue.


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

	2018-04-09	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-005.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-----

iQIcBAEBAgAGBQJay9YPAAoJEAZJc6xMSnBuvvkP/i++oukmYnYwveWd20jYIQ7r
/6K5FrdfslPkk8Wk0Rm8MV5QlPkp+aouJ/id/3ywQ7QoUx8qQOITo3yjTrVGqKkK
ksF2I5JLh+VwrOr4sitvanRST2b7FN6XqLL+UZf5aQg70ck/pobrI2nnH03Cs18I
snDno1hIly4WnBTu7H4+LvlUPgr+Ta6Ipix7/EwpQPKY6NImYG+LEIX8sEAe3D/e
RDyXV0O7/H6sf6cUmO4mNCnt1SbjblkS2LBMvYgrmrAWY5K6P93KYnQJ3HfIGwac
xM9FrQveZ2FYfoVx/OhIAmLrQXKTUde/YRhwwS8uyz4WLwaI1K31YjrVs6I2lcXn
K8AhGLzhHYr7d/UO9KgNufHlWtR1KEuqEj0LLOk3gFONmHkE37isZ6vnCR4+J3Ol
aVWGzd53pOxAz4i4e7KFfEDd91Xfxex1A561A6S7HGJtiTZX9UdvXraIU7/srC32
TjLbR7tHbiGm8O5Ajj9AvbCYaEcHaRNF6BImzz5SlZSsov9alCMuiotswgucyTkF
yu8rObLYJTGhNKHPrqMAN18jGQn9pap+KyT+DMcsDLQxtqEzuoqaSU6pSS76vt2E
bUb+RFhELRFCYjUr+UfWhCLRXlyK/2d6p7t3NAra0b0EVWQ0CoRSwEXwYKq76I8E
Lqk8n1FjrRmAqthVEqHi
=pr1D
- -----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:

        https://www.auscert.org.au/bulletins/

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

iQIVAwUBWs7D04x+lLeg9Ub1AQj4qhAAo55TVHuXc435UInlJ3msi2XQCcCESXnK
u30PABYjdsrDfvTu9e9IgDli7aHK2IjUjFEJIX5ZnnSfmSLrcRRXtR/n/GQMV+gF
9G0U8s/rsSoiy6TeQdQtYn68JENvoGU1QCNJYRAYx1Ty9/YHsUulqJm/WrqPv3Yu
2NXjwkSEsm/RgMwXFCanIhGvGq6fUB1hlMpMZy2t2czfXAVLDEm3S4yn8HSiFJtS
lWIv1DQMxVZ+TlA580HZN2qF1xnQw9I/WjeSAQFGLm5gT2WdfuKv0L90K6lGEoUm
O/nUTxZWIzIeE0qKToYmX74YO09SokGMrRpKwaSCxkcGWAxNSw6lCoOMp4te3aIU
H8423Vc2iF3Xtl9pJG4GyTjhJfJtSzlWAHYzJXe/hROKB3s/xWWWMArM7e6AK+CS
VMmJJdzYA78+ZTJCZMp4P7L9coCKXBs8u7hRMaMDgDqaPtvqn6LJhdId+2Zdigvx
GuGQ04Dd/ucnm5ajRrRTxlG3/z3/WvjgkJjHo5A/TNLdxwpMUInB0cSzS8HgJLrm
roHiNaacNf36ssvc+VbYbLZO2KFq5sAQd7WueJW48sRWfQjkE7huVQf/8uISKvhh
9Q4o5p+Ludeb1weXjwYImQ4mrkJSjS0+61+l9hX3D91iGX+JbYGDDeFQ0sBWzay2
hJZ6xfTB7CI=
=vZoZ
-----END PGP SIGNATURE-----

« Back to bulletins