This is a note to let you know that I've just added the patch titled filelock: fix potential use-after-free in posix_lock_inode to the 6.6-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: filelock-fix-potential-use-after-free-in-posix_lock_.patch and it can be found in the queue-6.6 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. commit afd9345f7a91d344c2107150d0e3471ab7c90a14 Author: Jeff Layton <jlayton@xxxxxxxxxx> Date: Tue Jul 2 18:44:48 2024 -0400 filelock: fix potential use-after-free in posix_lock_inode [ Upstream commit 1b3ec4f7c03d4b07bad70697d7e2f4088d2cfe92 ] Light Hsieh reported a KASAN UAF warning in trace_posix_lock_inode(). The request pointer had been changed earlier to point to a lock entry that was added to the inode's list. However, before the tracepoint could fire, another task raced in and freed that lock. Fix this by moving the tracepoint inside the spinlock, which should ensure that this doesn't happen. Fixes: 74f6f5912693 ("locks: fix KASAN: use-after-free in trace_event_raw_event_filelock_lock") Link: https://lore.kernel.org/linux-fsdevel/724ffb0a2962e912ea62bb0515deadf39c325112.camel@xxxxxxxxxx/ Reported-by: Light Hsieh (謝明燈) <Light.Hsieh@xxxxxxxxxxxx> Signed-off-by: Jeff Layton <jlayton@xxxxxxxxxx> Link: https://lore.kernel.org/r/20240702-filelock-6-10-v1-1-96e766aadc98@xxxxxxxxxx Reviewed-by: Alexander Aring <aahringo@xxxxxxxxxx> Signed-off-by: Christian Brauner <brauner@xxxxxxxxxx> Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx> diff --git a/fs/locks.c b/fs/locks.c index 76ad05f8070ad..fb717dae90297 100644 --- a/fs/locks.c +++ b/fs/locks.c @@ -1314,9 +1314,9 @@ static int posix_lock_inode(struct inode *inode, struct file_lock *request, locks_wake_up_blocks(left); } out: + trace_posix_lock_inode(inode, request, error); spin_unlock(&ctx->flc_lock); percpu_up_read(&file_rwsem); - trace_posix_lock_inode(inode, request, error); /* * Free any unused locks. */