aboutsummaryrefslogtreecommitdiffstats
diff options
-rw-r--r--security/apparmor/file.c12
-rw-r--r--security/apparmor/lsm.c4
2 files changed, 10 insertions, 6 deletions
diff --git a/security/apparmor/file.c b/security/apparmor/file.c
index b69fece45ade5..c751f2774c59f 100644
--- a/security/apparmor/file.c
+++ b/security/apparmor/file.c
@@ -155,8 +155,12 @@ static int path_name(const char *op, const struct cred *subj_cred,
const char *info = NULL;
int error;
- error = aa_path_name(path, flags, buffer, name, &info,
- labels_profile(label)->disconnected);
+ /* don't reaudit files closed during inheritance */
+ if (unlikely(path->dentry == aa_null.dentry))
+ error = -EACCES;
+ else
+ error = aa_path_name(path, flags, buffer, name, &info,
+ labels_profile(label)->disconnected);
if (error) {
fn_for_each_confined(label, profile,
aa_audit_file(subj_cred,
@@ -617,6 +621,10 @@ int aa_file_perm(const char *op, const struct cred *subj_cred,
AA_BUG(!label);
AA_BUG(!file);
+ /* don't reaudit files closed during inheritance */
+ if (unlikely(file->f_path.dentry == aa_null.dentry))
+ return -EACCES;
+
fctx = file_ctx(file);
rcu_read_lock();
diff --git a/security/apparmor/lsm.c b/security/apparmor/lsm.c
index f47d60d8c40a2..8d5d9a966b719 100644
--- a/security/apparmor/lsm.c
+++ b/security/apparmor/lsm.c
@@ -525,10 +525,6 @@ static int common_file_perm(const char *op, struct file *file, u32 mask)
struct aa_label *label;
int error = 0;
- /* don't reaudit files closed during inheritance */
- if (unlikely(file->f_path.dentry == aa_null.dentry))
- return -EACCES;
-
label = begin_current_label_crit_section();
error = aa_file_perm(op, current_cred(), label, file, mask, false);
end_current_label_crit_section(label);