Skip to content

Commit 1d0cffa

Browse files
committed
cifs: do not allow creating sockets except with SMB1 posix exensions
RHBZ: 1453123 Since at least the 3.10 kernel and likely a lot earlier we have not been able to create unix domain sockets in a cifs share when mounted using the SFU mount option (except when mounted with the cifs unix extensions to Samba e.g.) Trying to create a socket, for example using the af_unix command from xfstests will cause : BUG: unable to handle kernel NULL pointer dereference at 00000000 00000040 Since no one uses or depends on being able to create unix domains sockets on a cifs share the easiest fix to stop this vulnerability is to simply not allow creation of any other special files than char or block devices when sfu is used. Added update to Ronnie's patch to handle a tcon link leak, and to address a buf leak noticed by Gustavo and Colin. Acked-by: Gustavo A. R. Silva <gustavo@embeddedor.com> CC: Colin Ian King <colin.king@canonical.com> Reviewed-by: Pavel Shilovsky <pshilov@microsoft.com> Reported-by: Eryu Guan <eguan@redhat.com> Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com> Signed-off-by: Steve French <smfrench@gmail.com> Cc: stable@vger.kernel.org
1 parent ff30b89 commit 1d0cffa

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

fs/cifs/dir.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -684,6 +684,9 @@ int cifs_mknod(struct inode *inode, struct dentry *direntry, umode_t mode,
684684
goto mknod_out;
685685
}
686686

687+
if (!S_ISCHR(mode) && !S_ISBLK(mode))
688+
goto mknod_out;
689+
687690
if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL))
688691
goto mknod_out;
689692

@@ -692,10 +695,8 @@ int cifs_mknod(struct inode *inode, struct dentry *direntry, umode_t mode,
692695

693696
buf = kmalloc(sizeof(FILE_ALL_INFO), GFP_KERNEL);
694697
if (buf == NULL) {
695-
kfree(full_path);
696698
rc = -ENOMEM;
697-
free_xid(xid);
698-
return rc;
699+
goto mknod_out;
699700
}
700701

701702
if (backup_cred(cifs_sb))
@@ -742,7 +743,7 @@ int cifs_mknod(struct inode *inode, struct dentry *direntry, umode_t mode,
742743
pdev->minor = cpu_to_le64(MINOR(device_number));
743744
rc = tcon->ses->server->ops->sync_write(xid, &fid, &io_parms,
744745
&bytes_written, iov, 1);
745-
} /* else if (S_ISFIFO) */
746+
}
746747
tcon->ses->server->ops->close(xid, tcon, &fid);
747748
d_drop(direntry);
748749

0 commit comments

Comments
 (0)