Smack: fix d_instantiate logic for sockfs and pipefs
authorRafal Krypa <r.krypa@samsung.com>
Fri, 9 Dec 2016 13:03:04 +0000 (14:03 +0100)
committerJaechul Lee <jcsing.lee@samsung.com>
Tue, 14 Feb 2017 04:26:27 +0000 (13:26 +0900)
commit6dfda119f2373601c9b9f686b503490e05f057cc
treebd98be5b39be8fda0579415621888f843281c1f7
parenteeebb5a9b46144f04fbfac15741320ecf952872e
Smack: fix d_instantiate logic for sockfs and pipefs

Since 4b936885a (v2.6.32) all inodes on sockfs and pipefs are disconnected.
It caused filesystem specific code in smack_d_instantiate to be skipped,
because all inodes on those pseudo filesystems were treated as root inodes.
As a result all sockfs inodes had the Smack label set to floor.

In most cases access checks for sockets use socket_smack data so the inode
label is not important. But there are special cases that were broken.
One example would be calling fcntl with F_SETOWN command on a socket fd.

Now smack_d_instantiate expects all pipefs and sockfs inodes to be
disconnected and has the logic in appropriate place.

Signed-off-by: Rafal Krypa <r.krypa@samsung.com>
Signed-off-by: Casey Schaufler <casey@schaufler-ca.com>
security/smack/smack_lsm.c