[RFC] Add pthread_detach_pwd call.

Florian Weimer fweimer@redhat.com
Mon Oct 21 12:54:00 GMT 2013


On 10/21/2013 02:42 PM, Joseph S. Myers wrote:
> On Mon, 21 Oct 2013, Florian Weimer wrote:
>
>>> Feel free to propose/implement new *at functions for glibc.  That doesn't
>>> depend on kernel support (although kernel support would be good) because
>>> you can implement them in userspace using /proc/self/fd, just like many
>>> existing fallback implementations for !__ASSUME_ATFCTS.
>>
>> Interesting.  Is constructing such names
>>
>>        static const char procfd[] = "/proc/self/fd/%d/%s";
>>
>> race-free?  I'm asking because the /proc/self/fd entries are presented as
>> symbolic links.
>
> I don't see why this technique would involve any races different from a
> direct syscall.  In both cases, if another thread changes the file
> descriptor at the same time as the call, you can't predict whether the old
> or new version would be used.

I was wondering if the kernel performs symlink resolution behind the 
scenes, or if it uses the file descriptor directly.  But based on a 
quick experiment, it should be race-free.  This looks rather nice.

-- 
Florian Weimer / Red Hat Product Security Team



More information about the Libc-alpha mailing list