From 74577147bc2aff1dd4f12663975a0776b75a1d33 Mon Sep 17 00:00:00 2001 From: Nathan Date: Tue, 8 Apr 2025 20:27:49 -0500 Subject: [PATCH] Fixed building with backported AppArmor --- include/linux/mm.h | 2 ++ mm/util.c | 9 +++++++++ security/apparmor/path.c | 2 +- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index 79a997dd..f7e29c76 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -327,6 +327,8 @@ static inline int is_vmalloc_or_module_addr(const void *x) } #endif +extern void kvfree(const void *addr); + static inline void compound_lock(struct page *page) { #ifdef CONFIG_TRANSPARENT_HUGEPAGE diff --git a/mm/util.c b/mm/util.c index 6f5a57b4..b541ae7a 100644 --- a/mm/util.c +++ b/mm/util.c @@ -479,6 +479,15 @@ unsigned long vm_mmap(struct file *file, unsigned long addr, } EXPORT_SYMBOL(vm_mmap); +void kvfree(const void *addr) +{ + if (is_vmalloc_addr(addr)) + vfree(addr); + else + kfree(addr); +} +EXPORT_SYMBOL(kvfree); + struct address_space *page_mapping(struct page *page) { struct address_space *mapping = page->mapping; diff --git a/security/apparmor/path.c b/security/apparmor/path.c index 6cea2a6a..bcdf7bb7 100644 --- a/security/apparmor/path.c +++ b/security/apparmor/path.c @@ -158,7 +158,7 @@ static int d_namespace_path(struct path *path, char *buf, char **name, * security_path hooks as a deleted dentry except without an inode * allocated. */ - if (d_unlinked(path->dentry) && d_is_positive(path->dentry) && + if (d_unlinked(path->dentry) && path->dentry->d_inode && !(flags & PATH_MEDIATE_DELETED)) { error = -ENOENT; goto out;