summaryrefslogtreecommitdiff
path: root/fs
diff options
context:
space:
mode:
authorPali Rohár <pali@kernel.org>2024-12-22 17:58:21 +0100
committerSteve French <stfrench@microsoft.com>2025-04-01 04:58:09 -0500
commite97aec7889543663202e24ec51e1e2f9cb236472 (patch)
treee884da962f646c78db28dd1b07c2fc961db2577e /fs
parentb07687edee99b9e53465fbd7f24406616f67070e (diff)
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>
Diffstat (limited to 'fs')
-rw-r--r--fs/smb/client/smb2file.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/fs/smb/client/smb2file.c b/fs/smb/client/smb2file.c
index 5d60410460d2..a7f629238830 100644
--- a/fs/smb/client/smb2file.c
+++ b/fs/smb/client/smb2file.c
@@ -158,7 +158,16 @@ int smb2_open_file(const unsigned int xid, struct cifs_open_parms *oparms, __u32
if (smb2_path == NULL)
return -ENOMEM;
+ /*
+ * GENERIC_READ, GENERIC_EXECUTE, GENERIC_ALL and MAXIMUM_ALLOWED
+ * contains also FILE_READ_ATTRIBUTES access right. So do not append
+ * FILE_READ_ATTRIBUTES when not needed and prevent calling code path
+ * for retry_without_read_attributes.
+ */
if (!(oparms->desired_access & FILE_READ_ATTRIBUTES) &&
+ !(oparms->desired_access & GENERIC_READ) &&
+ !(oparms->desired_access & GENERIC_EXECUTE) &&
+ !(oparms->desired_access & GENERIC_ALL) &&
!(oparms->desired_access & MAXIMUM_ALLOWED)) {
oparms->desired_access |= FILE_READ_ATTRIBUTES;
retry_without_read_attributes = true;