exploit the possibilities
Home Files News &[SERVICES_TAB]About Contact Add New

Linux 2.6.28 fasync File Descriptor Issue

Linux 2.6.28 fasync File Descriptor Issue
Posted Jan 14, 2010
Authored by Tavis Ormandy

Linux kernel versions 2.6.28 and above suffer from an issue where locked fasync file descriptors can be referenced after free.

tags | advisory, kernel
systems | linux
SHA-256 | bf4b36103b7fd4bfc5b3d7bc2a781801086000a705d62c49f239f5091370bb78

Linux 2.6.28 fasync File Descriptor Issue

Change Mirror Download
Locked fasync file descriptors can be referenced after free in >= 2.6.28
-------------------------------------------------------------------------

A problem has been discovered handling locked fasync file descriptors.

Quoting analysis from Linus, "The problem is that the *same* file
descriptor can be on *multiple* fasync lists. It can be on a particular
fasync list just once, but file locking is special, and uses the
'fl->fl_fasync' list to add an arbitrary file to its own fasync list -
regardless of what the underlying device driver or whatever is."

This is an issue because fasync_helper() will clear the FASYNC flag as
it incorrectly assumes a file can only be on one fasync list.

http://lxr.linux.no/#linux+v2.6.30.4/fs/fcntl.c#L566

When the descriptor is finally closed and the file released, the FASYNC
flag will no longer be set and so it will not be removed the fasync list,
thus leaving a dangling reference to the freed structure.

A testcase for this issue which should result in an OOPS caused by a
userland pointer dereference is available here.

http://lock.cmpxchg8b.com/5ebe2294ecd0e0f08eab7690d2a6ee69/create_elf_tables.c

(gdb) bt
#0 __kill_fasync (fa=0xdf294820, sig=29, band=131073) at
/build/buildd/linux-2.6.31/fs/fcntl.c:587
#1 0xc01f4a32 in kill_fasync (fp=0xc089be64, sig=29, band=131073) at
/build/buildd/linux-2.6.31/fs/fcntl.c:614
(gdb) list
592 return;
593 }
594 fown = &fa->fa_file->f_owner;
595 /* Don't send SIGURG to processes which have not set a
596 queued signum: SIGURG has its own default signalling
597 mechanism. */
598 if (!(sig == SIGURG && fown->signum == 0))
599 send_sigio(fown, fa->fa_fd, band);
600 fa = fa->fa_next;
601 }
(gdb) p fa->fa_file->f_owner
$37 = {lock = {raw_lock = {lock = 2621449}}, pid = 0x1c001d, pid_type =
1179403647, uid = 65793, euid = 0, signum = 0}

(this is obviously nonsense, and send_sigio is going to explode)

http://lxr.linux.no/#linux+v2.6.32/fs/fcntl.c#L550

Linus has committed the following patch to address this issue
http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=53281b6d3

This bug was discovered by Tavis Ormandy.

Thanks to legendary kernel hackers Linus, Matt Mackall and Al Viro who
did most of the hard work tracking down the root cause.

--
-------------------------------------
taviso@sdf.lonestar.org | finger me for my gpg key.
-------------------------------------------------------

Login or Register to add favorites

File Archive:

December 2022

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    Dec 1st
    2 Files
  • 2
    Dec 2nd
    12 Files
  • 3
    Dec 3rd
    0 Files
  • 4
    Dec 4th
    0 Files
  • 5
    Dec 5th
    0 Files
  • 6
    Dec 6th
    0 Files
  • 7
    Dec 7th
    0 Files
  • 8
    Dec 8th
    0 Files
  • 9
    Dec 9th
    0 Files
  • 10
    Dec 10th
    0 Files
  • 11
    Dec 11th
    0 Files
  • 12
    Dec 12th
    0 Files
  • 13
    Dec 13th
    0 Files
  • 14
    Dec 14th
    0 Files
  • 15
    Dec 15th
    0 Files
  • 16
    Dec 16th
    0 Files
  • 17
    Dec 17th
    0 Files
  • 18
    Dec 18th
    0 Files
  • 19
    Dec 19th
    0 Files
  • 20
    Dec 20th
    0 Files
  • 21
    Dec 21st
    0 Files
  • 22
    Dec 22nd
    0 Files
  • 23
    Dec 23rd
    0 Files
  • 24
    Dec 24th
    0 Files
  • 25
    Dec 25th
    0 Files
  • 26
    Dec 26th
    0 Files
  • 27
    Dec 27th
    0 Files
  • 28
    Dec 28th
    0 Files
  • 29
    Dec 29th
    0 Files
  • 30
    Dec 30th
    0 Files
  • 31
    Dec 31st
    0 Files

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2022 Packet Storm. All rights reserved.

Hosting By
Rokasec
close