lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <2E51520E-EC73-457F-809A-4749ED9A3C97@mac.com>
Date:	Sat, 9 Jun 2007 15:27:43 -0400
From:	Kyle Moffett <mrmacman_g4@....com>
To:	Al Viro <viro@....linux.org.uk>
Cc:	Ulrich Drepper <drepper@...hat.com>,
	Linus Torvalds <torvalds@...ux-foundation.org>,
	Davide Libenzi <davidel@...ilserver.org>,
	Alan Cox <alan@...rguk.ukuu.org.uk>,
	Theodore Tso <tytso@....edu>,
	Eric Dumazet <dada1@...mosbay.com>,
	Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
	Andrew Morton <akpm@...ux-foundation.org>,
	Ingo Molnar <mingo@...e.hu>
Subject: Re: [patch 7/8] fdmap v2 - implement sys_socket2

On Jun 09, 2007, at 13:24:29, Al Viro wrote:
> On Sat, Jun 09, 2007 at 10:08:59AM -0700, Ulrich Drepper wrote:
>> - - there are two interface to use: open + fcntl.  This is racy.   
>> And don't tell me this doesn't matter.
> Racy with respect to what?  Return-to-libc exploits from another  
> thread?

How about racy with respect to normal open or fork+exec from another  
thread?  Specifically there are cases where libc or other libraries  
want to create a backend thread dealing with file descriptors in  
response to the program's straightforward calls into that library  
(Examples include using syslets or event-based polling threads).


SCENARIO 1:

Program Thread:   Library Thread:
                   fd = socket(AF_*, SOCK_*, 0);
fork();
                   int x = FD_CLOEXEC;
                   fcntl(fd, F_SETFD, &x);

New Process:
setgroups(...);
seteuid(...);
exec(....);

Whoops!!! Suddenly the user process executed by the (theoretically)  
single-threaded program got a handle to a netlink socket affecting  
some system resource!!!


SCENARIO 2:

Program Thread:     Async libc getpwent()-cache syslet
close(0);
                     fd = open("/etc/shadow");
open("/dev/null");
code_which_insecurely_reads_from_stdin();

Here we were trying to safely call into code which reads from stdin  
and shouldn't be given privileged data, but the syslet makes the  
common paradigm 'close(0); open("/dev/null");' horribly insecure.

If you extend all the FD syscalls to all take a "flags" parameter and  
add the appropriate flags, then you can pass O_CLOEXEC|O_RANDFD to  
whatever syscall you are using and both problems vanish.

Cheers,
Kyle Moffett

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ