Message ID | 20241122122931.90408-2-hch@lst.de (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | [1/2] fs: require inode_owner_or_capable for F_SET_RW_HINT | expand |
On Fri 22-11-24 13:29:24, Christoph Hellwig wrote: > 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. > > Signed-off-by: Christoph Hellwig <hch@lst.de> Makes sense. Feel free to add: Reviewed-by: Jan Kara <jack@suse.cz> Honza > --- > fs/fcntl.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/fs/fcntl.c b/fs/fcntl.c > index 22dd9dcce7ec..7fc6190da342 100644 > --- a/fs/fcntl.c > +++ b/fs/fcntl.c > @@ -375,6 +375,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)) > -- > 2.45.2 >
diff --git a/fs/fcntl.c b/fs/fcntl.c index 22dd9dcce7ec..7fc6190da342 100644 --- a/fs/fcntl.c +++ b/fs/fcntl.c @@ -375,6 +375,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))
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. Signed-off-by: Christoph Hellwig <hch@lst.de> --- fs/fcntl.c | 3 +++ 1 file changed, 3 insertions(+)