Skip to content

Commit df501c0

Browse files
dhkts1gregkh
authored andcommitted
ksmbd: add per-handle permission check to FILE_LINK_INFORMATION
commit 13f3942 upstream. The FILE_LINK_INFORMATION arm of smb2_set_info_file() calls smb2_create_link() with no per-handle fp->daccess check. On the ReplaceIfExists path smb2_create_link() unlinks an existing file at the target name (ksmbd_vfs_remove_file) and creates a hardlink (ksmbd_vfs_link); neither helper checks daccess. A handle opened with FILE_READ_DATA only (no FILE_DELETE, no FILE_WRITE_DATA) can therefore delete an arbitrary file in the share and plant a hardlink over its name. The sibling delete/move arms in the same switch already gate: FILE_RENAME_INFORMATION and FILE_DISPOSITION_INFORMATION both require FILE_DELETE_LE; FILE_FULL_EA_INFORMATION requires FILE_WRITE_EA_LE. Gate the link arm the same way as its closest analogue (rename), since it mutates the namespace and, on replace, deletes an existing entry. This is a sibling of commit cc57232 ("ksmbd: fix FSCTL permission bypass by adding a permission check for FSCTL_SET_SPARSE"). Cc: stable@vger.kernel.org Signed-off-by: Gil Portnoy <dddhkts1@gmail.com> Acked-by: Namjae Jeon <linkinjeon@kernel.org> Signed-off-by: Steve French <stfrench@microsoft.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 2ca82bf commit df501c0

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

fs/smb/server/smb2pdu.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6572,6 +6572,11 @@ static int smb2_set_info_file(struct ksmbd_work *work, struct ksmbd_file *fp,
65726572
}
65736573
case FILE_LINK_INFORMATION:
65746574
{
6575+
if (!(fp->daccess & FILE_DELETE_LE)) {
6576+
pr_err("no right to delete : 0x%x\n", fp->daccess);
6577+
return -EACCES;
6578+
}
6579+
65756580
if (buf_len < sizeof(struct smb2_file_link_info))
65766581
return -EINVAL;
65776582

0 commit comments

Comments
 (0)