Home    |    View Topics    |    Search    |    Contact Us    |   



Category:   OS (UNIX)  >   FreeBSD Kernel Vendors:   FreeBSD
FreeBSD Kernel Integer Overflow May Let Local Users Deny Service, Gain Elevated Privileges, or View Files on the System
SecurityTracker Alert ID:  1005898
SecurityTracker URL:
CVE Reference:   CVE-2003-1234   (Links to External Site)
Updated:  Jun 8 2008
Original Entry Date:  Jan 7 2003
Impact:   Denial of service via local system, Disclosure of system information, Disclosure of user information, Execution of arbitrary code via local system, Root access via local system
Fix Available:  Yes  Vendor Confirmed:  Yes  

Description:   An integer overflow was reported in the FreeBSD operating system kernel. A local user could trigger a kernel panic, gain elevated privileges, or view files on the system.

Pine Digital Security reported that there is an exploitable integer overflow in the FreeBSD operating system kernel.
It is reported that the fpathconf(2) system call is missing a call to the fdrop() function. When an fpathconf(2) call is issued on a socket, the call will reportedly issue an fhold() call to prevent the associated file from being closed during the operation. However, the fpathconf(2) call may return an error indication in some situations without issuing an fdrop() call to release the extra file reference.

Because of this, a local user could cause the 'f_count' integer reference counter of the specified file structure to overflow. When the original file descriptor is closed, the associated file structure will be deallocated. This leaves the extra file reference remaining with a file structure that points to unallocated memory.

The same type of flaw reportedly exists in the lseek(2) system call in some versions of FreeBSD.

Pine Digital Security notes that the missing fdrop() call in fpathconf(2) was previously reported by Nakamura Takayuki, but that the impact was originally underestimated.

Impact:   A local user could trigger a kernel panic, gain elevated privileges, or view files on the system. According to the report, it has been confirmed that a a local user can trigger a system panic and also obtain elevated privileges.
Solution:   According to the report, the CVS version should have been updated by the time the Pine Digital Security advisory was released.
Vendor URL: (Links to External Site)
Cause:   Boundary error

Message History:   None.

 Source Message Contents

Subject:  PDS: Integer overflow in FreeBSD kernel

Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

See attached advisory,


Joost Pol
Service Provider :: Pine Digital Security :: tel XX-XXXXXXXX :: 070-311 10 10 
:: PGP id 0xF360BB93 fpr ABED 303C 0120 E057 633A 1CB1 D236 C82A F360 BB93 ::  

Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="pine-cert-20030101.txt.asc"

Hash: SHA1

- -----------------------------------------------------------------------------
Pine Digital Security Advisory 
- -----------------------------------------------------------------------------
Advisory ID       : PINE-CERT-20030101
Authors           : Joost Pol
Vendor Informed   : 2002-12-30 
Issue date        : 2003-01-06 
Application       : Kernel 
Version(s)        : Various
Platforms         : FreeBSD 
Availability      : 
- -----------------------------------------------------------------------------


	While performing an audit for a customer, Pine Digital Security 
	found an integer overflow in the FreeBSD kernel.



	 RELENG_4   (aka -STABLE) 	: not vulnerable after 20021111
	 RELENG_5_0 (aka -CURRENT)      : vulnerable in lseek(2) (199)
	 All current -RELEASE versions  : vulnerable in fpathconf(2) (192)

        OpenBSD/NetBSD: not vulnerable



	This integer overflow could cause a system panic, resulting in a 
	Denial-of-Service (DoS). Also, this could be used to escalate 
	privileges or cause the system to disclose (sensitive) files.


	Inside the FreeBSD kernel each file (socket, device or regular 
	file) opened is represented by a file structure (sys/file.h).

        Amongst other members this structure holds a reference counter 
	(int f_count). This reference counter is increased by the fhold() 
	function and decreased by the fdrop() function. (both in sys/file.h)

	For example, when a file is open(2)ed or dup(2)ed the reference 
	counter is increased and when the file is close(2)ed again the
	reference counter is decreased. Once the reference counter reaches 
	zero, the file structure itself is deallocated.

	Most system calls which perform (blocking) operations on a file
	will issue a fhold() call to prevent the file from being closed
	in the middle of an operation. Once the operation is finished the 
	(extra) reference will be released again by issuing a fdrop() call.
	Inside the fpathconf(2) (192) system call we spotted a condition
	where a call to fdrop() is missing. When issueing a fpathconf(2)
	call on a socket it will return with an error condition but it 
	will not release the extra file reference.

     	Due to the missing fdrop() call inside the fpathconf(2) system
        call is it possible to overflow the reference counter of the
	file structure (int f_count).

	FreeBSD -CURRENT suffers from the same problem in another syscall.


	Causing a system panic and privilege escalation have been confirmed.
	Exploitation of this bug will take time, depending on machine 
	speed and system limits this could vary between hours and days. 

	1. System Panic
	A system panic can be caused by issuing around 2^31 calls to 
	fpathconf(2) with a filedescriptor which references a socket. 
	The reference counter (int f_count) will wrap to a negative
	value and this will cause a panic in close(2).
	2. Privilege Escalation
	It is also possible (although more difficult) to gain root access
	using this bug. One would open(2) a socket and dup(2) it. One would 
	then issue around 2^32 - 1 calls to fpathconf(2) causing the reference 
	counter to wrap to 1. 

	After closing the original filedescriptor the file structure will 
	be deallocated. At this point the dup(2)ed file descriptor is still 
	hanging around with a file structure pointing to unallocated memory. 
	The final step, which is left as an excercise for the reader, is 
	to have a sensitive file (like /etc/skeykeys) opened and 
	allocated at the previously freed location. 

	Once this happens the dup(2)ed file descriptor is still hanging 
	around providing access to this file. This could result in the 
	escalation of user privileges. 


	Pine Digital Security does not release exploits.

	Although the missing fdrop() call in fpathconf(2) was noticed
	before by Nakamura Takayuki <> its impact
	was severely underestimated.


	FreeBSD CVS should be updated.

Version: GnuPG v1.2.1 (SunOS)




Go to the Top of This SecurityTracker Archive Page

Home   |    View Topics   |    Search   |    Contact Us

This web site uses cookies for web analytics. Learn More

Copyright 2022, LLC