mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-02 15:46:33 +00:00
Kernel: Don't let locks of the same owner conflict with each other
Documentation on POSIX locks seems sparse, but this is how the Linux kernel implementation handles it.
This commit is contained in:
parent
dc6016cd18
commit
cd189999d1
Notes:
sideshowbarker
2024-07-17 09:35:30 +09:00
Author: https://github.com/timschumi
Commit: cd189999d1
Pull-request: https://github.com/SerenityOS/serenity/pull/13971
Reviewed-by: https://github.com/ADKaster ✅
Reviewed-by: https://github.com/Hendiadyoin1
Reviewed-by: https://github.com/bgianfo ✅
Reviewed-by: https://github.com/kleinesfilmroellchen
Reviewed-by: https://github.com/linusg
1 changed files with 4 additions and 0 deletions
|
@ -348,6 +348,10 @@ ErrorOr<void> Inode::get_flock(OpenFileDescription const& description, Userspace
|
|||
if (!range_overlap(lock.start, lock.len, lookup.l_start, lookup.l_len))
|
||||
continue;
|
||||
|
||||
// Locks with the same owner can't conflict with each other.
|
||||
if (lock.pid == Process::current().pid())
|
||||
continue;
|
||||
|
||||
if ((lookup.l_type == F_RDLCK && lock.type == F_WRLCK) || lookup.l_type == F_WRLCK) {
|
||||
lookup = { lock.type, SEEK_SET, lock.start, lock.len, lock.pid };
|
||||
return copy_to_user(reference_lock, &lookup);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue