Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
FreeBSD Security Advisory FreeBSD-SA-03:16.filedesc

From: FreeBSD Security Advisories (security-advisoriesfreebsd.org)
Date: Thu Oct 02 2003 - 12:37:38 CDT

Hash: SHA1

FreeBSD-SA-03:16.filedesc Security Advisory
                                                          The FreeBSD Project

Topic: file descriptor leak in readv

Category: core
Module: kernel
Announced: 2003-10-02
Credits: Joost Pol <joostpine.nl>
Affects: FreeBSD 4.3-RELEASE through 4.8-RELEASE
                4-STABLE prior to the correction date
Corrected: 2003-10-02 15:08:01 UTC (RELENG_4, 4.9-RC)
                2003-10-02 15:54:48 UTC (RELENG_4_8, 4.8-RELEASE-p11)
                2003-10-02 15:55:54 UTC (RELENG_4_7, 4.7-RELEASE-p21)
                2003-10-02 15:56:56 UTC (RELENG_4_6, 4.6-RELEASE-p24)
                2003-10-02 15:57:48 UTC (RELENG_4_5, 4.5-RELEASE-p35)
                2003-10-02 15:58:53 UTC (RELENG_4_4, 4.4-RELEASE-p45)
                2003-10-02 16:05:44 UTC (RELENG_4_3, 4.3-RELEASE-p41)
FreeBSD only: YES

For general information regarding FreeBSD Security Advisories,
including descriptions of the fields above, security branches, and the
following sections, please visit

I. Background

The readv(2) system call performs a scatter read: it reads from the
input file descriptor and stores the data into multiple buffers as
instructed by the caller.

II. Problem Description

A programming error in the readv system call can result in the given
file descriptor's reference count being erroneously incremented.

III. Impact

A local attacker may cause the operating system to crash by repeatedly
calling readv on a file descriptor until the reference count wraps to
a negative value, and then calling close on that file descriptor.

Similarly, it may be possible to cause a file descriptor to reference
unallocated kernel memory, but remain valid. If a new file is later
opened and the kernel allocates the new file structure at the same
memory location, then an attacker may be able to gain read or write
access to that file. This may in turn lead to privilege escalation.

IV. Workaround

There is no workaround.

V. Solution

The following patch has been verified to apply to FreeBSD 4.3, 4.4,
4.5, 4.6, 4.7, and 4.8 systems.

a) Download the relevant patch from the location below, and verify the
detached PGP signature using your PGP utility.

# fetch ftp://ftp.FreeBSD.org/pub/FreeBSD/CERT/patches/SA-03:16/filedesc.patch
# fetch ftp://ftp.FreeBSD.org/pub/FreeBSD/CERT/patches/SA-03:16/filedesc.patch.asc

b) Apply the patch.

# cd /usr/src
# patch < /path/to/patch

c) Recompile your kernel as described in
<URL:http://www.freebsd.org/handbook/kernelconfig.html> and reboot the

VI. Correction details

The following list contains the revision numbers of each file that was
corrected in FreeBSD.

Branch Revision
- -------------------------------------------------------------------------
- -------------------------------------------------------------------------

VII. References

Version: GnuPG v1.2.3 (FreeBSD)