From: sashiko-bot@kernel.org
To: "Runyu Xiao" <runyu.xiao@seu.edu.cn>
Cc: linux-scsi@vger.kernel.org
Subject: Re: [PATCH v3] scsi: target: file: avoid recursive configfs open in fd_init_prot()
Date: Tue, 18 Aug 2026 09:27:11 +0000 [thread overview]
Message-ID: <20260818092711.87B8D1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260818091326.1582200-1-runyu.xiao@seu.edu.cn>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Reopening an existing PI sidecar file using `dentry_open()` bypasses `may_open()` and `inode_permission()` checks.
--
--- Patch [1]: [PATCH v3] scsi: target: file: avoid recursive configfs open in fd_init_prot() ---
commit 12b71238378c9751f15927b9f16e21baaa769408
Author: Runyu Xiao <runyu.xiao@seu.edu.cn>
scsi: target: file: avoid recursive configfs open in fd_init_prot()
This patch fixes a recursive configfs open hazard by avoiding the reopening
of a user-controlled pathname. Instead, it derives the protection sidecar
file from the opened backing file itself and opens it directly.
Link: https://lore.kernel.org/r/20260818073539.1555605-1-runyu.xiao@seu.edu.cn
> diff --git a/drivers/target/target_core_file.c b/drivers/target/target_core_file.c
> index 62ced9f5102ff..f6c34e69dbfed 100644
> --- a/drivers/target/target_core_file.c
> +++ b/drivers/target/target_core_file.c
[ ... ]
> @@ -86,6 +90,131 @@ static struct se_device *fd_alloc_device(struct se_hba *hba, const char *name)
[ ... ]
> +static int fd_open_prot_file(struct file *file, int flags, umode_t mode,
> + struct file **filep)
> +{
[ ... ]
> + if (d_is_negative(prot_path.dentry)) {
> + prot_file = dentry_create(&prot_path, flags, mode, current_cred());
> + } else {
> + if (!d_is_reg(prot_path.dentry)) {
> + ret = -EINVAL;
> + goto out_dput;
> + }
> +
> + inode_unlock(d_inode(parent_path.dentry));
> + mnt_drop_write_file(file);
> + release_dentry_name_snapshot(&backing_name);
> + kfree(prot_name);
> +
> + prot_file = dentry_open(&prot_path, flags & ~O_CREAT,
> + current_cred());
[Severity: High]
Does this dentry_open() call bypass standard permission checks?
When reopening an existing sidecar file, this goes straight to dentry_open()
without calling inode_permission() or may_open(). This appears to skip
access controls, including standard permissions, security hooks, and checks
for immutable or append-only file attributes.
If someone with configuration access sets up a backend and links an
immutable file (or one they lack write access to) at the sidecar path,
could they use this to overwrite the file since the permission gates
are bypassed?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260818091326.1582200-1-runyu.xiao@seu.edu.cn?part=1
next prev parent reply other threads:[~2026-08-18 9:27 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-18 4:58 [PATCH] scsi: target: file: reject configfs-backed paths in configfs stores Runyu Xiao
2026-08-18 5:12 ` sashiko-bot
2026-08-18 7:35 ` [PATCH v2] scsi: target: file: avoid recursive configfs open in fd_init_prot() Runyu Xiao
2026-08-18 7:50 ` sashiko-bot
2026-08-18 9:13 ` [PATCH v3] " Runyu Xiao
2026-08-18 9:27 ` sashiko-bot [this message]
2026-08-18 10:16 ` [PATCH v4] " Runyu Xiao
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=20260818092711.87B8D1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=runyu.xiao@seu.edu.cn \
--cc=sashiko-reviews@lists.linux.dev \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.