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)
committerJaehoon Chung <jh80.chung@samsung.com>
Tue, 29 Jan 2019 02:25:31 +0000 (11:25 +0900)
commit607ae8001bf2de95268ef767095409381c7bd711
tree82b859d5e974b9b335413d2b5613f44365e1e11c
parent27141030d7ef5b493e5982af45e726afcbd0ca9d
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>
[sw0312.kim: cherry-pick from main to fix SMACK issue realted with socket]
Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Change-Id: I1b55a8829b26259f4e0502f12aa27e423dd1cafe
security/smack/smack_lsm.c