fs: prevent use after free in auditing when symlink following was denied
authorSasha Levin <sasha.levin@oracle.com>
Thu, 4 Oct 2012 23:56:40 +0000 (19:56 -0400)
committerAl Viro <viro@zeniv.linux.org.uk>
Wed, 10 Oct 2012 03:33:37 +0000 (23:33 -0400)
Commit "fs: add link restriction audit reporting" has added auditing of failed
attempts to follow symlinks. Unfortunately, the auditing was being done after
the struct path structure was released earlier.

Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
fs/namei.c

index aa30d19e9edd75acf05780cad24eadbf37fba910..6d47fac64292e0155ef925ef78be737f4bf826ab 100644 (file)
@@ -692,9 +692,9 @@ static inline int may_follow_link(struct path *link, struct nameidata *nd)
        if (uid_eq(parent->i_uid, inode->i_uid))
                return 0;
 
+       audit_log_link_denied("follow_link", link);
        path_put_conditional(link, nd);
        path_put(&nd->path);
-       audit_log_link_denied("follow_link", link);
        return -EACCES;
 }