Subject: Re: bug#30918: Don't use syscall() to call renameat2()

From: Paul Eggert <[email-masked]>
Date: Sun, 25 Mar 2018 18:20:56 -0700

Seebs wrote:
> I have significant concerns about the feasibility of a generic wrapper
> for syscall(). In particular, a "wrapper" which does *nothing* but
> forward arguments may well be practical. Or one which just fails
> immediately and claims ENOTSUPP -- but this creates the risk that we'll
> break things which were using perfectly valid syscalls which work fine
> and which we don't need to intercept or do anything with.

For this particular issue, failing with ENOTSUPP should do. Perhaps such a 
behavior could be available as a link-time or runtime option.

More precise would be to have syscall to do nothing but forward arguments, 
*except* for the renameat2 syscall which would work much like the renameat 
wrapper that I assume you already have. This would work for coreutils, shouldn't 
break anything else, shouldn't require a link-time or runtime option, and 
shouldn't be that much harder than always forwarding syscall arguments.

> I'm assuming the race condition refers to the behavior of
> RENAME_EXCHANGE.

No, it's RENAME_NOREPLACE. Coreutils doesn't use RENAME_EXCHANGE now (though it 
might in the future, I suppose).