]> git.hungrycats.org Git - linux/commitdiff
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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 21 Oct 2012 16:32:42 +0000 (09:32 -0700)
commit ffd8d101a3a7d3f2e79deee1e342801703b6dc70 upstream.

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>
Cc: Dave Jones <davej@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/namei.c

index dd1ed1b8e98efe048683e81bd1244c483160ad55..81bd5463d908df142426b780eea5af4357fd38fc 100644 (file)
@@ -692,9 +692,9 @@ static inline int may_follow_link(struct path *link, struct nameidata *nd)
        if (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;
 }