filelock: Correct the filelock owner in fcntl_setlk/fcntl_setlk64
BugLink: https://bugs.launchpad.net/bugs/2080595 The locks_remove_posix() function in fcntl_setlk/fcntl_setlk64 is designed to reliably remove locks when an fcntl/close race is detected. However, it was passing in the wrong filelock owner, it looks like a mistake and resulting in a failure to remove locks. More critically, if the lock removal fails, it could lead to a uaf issue while traversing the locks. This problem occurs only in the 4.19/5.4 stable version. Fixes: 4c43ad4ab416 ("filelock: Fix fcntl/close race recovery compat path") Fixes: dc2ce1dfceaa ("filelock: Remove locks reliably when fcntl/close race is detected") Cc: stable@vger.kernel.org Signed-off-by: Long Li <leo.lilong@huawei.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Koichiro Den <koichiro.den@canonical.com> Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
This commit is contained in:
parent
72268f593c
commit
ee9bc21135
fs
|
@ -2542,7 +2542,7 @@ int fcntl_setlk(unsigned int fd, struct file *filp, unsigned int cmd,
|
|||
f = fcheck(fd);
|
||||
spin_unlock(¤t->files->file_lock);
|
||||
if (f != filp) {
|
||||
locks_remove_posix(filp, ¤t->files);
|
||||
locks_remove_posix(filp, current->files);
|
||||
error = -EBADF;
|
||||
}
|
||||
}
|
||||
|
@ -2672,7 +2672,7 @@ int fcntl_setlk64(unsigned int fd, struct file *filp, unsigned int cmd,
|
|||
f = fcheck(fd);
|
||||
spin_unlock(¤t->files->file_lock);
|
||||
if (f != filp) {
|
||||
locks_remove_posix(filp, ¤t->files);
|
||||
locks_remove_posix(filp, current->files);
|
||||
error = -EBADF;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue