From: sashiko-bot@kernel.org
Cc: linux-security-module@vger.kernel.org
Subject: Re: [PATCH v2] smack: mediate file attribute syscalls
Date: Mon, 30 Nov 2026 08:00:33 +0000 [thread overview]
Message-ID: <sashiko-outbox-240637@kernel.org> (raw)
In-Reply-To: <20261130074845.2537541-1-shawnq1@163.com>
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] smack: missing IS_PRIVATE() check in
smack_inode_file_getattr() and setattr
- [Low] smack: conversational reply and revision notes in commit message
--
commit def34cb2a8662edb62c35fd5980f1b8b6195ff82
Author: Shawn Shao <shawnq1@163.com>
> smack: mediate file attribute syscalls
>
> Hello,
>
> Thanks for the review. I added kernel-doc comments to both new hook
> functions, including their parameters and return value.
>
> Smack lacks the inode_file_getattr and inode_file_setattr hooks. As a
> result, file_getattr() and file_setattr() could bypass Smack's existing
> read and write checks. The patch implements both hooks with the same access
> checks as the existing getattr and setattr hooks.
>
> The reproducer runs as uid 1000 without capabilities and changes its Smack
> label to Subject. A stat() on /mnt/secret is denied, but file_getattr() on
> the same file succeeds. Subject can read the Control label but cannot write
> it. Yet file_setattr() clears flags on /mnt/control. Ordinary
> open() checks continue to be enforced. With the patch, denied calls return
> -EACCES, while permitted operations on /mnt/public still succeed.
>
> Tested source: v7.3-23903-g7cd8495c0f162
> compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0
>
> The CONFIG_SECURITY_SMACK-enabled smack_lsm.o build completed with
> KCFLAGS=-Wframe-larger-than=1280. The kernel-doc check for both callbacks
> completed without warnings. The behavioral reproducer and console output
> are unchanged from v1:
> https://gist.github.com/shaos26/fbf8b7f663ee82593d7d41623aa2e2c4
>
> Fixes: defdd02d783c ("lsm: introduce new hooks for setting/getting inode fsxattr")
> Signed-off-by: Shawn Shao <shawnq1@163.com>
[Severity: Low]
This isn't a bug, but the conversational reply ("Hello, Thanks for the
review..."), v1 comparison notes, local build environment details, and
external gist URL should be moved below the "---" tearline so they do not
become part of the permanent git commit log.
> diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
> index 8e88ac65fd7fc..da0aab6812b99 100644
> --- a/security/smack/smack_lsm.c
> +++ b/security/smack/smack_lsm.c
> @@ -1308,6 +1308,48 @@ static int smack_inode_getattr(const struct path *path)
> return rc;
> }
>
> +/**
> + * smack_inode_file_getattr - Smack check for retrieving file attributes
> + * @dentry: file to retrieve filesystem attributes from
> + * @fa: attributes to get
> + *
> + * Returns 0 if access is permitted, an error code otherwise.
> + */
> +static int smack_inode_file_getattr(struct dentry *dentry,
> + struct file_kattr *fa)
> +{
> + struct smk_audit_info ad;
> + struct inode *inode = d_backing_inode(dentry);
> + int rc;
> +
> + smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_DENTRY);
> + smk_ad_setfield_u_fs_path_dentry(&ad, dentry);
> + rc = smk_curacc(smk_of_inode(inode), MAY_READ, &ad);
> + rc = smk_bu_inode(inode, MAY_READ, rc);
> + return rc;
> +}
> +
> +/**
> + * smack_inode_file_setattr - Smack check for setting file attributes
> + * @dentry: file to set filesystem attributes on
> + * @fa: attributes to set
> + *
> + * Returns 0 if access is permitted, an error code otherwise.
> + */
> +static int smack_inode_file_setattr(struct dentry *dentry,
> + struct file_kattr *fa)
> +{
> + struct smk_audit_info ad;
> + struct inode *inode = d_backing_inode(dentry);
> + int rc;
> +
> + smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_DENTRY);
> + smk_ad_setfield_u_fs_path_dentry(&ad, dentry);
> + rc = smk_curacc(smk_of_inode(inode), MAY_WRITE, &ad);
> + rc = smk_bu_inode(inode, MAY_WRITE, rc);
> + return rc;
> +}
[Severity: Medium]
Should smack_inode_file_getattr() and smack_inode_file_setattr() return 0
when IS_PRIVATE(inode) is true?
Unlike security_inode_getattr() and security_inode_setattr(),
security_inode_file_getattr() and security_inode_file_setattr() do not
filter out S_PRIVATE inodes before invoking the LSM hooks:
security/security.c:security_inode_file_setattr() {
return call_int_hook(inode_file_setattr, dentry, fa);
}
Other Smack hooks whose LSM wrappers do not check IS_PRIVATE(), such as
smack_file_ioctl() and smack_file_receive(), explicitly check
IS_PRIVATE(inode). Without that check here, vfs_fileattr_get() and
vfs_fileattr_set() (for example via FS_IOC_GETFLAGS or file_getattr()) on
an S_PRIVATE tmpfs inode received over SCM_RIGHTS or retained across a
Smack label change will fail with -EACCES when the caller's label lacks
access to the allocator's label.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261130074845.2537541-1-shawnq1@163.com?part=1
prev parent reply other threads:[~2026-11-30 8:00 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-28 8:28 [PATCH] smack: mediate file attribute syscalls shaos
2026-11-28 8:46 ` sashiko-bot
2026-11-28 17:37 ` Casey Schaufler
2026-11-30 7:48 ` [PATCH v2] " Shawn Shao
2026-11-30 8:00 ` sashiko-bot [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=sashiko-outbox-240637@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-security-module@vger.kernel.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox