Patch "apparmor: free the allocated pdb objects" has been added to the 6.7-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: free the allocated pdb objects

to the 6.7-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-free-the-allocated-pdb-objects.patch
and it can be found in the queue-6.7 subdirectory.

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



commit 490e25d73305cf29318dc86ed9f6502efaa05ea4
Author: Fedor Pchelkin <pchelkin@xxxxxxxxx>
Date:   Mon Nov 27 20:59:04 2023 +0300

    apparmor: free the allocated pdb objects
    
    [ Upstream commit 1af5aa82c976753e93eb52b72784e586a7d2844b ]
    
    policy_db objects are allocated with kzalloc() inside aa_alloc_pdb() and
    are not cleared in the corresponding aa_free_pdb() function causing leak:
    
    unreferenced object 0xffff88801f0a1400 (size 192):
      comm "apparmor_parser", pid 1247, jiffies 4295122827 (age 2306.399s)
      hex dump (first 32 bytes):
        00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
        00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
      backtrace:
        [<ffffffff81ddc612>] __kmem_cache_alloc_node+0x1e2/0x2d0
        [<ffffffff81c47c55>] kmalloc_trace+0x25/0xc0
        [<ffffffff83eb9a12>] aa_alloc_pdb+0x82/0x140
        [<ffffffff83ec4077>] unpack_pdb+0xc7/0x2700
        [<ffffffff83ec6b10>] unpack_profile+0x450/0x4960
        [<ffffffff83ecc129>] aa_unpack+0x309/0x15e0
        [<ffffffff83ebdb23>] aa_replace_profiles+0x213/0x33c0
        [<ffffffff83e8d341>] policy_update+0x261/0x370
        [<ffffffff83e8d66e>] profile_replace+0x20e/0x2a0
        [<ffffffff81eadfaf>] vfs_write+0x2af/0xe00
        [<ffffffff81eaf4c6>] ksys_write+0x126/0x250
        [<ffffffff890fa0b6>] do_syscall_64+0x46/0xf0
        [<ffffffff892000ea>] entry_SYSCALL_64_after_hwframe+0x6e/0x76
    
    Free the pdbs inside aa_free_pdb(). While at it, rename the variable
    representing an aa_policydb object to make the function more unified with
    aa_pdb_free_kref() and aa_alloc_pdb().
    
    Found by Linux Verification Center (linuxtesting.org).
    
    Fixes: 98b824ff8984 ("apparmor: refcount the pdb")
    Signed-off-by: Fedor Pchelkin <pchelkin@xxxxxxxxx>
    Signed-off-by: John Johansen <john.johansen@xxxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/security/apparmor/policy.c b/security/apparmor/policy.c
index ed4c9803c8fa..957654d253dd 100644
--- a/security/apparmor/policy.c
+++ b/security/apparmor/policy.c
@@ -99,13 +99,14 @@ const char *const aa_profile_mode_names[] = {
 };
 
 
-static void aa_free_pdb(struct aa_policydb *policy)
+static void aa_free_pdb(struct aa_policydb *pdb)
 {
-	if (policy) {
-		aa_put_dfa(policy->dfa);
-		if (policy->perms)
-			kvfree(policy->perms);
-		aa_free_str_table(&policy->trans);
+	if (pdb) {
+		aa_put_dfa(pdb->dfa);
+		if (pdb->perms)
+			kvfree(pdb->perms);
+		aa_free_str_table(&pdb->trans);
+		kfree(pdb);
 	}
 }
 




[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