The iBCS2 system call translator for statfs erroneously used theuser-supplied length parameter when copying a kernel data structureinto userland.

NetBSD Security Advisory 2003-013
=================================
Topic: Kernel memory disclosure via ibcs2
Version: NetBSD-current: source prior to August 7, 2002
NetBSD 1.6.1: not affected
NetBSD 1.6: not affected
NetBSD-1.5.3: affected
NetBSD-1.5.2: affected
NetBSD-1.5.1: affected
NetBSD-1.5: affected
Severity:
Fixed: NetBSD-current: August 7, 2002
NetBSD-1.6 branch: not affected
NetBSD-1.5 branch: August 28, 2002
Abstract
========
The iBCS2 system call translator for statfs(2) erroneously used the
user-supplied length parameter when copying a kernel data structure
into userland. If the length parameter were larger than required,
then instead of copying only the statfs-related data structure,
additional kernel memory would also be made available to the user.
Technical Details
=================
If iBCS2 support were enabled, a malicious user could call the iBCS2
version of statfs(2) with an arbitrarily large length parameter,
causing the kernel to return a large portion of kernel memory. Such
memory might contain sensitive information, such as portions of the
file cache or terminal buffers. This information might be directly
useful, or it might be leveraged to obtain elevated privileges in some
way. For example, a terminal buffer might include a user-entered
password.
iBCS2 support is only present on i386/vax GENERIC kernel.
Solutions and Workarounds
=========================
If your kernel configuration file does not contain COMPAT_IBCS2,
your system is not affected.
The following instructions describe how to upgrade your kernel
binaries by updating your source tree and rebuilding and
installing a new version of kernel.
* NetBSD-current:
Systems running NetBSD-current dated from before 2002-08-06
should be upgraded to NetBSD-current dated 2002-08-07 or later.
The following directories need to be updated from the
netbsd-current CVS branch (aka HEAD):
src/sys/compat/ibcs2/ibcs2_stat.c
However, because the date of the point fix is way too old, we'd suggest
you to update the whole kernel. The following instruction is for
updating the whole kernel.
To update from CVS, re-build, and re-install the kernel and reboot:
# cd src
# cvs update -d -P sys
# cd sys/ARCH/conf
# config KERNELCONF
# cd ../../compile/KERNELCONF
# make depend; make
# cp netbsd /
# reboot
* NetBSD 1.6, 1.6.1:
The binary distribution of NetBSD 1.6 and 1.6.1 are NOT vulnerable.
* NetBSD 1.5, 1.5.1, 1.5.2, 1.5.3:
The binary distribution of NetBSD 1.5 to 1.5.3 are vulnerable.
Systems running NetBSD 1.5, 1.5.1, 1.5.2, or 1.5.3 sources dated
from before 2003-08-27 should be upgraded from NetBSD 1.5.*
sources dated 2003-08-28 or later.
The following directories need to be updated from the
netbsd-1-5 CVS branch:
src/sys/compat/ibcs2/ibcs2_stat.c
To update from CVS, re-build, and re-install the kernel and reboot:
# cd src
# cvs update -d -P -r netbsd-1-5 sys/compat/ibcs2/ibcs2_stat.c
# cd sys/ARCH/conf
# config KERNELCONF
# cd ../../compile/KERNELCONF
# make depend; make
# cp netbsd /
# reboot
Alternatively, apply the following patch (with potential offset
differences):
ftp://ftp.NetBSD.org/pub/NetBSD/security/patches/SA2003-013-ibcs2.patch
To patch, re-build and re-install re-install the kernel and reboot:
# cd src/sys/compat/ibcs2
# patch < /path/to/SA2003-013-ibcs2.patch
# make cleandir dependall
# make install
Thanks To
=========
Some of the text are derived from FreeBSD security advisory
FreeBSD-SA-03:10.ibcs2.
The problem in ibcs2_stat.c was pointed out by silvio@qualys.com.
Revision History
================
2003-09-17 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
ftp://ftp.NetBSD.org/pub/NetBSD/security/advisories/NetBSD-SA2003-013.txt.asc
Information about NetBSD and NetBSD security can be found at
http://www.NetBSD.org/ and http://www.NetBSD.org/Security/.
Copyright 2003, The NetBSD Foundation, Inc. All Rights Reserved.
Redistribution permitted only in full, unmodified form.
$NetBSD: NetBSD-SA2003-013.txt,v 1.4 2003/09/17 02:47:19 david Exp $