FAILED: patch "[PATCH] fcntl: refuse F_SET_RW_HINT on an immutable inode" failed to apply to 6.6-stable tree
Subsystems (3)
[email protected]
maintainerThe patch below does not apply to the 6.6-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.6.y
git checkout FETCH_HEAD
git cherry-pick -x b0d1022b9bdb1e98aa7fb3244fdd50a58c61766c
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026101223-sprinkled-coming-7d84@gregkh' --subject-prefix 'PATCH 6.6.y' 'HEAD^..'
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From b0d1022b9bdb1e98aa7fb3244fdd50a58c61766c Mon Sep 17 00:00:00 2001
From: Christian Brauner <[email protected]>
Date: Fri, 2 Oct 2026 15:52:34 +0200
Subject: [PATCH] fcntl: refuse F_SET_RW_HINT on an immutable inode
An immutable inode is never written to so write hints are pointless. Refuse the hint on an immutable inode the way setattr(), fallocate() and etxattr() refuse their changes.
fs/fcntl.c +3 -0
@@ -372,6 +372,9 @@ static long fcntl_set_rw_hint(struct file *file, unsigned long arg)u64 __user *argp = (u64 __user *)arg;u64 hint; +/* nothing is ever written to it */ +if (IS_IMMUTABLE (inode)) +return -EPERM ;if (!inode_owner_or_capable (file_mnt_idmap (file), inode))return -EPERM ;
Sasha Levin
maintainerPATCH 1/3 fs: Split fcntl_rw_hint()
From: Bart Van Assche <[email protected]>
[ Upstream commit 1505ba06e52e701600172bccbc3aa7fb9bd5d0da ]
Split fcntl_rw_hint() such that there is one helper function per fcntl. Use READ_ONCE() and WRITE_ONCE() to access the i_write_hint member instead of protecting such accesses with the inode lock. READ_ONCE() is not used in I/O path code that reads i_write_hint. Users who want F_SET_RW_HINT to affect I/O need to make sure that F_SET_RW_HINT has completed before I/O is submitted that should use the configured write hint.
Stable-dep-of: b0d1022b9bdb ("fcntl: refuse F_SET_RW_HINT on an immutable inode")
--- fs/fcntl.c | 45 ++++++++++++++++++++++++--------------------- 1 file changed, 24 insertions(+), 21 deletions(-)
fs/fcntl.c +24 -21
@@ -277,32 +277,33 @@ static bool rw_hint_valid(u64 hint) } } -static long fcntl_rw_hint (struct file *file,unsigned int cmd, -unsigned long arg) +static long fcntl_get_rw_hint (struct file *file,unsigned int cmd, +unsigned long arg) {struct inode *inode =file_inode (file);u64 __user *argp = (u64 __user *)arg; -u64 hint; +u64 hint =READ_ONCE (inode->i_write_hint); -switch (cmd) { -case F_GET_RW_HINT : - hint = inode->i_write_hint; -if (copy_to_user (argp, &hint,sizeof (*argp))) -return -EFAULT ; -return 0 ; -case F_SET_RW_HINT : -if (copy_from_user (&hint, argp,sizeof (hint))) -return -EFAULT ; -if (!rw_hint_valid (hint)) -return -EINVAL ; +if (copy_to_user (argp, &hint,sizeof (*argp))) +return -EFAULT ; +return 0 ; +} -inode_lock (inode); - inode->i_write_hint = hint; -inode_unlock (inode); -return 0 ; -default : +static long fcntl_set_rw_hint (struct file *file,unsigned int cmd, +unsigned long arg) +{ +struct inode *inode =file_inode (file); +u64 __user *argp = (u64 __user *)arg; +u64 hint; + +if (copy_from_user (&hint, argp,sizeof (hint))) +return -EFAULT ; +if (!rw_hint_valid (hint))return -EINVAL ; - } + +WRITE_ONCE (inode->i_write_hint, hint); + +return 0 ; } static long do_fcntl(int fd, unsigned int cmd, unsigned long arg,
@@ -408,8 +409,10 @@ static long do_fcntl(int fd, unsigned int cmd, unsigned long arg, err =memfd_fcntl (filp, cmd, argi);break ;case F_GET_RW_HINT : + err =fcntl_get_rw_hint (filp, cmd, arg); +break ;case F_SET_RW_HINT : - err =fcntl_rw_hint (filp, cmd, arg); + err =fcntl_set_rw_hint (filp, cmd, arg);break ;default :break ;
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 2/3 fs: require inode_owner_or_capable for F_SET_RW_HINT
From: Christoph Hellwig <[email protected]>
[ Upstream commit b6512519496e29270bca6b2df9baa3cc2d9d5356 ]
F_SET_RW_HINT controls data placement in the file system and / or device and should not be available to everyone who can read a given file.
Stable-dep-of: b0d1022b9bdb ("fcntl: refuse F_SET_RW_HINT on an immutable inode")
--- fs/fcntl.c | 3 +++ 1 file changed, 3 insertions(+)
fs/fcntl.c +3 -0
@@ -296,6 +296,9 @@ static long fcntl_set_rw_hint(struct file *file, unsigned int cmd,u64 __user *argp = (u64 __user *)arg;u64 hint; +if (!inode_owner_or_capable (file_mnt_idmap (file), inode)) +return -EPERM ; +if (copy_from_user (&hint, argp,sizeof (hint)))return -EFAULT ;if (!rw_hint_valid (hint))
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 3/3 fcntl: refuse F_SET_RW_HINT on an immutable inode
In reply to Sasha LevinFrom: Christian Brauner <[email protected]>
[ Upstream commit b0d1022b9bdb1e98aa7fb3244fdd50a58c61766c ]
An immutable inode is never written to so write hints are pointless. Refuse the hint on an immutable inode the way setattr(), fallocate() and etxattr() refuse their changes.
--- fs/fcntl.c | 3 +++ 1 file changed, 3 insertions(+)
fs/fcntl.c +3 -0
@@ -296,6 +296,9 @@ static long fcntl_set_rw_hint(struct file *file, unsigned int cmd,u64 __user *argp = (u64 __user *)arg;u64 hint; +/* nothing is ever written to it */ +if (IS_IMMUTABLE (inode)) +return -EPERM ;if (!inode_owner_or_capable (file_mnt_idmap (file), inode))return -EPERM ;
Signature · 1 line
2.53.0