Patch "apparmor: Fix move_mount mediation by detecting if source is detached" has been added to the 6.6-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    apparmor: Fix move_mount mediation by detecting if source is detached

to the 6.6-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     apparmor-fix-move_mount-mediation-by-detecting-if-so.patch
and it can be found in the queue-6.6 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 56bf9ad98514889ec9638d6dfe57310f53bd29ec
Author: John Johansen <john.johansen@xxxxxxxxxxxxx>
Date:   Mon Dec 18 01:10:03 2023 -0800

    apparmor: Fix move_mount mediation by detecting if source is detached
    
    [ Upstream commit 8026e40608b4d552216d2a818ca7080a4264bb44 ]
    
    Prevent move_mount from applying the attach_disconnected flag
    to move_mount(). This prevents detached mounts from appearing
    as / when applying mount mediation, which is not only incorrect
    but could result in bad policy being generated.
    
    Basic mount rules like
      allow mount,
      allow mount options=(move) -> /target/,
    
    will allow detached mounts, allowing older policy to continue
    to function. New policy gains the ability to specify `detached` as
    a source option
      allow mount detached -> /target/,
    
    In addition make sure support of move_mount is advertised as
    a feature to userspace so that applications that generate policy
    can respond to the addition.
    
    Note: this fixes mediation of move_mount when a detached mount is used,
          it does not fix the broader regression of apparmor mediation of
          mounts under the new mount api.
    
    Link: https://lore.kernel.org/all/68c166b8-5b4d-4612-8042-1dee3334385b@xxxxxxxxxxxxx/T/#mb35fdde37f999f08f0b02d58dc1bf4e6b65b8da2
    Fixes: 157a3537d6bc ("apparmor: Fix regression in mount mediation")
    Reviewed-by: Georgia Garcia <georgia.garcia@xxxxxxxxxxxxx>
    Signed-off-by: John Johansen <john.johansen@xxxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/security/apparmor/apparmorfs.c b/security/apparmor/apparmorfs.c
index 261cef4c622fb..63ddefb6ddd1c 100644
--- a/security/apparmor/apparmorfs.c
+++ b/security/apparmor/apparmorfs.c
@@ -2364,6 +2364,7 @@ static struct aa_sfs_entry aa_sfs_entry_policy[] = {
 
 static struct aa_sfs_entry aa_sfs_entry_mount[] = {
 	AA_SFS_FILE_STRING("mask", "mount umount pivot_root"),
+	AA_SFS_FILE_STRING("move_mount", "detached"),
 	{ }
 };
 
diff --git a/security/apparmor/mount.c b/security/apparmor/mount.c
index f2a114e540079..cb0fdbdb82d94 100644
--- a/security/apparmor/mount.c
+++ b/security/apparmor/mount.c
@@ -499,6 +499,10 @@ int aa_move_mount(const struct cred *subj_cred,
 	error = -ENOMEM;
 	if (!to_buffer || !from_buffer)
 		goto out;
+
+	if (!our_mnt(from_path->mnt))
+		/* moving a mount detached from the namespace */
+		from_path = NULL;
 	error = fn_for_each_confined(label, profile,
 			match_mnt(subj_cred, profile, to_path, to_buffer,
 				  from_path, from_buffer,




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux