smb: client: increase number of PDUs allowed in a compound request
authorPaulo Alcantara <pc@manguebit.com>
Tue, 30 Jan 2024 00:04:44 +0000 (21:04 -0300)
committerSteve French <stfrench@microsoft.com>
Thu, 1 Feb 2024 18:15:51 +0000 (12:15 -0600)
With the introduction of SMB2_OP_QUERY_WSL_EA, the client may now send
5 commands in a single compound request in order to query xattrs from
potential WSL reparse points, which should be fine as we currently
allow up to 5 PDUs in a single compound request.  However, if
encryption is enabled (e.g. 'seal' mount option) or enforced by the
server, current MAX_COMPOUND(5) won't be enough as we require an extra
PDU for the transform header.

Fix this by increasing MAX_COMPOUND to 7 and, while we're at it, add
an WARN_ON_ONCE() and return -EIO instead of -ENOMEM in case we
attempt to send a compound request that couldn't include the extra
transform header.

Signed-off-by: Paulo Alcantara <pc@manguebit.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
fs/smb/client/cifsglob.h
fs/smb/client/transport.c

index 9093c507042fa12ed867bc5297aa5ca8abf50458..c86a72c9d9ecd4268481a4caa29e58004cb7d6b9 100644 (file)
@@ -87,7 +87,7 @@
 #define SMB_INTERFACE_POLL_INTERVAL    600
 
 /* maximum number of PDUs in one compound */
-#define MAX_COMPOUND 5
+#define MAX_COMPOUND 7
 
 /*
  * Default number of credits to keep available for SMB3.
index e00278fcfa4fa65f063430001c5506e3a2906358..994d70193432978de213a19a0f9933bd90e63671 100644 (file)
@@ -435,8 +435,8 @@ smb_send_rqst(struct TCP_Server_Info *server, int num_rqst,
        if (!(flags & CIFS_TRANSFORM_REQ))
                return __smb_send_rqst(server, num_rqst, rqst);
 
-       if (num_rqst > MAX_COMPOUND - 1)
-               return -ENOMEM;
+       if (WARN_ON_ONCE(num_rqst > MAX_COMPOUND - 1))
+               return -EIO;
 
        if (!server->ops->init_transform_rq) {
                cifs_server_dbg(VFS, "Encryption requested but transform callback is missing\n");