mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Hungyu Lin <dennylin0707@gmail.com>
To: jaegeuk@kernel.org, chao@kernel.org
Cc: daehojeong@google.com, linux-f2fs-devel@lists.sourceforge.net,
	linux-kernel@vger.kernel.org, dennylin0707@gmail.com
Subject: [PATCH v2 4/4] f2fs: require write permission for F2FS_IOC_IO_PRIO
Date: Thu, 12 Nov 2026 21:43:03 +0000	[thread overview]
Message-ID: <20261112214303.16198-5-dennylin0707@gmail.com> (raw)
In-Reply-To: <20261112214303.16198-1-dennylin0707@gmail.com>

F2FS_IOC_IO_PRIO does not check who the caller is, so any user who can
open a file, even read-only, can set its write I/O priority hint.

Require write permission on the inode.

Fixes: 5f95c1812a65 ("f2fs: add ioctl to get IO priority hint")
Suggested-by: Chao Yu <chao@kernel.org>
Cc: stable@vger.kernel.org
Signed-off-by: Hungyu Lin <dennylin0707@gmail.com>
---
 fs/f2fs/file.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index 9d09ce597f72..e25c7166c367 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -3985,6 +3985,9 @@ static int f2fs_ioc_io_prio(struct file *filp, unsigned long arg)
 	if (!S_ISREG(inode->i_mode) || level >= F2FS_IOPRIO_MAX)
 		return -EINVAL;
 
+	if (inode_permission(file_mnt_idmap(filp), inode, MAY_WRITE))
+		return -EACCES;
+
 	inode_lock(inode);
 	F2FS_I(inode)->ioprio_hint = level;
 	inode_unlock(inode);
-- 
2.43.0


      parent reply	other threads:[~2026-11-12 21:43 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-12 21:42 [PATCH v2 0/4] f2fs: require write permission for ioctls that change per-file state Hungyu Lin
2026-11-12 21:43 ` [PATCH v2 1/4] f2fs: require write permission for F2FS_IOC_SET_PIN_FILE Hungyu Lin
2026-11-12 21:43 ` [PATCH v2 2/4] f2fs: require write permission for F2FS_IOC_RELEASE_COMPRESS_BLOCKS Hungyu Lin
2026-11-12 21:43 ` [PATCH v2 3/4] f2fs: require write permission for F2FS_IOC_RESERVE_COMPRESS_BLOCKS Hungyu Lin
2026-11-12 21:43 ` Hungyu Lin [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261112214303.16198-5-dennylin0707@gmail.com \
    --to=dennylin0707@gmail.com \
    --cc=chao@kernel.org \
    --cc=daehojeong@google.com \
    --cc=jaegeuk@kernel.org \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®