Skip to content

Commit 2ca82bf

Browse files
dhkts1gregkh
authored andcommitted
ksmbd: enforce FILE_READ_ATTRIBUTES on SMB_FIND_FILE_POSIX_INFORMATION
commit 20c8442 upstream. find_file_posix_info() in smb2_query_info() returns file metadata (owner uid, group gid, mode, inode, size, allocation size, hard-link count and all four timestamps) but performs no per-handle access check. Every sibling query handler gates on the handle's granted access first -- get_file_basic_info(), get_file_all_info(), get_file_network_open_info() and get_file_attribute_tag_info() all reject a handle lacking FILE_READ_ATTRIBUTES_LE with -EACCES. The POSIX handler is gated only by the connection-scoped tcon->posix_extensions flag, which is not a per-handle authorization, so a handle opened with only FILE_WRITE_DATA is correctly denied FileBasicInformation yet is allowed the strict-superset POSIX info. Mirror the FILE_READ_ATTRIBUTES_LE gate the sibling info handlers already use. Fixes: e2f3448 ("cifsd: add server-side procedures for SMB3") 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 20ee516 commit 2ca82bf

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

fs/smb/server/smb2pdu.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5339,6 +5339,12 @@ static int find_file_posix_info(struct smb2_query_info_rsp *rsp,
53395339
int out_buf_len = sizeof(struct smb311_posix_qinfo) + 32;
53405340
int ret;
53415341

5342+
if (!(fp->daccess & FILE_READ_ATTRIBUTES_LE)) {
5343+
pr_err("no right to read the attributes : 0x%x\n",
5344+
fp->daccess);
5345+
return -EACCES;
5346+
}
5347+
53425348
ret = vfs_getattr(&fp->filp->f_path, &stat, STATX_BASIC_STATS,
53435349
AT_STATX_SYNC_AS_STAT);
53445350
if (ret)

0 commit comments

Comments
 (0)