Skip to content

Commit d36a1dd

Browse files
author
Al Viro
committed
dump_common_audit_data(): fix racy accesses to ->d_name
We are not guaranteed the locking environment that would prevent dentry getting renamed right under us. And it's possible for old long name to be freed after rename, leading to UAF here. Cc: [email protected] # v2.6.2+ Signed-off-by: Al Viro <[email protected]>
1 parent a959a97 commit d36a1dd

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

security/lsm_audit.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,9 @@ static void dump_common_audit_data(struct audit_buffer *ab,
275275
struct inode *inode;
276276

277277
audit_log_format(ab, " name=");
278+
spin_lock(&a->u.dentry->d_lock);
278279
audit_log_untrustedstring(ab, a->u.dentry->d_name.name);
280+
spin_unlock(&a->u.dentry->d_lock);
279281

280282
inode = d_backing_inode(a->u.dentry);
281283
if (inode) {
@@ -293,8 +295,9 @@ static void dump_common_audit_data(struct audit_buffer *ab,
293295
dentry = d_find_alias(inode);
294296
if (dentry) {
295297
audit_log_format(ab, " name=");
296-
audit_log_untrustedstring(ab,
297-
dentry->d_name.name);
298+
spin_lock(&dentry->d_lock);
299+
audit_log_untrustedstring(ab, dentry->d_name.name);
300+
spin_unlock(&dentry->d_lock);
298301
dput(dentry);
299302
}
300303
audit_log_format(ab, " dev=");

0 commit comments

Comments
 (0)