From 931116a0e776d4b0c2f72d6669ab61997f35775e Mon Sep 17 00:00:00 2001 From: Long Li Date: Mon, 19 Aug 2024 09:19:54 +0800 Subject: [PATCH] filelock: Correct the file lock owner in fcntl_setlk64 hulk inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/IAKLNT CVE: NA -------------------------------- The locks_remove_posix() function is designed to reliably remove locks when an fcntl/close race is detected. However, it was passing in the wrong filelock owner, 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. Fixes: dfbebb5dc268 ("filelock: Fix fcntl/close race recovery compat path") Signed-off-by: Long Li --- fs/locks.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/locks.c b/fs/locks.c index 5549b5a54ffd..d06e4b8e7ee6 100644 --- a/fs/locks.c +++ b/fs/locks.c @@ -2676,7 +2676,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; } } -- Gitee