Re: DoS with POSIX file locks?

Trond Myklebust
2006-03-22T20:08:19Z

On Wed, 2006-03-22 at 17:34 +0100, Miklos Szeredi wrote:

> You mean the "local lockowner being stable" is irrelevant.
>
> Yes that is true, but the patch not only makes the local lockowner
> stable, it makes the "owner" stable. And that is the important part
> for NFS, etc.
>
> The remote lockowner has to be derived from the owner, which used to
> be current->files, but is changed to current->file->owner.
>
> The fact that current->file->owner will remain stable across the exec
> will mean that locking will behave consistently for local _and_ remote
> filesystems.
>
> Now I'm not saying I want to keep this weird semantics of always
> inheriting locks on exec. All I'm saying that it's _possible_.

You'd have to ensure that none of the threads involved are able to grab
new posix locks in the period between the unsharing of current->files to
the moment when current->files->owner is swapped.

If not, one thread could in theory open a new file and grab a lock that
can never be unlocked because its lockowner gets stolen away from it by
another execing thread.

Cheers,
Trond