]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
fs: drop assert in file_seek_cur_needs_f_lock
authorLuis Henriques <luis@igalia.com>
Fri, 13 Jun 2025 10:11:11 +0000 (11:11 +0100)
committerChristian Brauner <brauner@kernel.org>
Mon, 16 Jun 2025 07:59:24 +0000 (09:59 +0200)
The assert in function file_seek_cur_needs_f_lock() can be triggered very
easily because there are many users of vfs_llseek() (such as overlayfs)
that do their custom locking around llseek instead of relying on
fdget_pos(). Just drop the overzealous assertion.

Fixes: da06e3c51794 ("fs: don't needlessly acquire f_lock")
Suggested-by: Jan Kara <jack@suse.cz>
Suggested-by: Mateusz Guzik <mjguzik@gmail.com>
Signed-off-by: Luis Henriques <luis@igalia.com>
Link: https://lore.kernel.org/20250613101111.17716-1-luis@igalia.com
Signed-off-by: Christian Brauner <brauner@kernel.org>
fs/file.c

index 3a3146664cf37115624e12f7f06826d48827e9d7..b6db031545e65093f60f276de7146215a40178e3 100644 (file)
--- a/fs/file.c
+++ b/fs/file.c
@@ -1198,8 +1198,12 @@ bool file_seek_cur_needs_f_lock(struct file *file)
        if (!(file->f_mode & FMODE_ATOMIC_POS) && !file->f_op->iterate_shared)
                return false;
 
-       VFS_WARN_ON_ONCE((file_count(file) > 1) &&
-                        !mutex_is_locked(&file->f_pos_lock));
+       /*
+        * Note that we are not guaranteed to be called after fdget_pos() on
+        * this file obj, in which case the caller is expected to provide the
+        * appropriate locking.
+        */
+
        return true;
 }