From: sashiko-bot@kernel.org
Cc: selinux@vger.kernel.org
Subject: Re: [PATCH v6 3/8] apparmor: Convert from sb_mount to granular mount hooks
Date: Tue, 07 Jul 2026 00:05:00 +0000 [thread overview]
Message-ID: <20260707000500.C34F51F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260706235053.4104951-4-song@kernel.org>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Critical] The patch completely disables AppArmor mount mediation by replacing active LSM hooks (`sb_mount` and `move_mount`) with new granular hooks (`mount_bind`, `mount_new`, `mount_remount`, `mount_move`, etc.) that are never invoked by the VFS.
- [High] The new granular mount hooks fail to strip `AA_MS_IGNORE_MASK` internal kernel flags before policy matching, causing legitimate mounts to be denied if the hooks were active.
--
--- Patch [3]: [PATCH v6 3/8] apparmor: Convert from sb_mount to granular mount hooks ---
commit 6ef64d51cf68e28f54ba97e3ee56be6a9183f162
Author: Song Liu <song@kernel.org>
apparmor: Convert from sb_mount to granular mount hooks
Replace AppArmor's monolithic apparmor_sb_mount() with granular mount hooks.
Key changes include updating bind, new, remount, reconfigure, move, and
change_type mount handling.
> diff --git a/security/apparmor/lsm.c b/security/apparmor/lsm.c
> index 4415bca5889cf..cfd7f0f757734 100644
> --- a/security/apparmor/lsm.c
> +++ b/security/apparmor/lsm.c
> @@ -698,41 +699,91 @@ static int apparmor_uring_sqpoll(void)
> }
> #endif /* CONFIG_IO_URING */
>
> -static int apparmor_sb_mount(const char *dev_name, const struct path *path,
> - const char *type, unsigned long flags, void *data)
> -{
> - struct aa_label *label;
> - int error = 0;
> - bool needput;
> -
> - flags &= ~AA_MS_IGNORE_MASK;
[ ... ]
> +static int apparmor_mount_new(struct fs_context *fc, const struct path *mp,
> + int mnt_flags, unsigned long flags, void *data)
> +{
> + struct aa_label *label;
> + int error = 0;
> + bool needput;
> +
> + /* flags and data are from the original mount(2) call */
> + label = __begin_current_label_crit_section(&needput);
> + if (!unconfined(label))
> + error = aa_new_mount(current_cred(), label, fc->source,
> + mp, fc->fs_type->name, flags, data);
[Severity: High]
Does this pass raw flags to aa_new_mount() without stripping internal kernel
flags?
The old apparmor_sb_mount() explicitly performed:
flags &= ~AA_MS_IGNORE_MASK;
Could passing raw flags cause legitimate mounts to be denied if internal bits
fail policy evaluation?
> + __end_current_label_crit_section(label, needput);
> +
> + return error;
> +}
> +
> +static int apparmor_mount_remount(struct fs_context *fc, const struct path *mp,
> + int mnt_flags, unsigned long flags,
> + void *data)
> +{
> + struct aa_label *label;
> + int error = 0;
> + bool needput;
> +
> + /* flags and data are from the original mount(2) call */
> + label = __begin_current_label_crit_section(&needput);
> + if (!unconfined(label))
> + error = aa_remount(current_cred(), label, mp, flags, data);
[Severity: High]
Similarly, should AA_MS_IGNORE_MASK be stripped from flags here before
passing them to aa_remount()?
> + __end_current_label_crit_section(label, needput);
> +
> + return error;
> +}
[ ... ]
> @@ -1655,8 +1706,12 @@ static struct security_hook_list apparmor_hooks[] __ro_after_init = {
> LSM_HOOK_INIT(capget, apparmor_capget),
> LSM_HOOK_INIT(capable, apparmor_capable),
>
> - LSM_HOOK_INIT(move_mount, apparmor_move_mount),
> - LSM_HOOK_INIT(sb_mount, apparmor_sb_mount),
> + LSM_HOOK_INIT(mount_bind, apparmor_mount_bind),
> + LSM_HOOK_INIT(mount_new, apparmor_mount_new),
> + LSM_HOOK_INIT(mount_remount, apparmor_mount_remount),
> + LSM_HOOK_INIT(mount_reconfigure, apparmor_mount_reconfigure),
> + LSM_HOOK_INIT(mount_move, apparmor_move_mount),
> + LSM_HOOK_INIT(mount_change_type, apparmor_mount_change_type),
> LSM_HOOK_INIT(sb_umount, apparmor_sb_umount),
> LSM_HOOK_INIT(sb_pivotroot, apparmor_sb_pivotroot),
[Severity: Critical]
Are these new hooks being invoked by the VFS?
This patch removes the active sb_mount and move_mount hooks, replacing them
with granular hooks like mount_new and mount_bind. However, the VFS doesn't
appear to have been updated to call these new security hooks (e.g.,
security_mount_new() is never called in fs/namespace.c).
Could this completely disable AppArmor mount mediation, allowing userspace
to perform arbitrary mount operations regardless of the AppArmor profile?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260706235053.4104951-1-song@kernel.org?part=3
next prev parent reply other threads:[~2026-07-07 0:05 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-06 23:50 [PATCH v6 0/8] lsm: Replace security_sb_mount with granular mount hooks Song Liu
2026-07-06 23:50 ` [PATCH v6 1/8] lsm: Add " Song Liu
2026-07-07 0:00 ` sashiko-bot
2026-07-06 23:50 ` [PATCH v6 2/8] apparmor: Remove redundant MS_MGC_MSK stripping in apparmor_sb_mount Song Liu
2026-07-07 0:04 ` sashiko-bot
2026-07-06 23:50 ` [PATCH v6 3/8] apparmor: Convert from sb_mount to granular mount hooks Song Liu
2026-07-07 0:05 ` sashiko-bot [this message]
2026-07-06 23:50 ` [PATCH v6 4/8] selinux: " Song Liu
2026-07-07 0:01 ` sashiko-bot
2026-07-06 23:50 ` [PATCH v6 5/8] landlock: " Song Liu
2026-07-07 0:04 ` sashiko-bot
2026-07-06 23:50 ` [PATCH v6 6/8] tomoyo: " Song Liu
2026-07-07 0:04 ` sashiko-bot
2026-07-06 23:50 ` [PATCH v6 7/8] vfs: Replace security_sb_mount/security_move_mount with granular hooks Song Liu
2026-07-07 0:06 ` sashiko-bot
2026-07-06 23:50 ` [PATCH v6 8/8] lsm: Remove security_sb_mount and security_move_mount Song Liu
2026-07-07 2:08 ` sashiko-bot
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=20260707000500.C34F51F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=selinux@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 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.