bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] openat: reduce syscalls in first probe of /proc


From: Eric Blake
Subject: Re: [PATCH] openat: reduce syscalls in first probe of /proc
Date: Mon, 09 May 2011 17:18:13 -0600
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.17) Gecko/20110428 Fedora/3.1.10-1.fc14 Lightning/1.0b3pre Mnenhy/0.8.3 Thunderbird/3.1.10

On 05/09/2011 05:15 PM, Bruno Haible wrote:
> Eric Blake wrote:
>> -      int proc_self_fd = open ("/proc/self/fd", O_SEARCH);
>> +      int proc_self_fd = open ("/proc/self/fd",
>> +                               O_SEARCH | O_DIRECTORY | O_NOCTTY | 
>> O_NONBLOCK);
> 
> What is the point of playing with O_NOCTTY and O_NONBLOCK here?
> It could trigger bugs in dark untested areas of the kernels, so why do it?

For the same reason that all the rest of gnulib uses those same flags
when opening directories (chdir-long.c, chdir-safer.c, fds.c, savewd.c).
 Our replacement <sys/stat.h> defines these to no-ops if they are
dangerous, and where they aren't dangerous, they are actually helpful
for ensuring that we really did get a directory and can't deadlock the
process when someone else maliciously breaks file system conventions to
intentionally place a tty or socket at that name.

-- 
Eric Blake   address@hidden    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]