-----BEGIN PGP SIGNED MESSAGE----- NetBSD Security Advisory 2003-014 ================================= Topic: Insufficient argument checking in sysctl(2) Version: NetBSD-current: source prior to October 3, 2003 (*) NetBSD 1.6.1: affected NetBSD 1.6: affected NetBSD-1.5.3: affected NetBSD-1.5.2: affected NetBSD-1.5.1: affected NetBSD-1.5: affected Severity: local DoS, read protected kernel memory Fixed: NetBSD-current: October 3, 2003 NetBSD-1.6 branch: October 3, 2003 (1.6.2 will include the fix) NetBSD-1.5 branch: October 9, 2003 (*) - This advisory has been updated with additional sysctl issues. See the details below, or the revision history. Abstract ======== Three unrelated problems with inappropriate argument handling were found in the kernel sysctl(2) code, which could be exploited by a malicious local user: Some sysctl nodes could cause the kernel to dereference a NULL pointer, resulting in a panic. (item 1 in technical details section) Passing the process id of a zombie process could cause the kernel to dereference invalid process data, and panic. (item 2) Other sysctl nodes had an insufficient range check, which could be abused to read arbitrary locations in kernel memory space. (item 3 and 4) NOTE: previous revision of the advisory did not catch (4) in the technical details. Technical Details ================= There are four unrelated problems which were found during an effort to reimplement the sysctl(2) infrastructure. 1) A pointer variable was reused for pointing user-level addresses (sysctl(2) argument) and kernel addresses, and there was a code path which would allow a local user to set the pointer to NULL. 2) The proc.* sysctl tree could be invoked on a zombie process, but made assumptions that the processes were in a valid state, and so could attempt to reference process information that is invalid or non-existent for zombies. This is no longer possible. 3) Under the proc.curproc.rlimit subtree there are a number of nodes representing the process resource limits, soft and hard. The sysctl helper function used to manipulate these values had an insufficient range check, and could be used to read values outside of the working copy of the rlimit structure. Writes have been changed to check thoroughly. 4) The code that supports the debug.* subtree had an insufficient range check, and could be used to read/write values outside of the intended variables. The flaw will exist only if "options DEBUG" is specified in the kernel configuration file, which is not the case in the GENERIC or INSTALL kernel configurations. Solutions and Workarounds ========================= To correct this problem, a kernel upgrade (and reboot) is required. There is no practical work-around for systems running the vulnerable code in the kernel. The fixes for all of these issues are contained in the one file, sys/kern/kern_sysctl.c. The following table lists the fixed revisions and dates of this file for each branch: CVS branch revision date ------------- ----------- ---------------- HEAD 1.147 2003/10/03 netbsd-1-6 1.108.4.4 2003/10/03 netbsd-1-5 1.73.2.7 2003/10/09 The following instructions describe how to upgrade your kernel binaries by updating your source tree and rebuilding and installing a new version of the kernel. In these instructions, replace: BRANCH with the appropriate CVS branch (from the above table) ARCH with your architecture (from uname -m), and KERNCONF with the name of your kernel configuration file. To update from CVS, re-build, and re-install the kernel: # cd src # cvs update -d -P -r BRANCH sys/kern/kern_sysctl.c # cd sys/arch/ARCH/conf # config KERNCONF # cd ../compile/KERNCONF # make depend;make # mv /netbsd /netbsd.old # cp netbsd / # reboot Thanks To ========= Andrew Brown Eike Dehling for corrections to the advisory. smak@bbugs.org Revision History ================ 2003-09-17 Initial release 2003-09-18 Correct path in rebuild instructions. 2003-10-09 Additional issues - details updated 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-014.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-014.txt,v 1.16 2003/10/09 02:24:33 david Exp $ -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.6 (NetBSD) Comment: For info see http://www.gnupg.org iQCVAwUBP4V/TD5Ru2/4N2IFAQG6aAQAgLPT90yovcslYBMpF5M561JR56vd/pwb b8zmi5u+cNqZ7y2mbyuKIRpXBGlry4qqs66WBJkx6ISR5bD/Eglbw8ktJqNbzOEj zSKJzFBUTr9LS67h3nwvc6H6Wty38osZDXO/Bq5s/Ti7Ej4bKUTVVB/aQTNW09wG 9+S12xKIAkw= =0iOn -----END PGP SIGNATURE-----