Skip to content

Commit e97aec7

Browse files
paliSteve French
authored andcommitted
cifs: Do not add FILE_READ_ATTRIBUTES when using GENERIC_READ/EXECUTE/ALL
Individual bits GENERIC_READ, GENERIC_EXECUTE and GENERIC_ALL have meaning which includes also access right for FILE_READ_ATTRIBUTES. So specifying FILE_READ_ATTRIBUTES bit together with one of those GENERIC (except GENERIC_WRITE) does not do anything. This change prevents calling additional (fallback) code and sending more requests without FILE_READ_ATTRIBUTES when the primary request fails on -EACCES, as it is not needed at all. Signed-off-by: Pali Rohár <pali@kernel.org> Signed-off-by: Steve French <stfrench@microsoft.com>
1 parent b07687e commit e97aec7

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

fs/smb/client/smb2file.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,16 @@ int smb2_open_file(const unsigned int xid, struct cifs_open_parms *oparms, __u32
158158
if (smb2_path == NULL)
159159
return -ENOMEM;
160160

161+
/*
162+
* GENERIC_READ, GENERIC_EXECUTE, GENERIC_ALL and MAXIMUM_ALLOWED
163+
* contains also FILE_READ_ATTRIBUTES access right. So do not append
164+
* FILE_READ_ATTRIBUTES when not needed and prevent calling code path
165+
* for retry_without_read_attributes.
166+
*/
161167
if (!(oparms->desired_access & FILE_READ_ATTRIBUTES) &&
168+
!(oparms->desired_access & GENERIC_READ) &&
169+
!(oparms->desired_access & GENERIC_EXECUTE) &&
170+
!(oparms->desired_access & GENERIC_ALL) &&
162171
!(oparms->desired_access & MAXIMUM_ALLOWED)) {
163172
oparms->desired_access |= FILE_READ_ATTRIBUTES;
164173
retry_without_read_attributes = true;

0 commit comments

Comments
 (0)