2003-07-23 17:02:31

by Andreas Gruenbacher

[permalink] [raw]
Subject: [BUG] 2.4.22-pre7: unshare-files fix breaks file locks

Hello Marcelo,

as already mentioned in private mail, the unshare-files patch in 2.4.22-pre7
breaks POSIX file lock semantics after an execve(2): unshare_files() gives
the process a new task_struct->files struct. Existing POSIX file locks
continue to refer to the old files struct. POSIX requires that the locks
migrate to the exec'ed process. (The LSB checks that.)

The fix is to steal the locks from the old file struct after unshare_files(),
when it is known that the new, unshared files struct will be used.

The fixes introduce changes in behavior for processes that share a common
files struct, a case which can be constructed using clone(2). This use of
clone is pathological. Before the unshare-files fix, the clones would still
share the same files struct. With unshare files, the exec'ed process would
lose the locks. We should ensure that the exec'ed process finally holds the
locks.


Cheers,
Andreas.

------------------------------------------------------------------
Andreas Gruenbacher SuSE Labs, SuSE Linux AG
mailto:[email protected] Deutschherrnstr. 15-19
http://www.suse.de/ D-90429 Nuernberg, Germany


Attachments:
(No filename) (1.16 kB)
file-locking-fix.diff (2.26 kB)
Download all attachments