Skip to content

Commit 805b65a

Browse files
rafal-krypacschaufler
authored andcommitted
Smack: fix d_instantiate logic for sockfs and pipefs
Since 4b93688 (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>
1 parent c9d238a commit 805b65a

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

security/smack/smack_lsm.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3486,6 +3486,13 @@ static void smack_d_instantiate(struct dentry *opt_dentry, struct inode *inode)
34863486
case PIPEFS_MAGIC:
34873487
isp->smk_inode = smk_of_current();
34883488
break;
3489+
case SOCKFS_MAGIC:
3490+
/*
3491+
* Socket access is controlled by the socket
3492+
* structures associated with the task involved.
3493+
*/
3494+
isp->smk_inode = &smack_known_star;
3495+
break;
34893496
default:
34903497
isp->smk_inode = sbsp->smk_root;
34913498
break;
@@ -3502,19 +3509,12 @@ static void smack_d_instantiate(struct dentry *opt_dentry, struct inode *inode)
35023509
*/
35033510
switch (sbp->s_magic) {
35043511
case SMACK_MAGIC:
3505-
case PIPEFS_MAGIC:
3506-
case SOCKFS_MAGIC:
35073512
case CGROUP_SUPER_MAGIC:
35083513
/*
35093514
* Casey says that it's a little embarrassing
35103515
* that the smack file system doesn't do
35113516
* extended attributes.
35123517
*
3513-
* Casey says pipes are easy (?)
3514-
*
3515-
* Socket access is controlled by the socket
3516-
* structures associated with the task involved.
3517-
*
35183518
* Cgroupfs is special
35193519
*/
35203520
final = &smack_known_star;

0 commit comments

Comments
 (0)