-----BEGIN PGP SIGNED MESSAGE-----

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

                ESB-2003.0009 -- FreeBSD-SA-02:44.filedesc
                     file descriptor leak in fpathconf
                              08 January 2003

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

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

Product:                fpathconf
Vendor:                 FreeBSD
Operating System:       FreeBSD 4.x
                        FreeBSD 5.0
Impact:                 Root Compromise
                        Denial of Service
Access Required:        Existing Account

Ref:                    ESB-2003.0007

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

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

=============================================================================
FreeBSD-SA-02:44.filedesc                                   Security Advisory
                                                          The FreeBSD Project

Topic:          file descriptor leak in fpathconf

Category:       core
Module:         kernel
Announced:      2003-01-07
Credits:        Joost Pol <joost@pine.nl>
Affects:        FreeBSD 4.3-RELEASE and later versions
Corrected:      2002-11-11 01:43:31 UTC (RELENG_4)
                2003-01-06 12:37:52 UTC (RELENG_4_7)
                2003-01-06 12:38:21 UTC (RELENG_4_6)
                2003-01-07 15:17:16 UTC (RELENG_4_5)
                2003-01-07 15:17:40 UTC (RELENG_4_4)
                2003-01-06 21:20:54 UTC (RELENG_5_0)
FreeBSD only:   YES

0.   Revision History

2003-01-06  v1.0  Initial release.
2003-01-07  v1.1  Added information regarding bug in FreeBSD 5.x.
                  Added correction details for RELENG_4_5, RELENG_4_4.

I.   Background

The fpathconf system call provides a method for applications to
determine the current value of a configurable system limit or option
variable associated with a pathname or file descriptor.

II.  Problem Description

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

A similar problem exists in the developer preview versions of FreeBSD
5.0, affecting the lseek(2), dup(2), and other system calls.

III. Impact

A local attacker may cause the operating system to crash by repeatedly
calling fpathconf 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.4, 4.5,
4.6, and 4.7 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-02:44/filedesc.patch
# fetch ftp://ftp.FreeBSD.org/pub/FreeBSD/CERT/patches/SA-02:44/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
system.

VI.  Correction details

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

Path                                                             Revision
  Branch
- - -------------------------------------------------------------------------
src/sys/kern/kern_descrip.c
  RELENG_4                                                      1.81.2.15
  RELENG_4_7                                                1.81.2.14.4.1
  RELENG_4_6                                                1.81.2.14.2.1
  RELENG_4_5                                                 1.81.2.9.2.3
  RELENG_4_4                                                 1.81.2.8.2.3
  RELENG_5_0                                                    1.169.2.2
src/sys/kern/vfs_syscalls.c
  RELENG_5_0                                                    1.297.2.2
- - -------------------------------------------------------------------------

VII. References

<URL:http://www.pine.nl/press/pine-cert-20030101.txt>
- -----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (FreeBSD)

iD8DBQE+GxDCFdaIBMps37IRAkDtAJ9Ma79bfwhHHBMe1v0gVgvzrFtoMgCgmh/v
iyuKtTozFxmSATQP1w5VEWg=
=MWcN
- -----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.

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 use any or all of this information is
the responsibility of each user or organisation, and should be done so in
accordance with site policies and procedures.

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:

        http://www.auscert.org.au/render.html?cid=1980

If you believe that your system has been compromised, contact AusCERT or
your representative in FIRST (Forum of Incident Response and Security
Teams).

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-----
Version: 2.6.3i
Charset: noconv
Comment: http://www.auscert.org.au/render.html?it=1967

iQCVAwUBPhv1bSh9+71yA2DNAQGD4QQAkonDZIUfyLeZIAHP3mqKX84vA2ksE1ME
FsWc+nhcUw6DWLCyFwR5MSn/H1iDIi0NRHjPivCOokX1x00q4UO3EWDNSXyBOk3j
OSOjZFQbgX5Nrl9c+Vgpy5/tYRJSoy66k6nUJeydVwdaZwwz+G58IKkAkf65m5ub
K3Ey6vPj8og=
=gYSK
-----END PGP SIGNATURE-----