Skip to content

Commit

Permalink
Smack: Safer check for a socket in file_receive
Browse files Browse the repository at this point in the history
The check of S_ISSOCK() in smack_file_receive() is not
appropriate if the passed descriptor is a socket.

Reported-by: Stephen Smalley <[email protected]>
Signed-off-by: Casey Schaufler <[email protected]>
  • Loading branch information
cschaufler committed Jun 1, 2017
1 parent e661a58 commit 51d59af
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion security/smack/smack_lsm.c
Original file line number Diff line number Diff line change
Expand Up @@ -1915,7 +1915,7 @@ static int smack_file_receive(struct file *file)
smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_PATH);
smk_ad_setfield_u_fs_path(&ad, file->f_path);

if (S_ISSOCK(inode->i_mode)) {
if (inode->i_sb->s_magic == SOCKFS_MAGIC) {
sock = SOCKET_I(inode);
ssp = sock->sk->sk_security;
tsp = current_security();
Expand Down

0 comments on commit 51d59af

Please sign in to comment.