Skip to content

Commit d7807d8

Browse files
committed
Merge tag 'apparmor-pr-2024-01-03' of git://git.kernel.org/pub/scm/linux/kernel/git/jj/linux-apparmor
Pull apparmor fix from John Johansen: "Detect that the source mount is not in the namespace and if it isn't don't use it as a source path match. This prevent apparmor from applying the attach_disconnected flag to move_mount() source which prevents detached mounts from appearing as / when applying mount mediation, which is not only incorrect but could result in bad policy being generated" * tag 'apparmor-pr-2024-01-03' of git://git.kernel.org/pub/scm/linux/kernel/git/jj/linux-apparmor: apparmor: Fix move_mount mediation by detecting if source is detached
2 parents 94a502e + 8026e40 commit d7807d8

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

security/apparmor/apparmorfs.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2373,6 +2373,7 @@ static struct aa_sfs_entry aa_sfs_entry_policy[] = {
23732373

23742374
static struct aa_sfs_entry aa_sfs_entry_mount[] = {
23752375
AA_SFS_FILE_STRING("mask", "mount umount pivot_root"),
2376+
AA_SFS_FILE_STRING("move_mount", "detached"),
23762377
{ }
23772378
};
23782379

security/apparmor/mount.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,10 @@ int aa_move_mount(const struct cred *subj_cred,
499499
error = -ENOMEM;
500500
if (!to_buffer || !from_buffer)
501501
goto out;
502+
503+
if (!our_mnt(from_path->mnt))
504+
/* moving a mount detached from the namespace */
505+
from_path = NULL;
502506
error = fn_for_each_confined(label, profile,
503507
match_mnt(subj_cred, profile, to_path, to_buffer,
504508
from_path, from_buffer,

0 commit comments

Comments
 (0)