]> git.ipfire.org Git - people/arne_f/kernel.git/commit
commoncap: move assignment of fs_ns to avoid null pointer dereference
authorColin Ian King <colin.king@canonical.com>
Mon, 4 Sep 2017 17:50:05 +0000 (18:50 +0100)
committerJames Morris <james.l.morris@oracle.com>
Thu, 19 Oct 2017 02:09:33 +0000 (13:09 +1100)
commit76ba89c76f2c74e208d93a9e7c698e39eeb3b85c
tree94ee1504a73ca7d7c7545f3282210d5c2091068e
parent494b9ae7abb84e6d88d7587906aff29dd26cf9d0
commoncap: move assignment of fs_ns to avoid null pointer dereference

The pointer fs_ns is assigned from inode->i_ib->s_user_ns before
a null pointer check on inode, hence if inode is actually null we
will get a null pointer dereference on this assignment. Fix this
by only dereferencing inode after the null pointer check on
inode.

Detected by CoverityScan CID#1455328 ("Dereference before null check")

Fixes: 8db6c34f1dbc ("Introduce v3 namespaced file capabilities")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Cc: stable@vger.kernel.org
Acked-by: Serge Hallyn <serge@hallyn.com>
Signed-off-by: James Morris <james.l.morris@oracle.com>
security/commoncap.c