Skip to content

Commit a5e74b4

Browse files
committed
smb: client: fix compound alignment with encryption
JIRA: https://issues.redhat.com/browse/RHEL-108683 commit 90f7c10 Author: Paulo Alcantara <pc@manguebit.org> Date: Sat Sep 6 21:19:29 2025 -0300 smb: client: fix compound alignment with encryption The encryption layer can't handle the padding iovs, so flatten the compound request into a single buffer with required padding to prevent the server from dropping the connection when finding unaligned compound requests. Fixes: bc925c1 ("smb: client: improve compound padding in encryption") Signed-off-by: Paulo Alcantara (Red Hat) <pc@manguebit.org> Reviewed-by: David Howells <dhowells@redhat.com> Cc: linux-cifs@vger.kernel.org Cc: stable@vger.kernel.org Signed-off-by: Steve French <stfrench@microsoft.com> Signed-off-by: Paulo Alcantara <paalcant@redhat.com>
1 parent 53b9874 commit a5e74b4

File tree

1 file changed

+25
-3
lines changed

1 file changed

+25
-3
lines changed

fs/smb/client/smb2ops.c

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2631,13 +2631,35 @@ smb2_set_next_command(struct cifs_tcon *tcon, struct smb_rqst *rqst)
26312631
}
26322632

26332633
/* SMB headers in a compound are 8 byte aligned. */
2634-
if (!IS_ALIGNED(len, 8)) {
2635-
num_padding = 8 - (len & 7);
2634+
if (IS_ALIGNED(len, 8))
2635+
goto out;
2636+
2637+
num_padding = 8 - (len & 7);
2638+
if (smb3_encryption_required(tcon)) {
2639+
int i;
2640+
2641+
/*
2642+
* Flatten request into a single buffer with required padding as
2643+
* the encryption layer can't handle the padding iovs.
2644+
*/
2645+
for (i = 1; i < rqst->rq_nvec; i++) {
2646+
memcpy(rqst->rq_iov[0].iov_base +
2647+
rqst->rq_iov[0].iov_len,
2648+
rqst->rq_iov[i].iov_base,
2649+
rqst->rq_iov[i].iov_len);
2650+
rqst->rq_iov[0].iov_len += rqst->rq_iov[i].iov_len;
2651+
}
2652+
memset(rqst->rq_iov[0].iov_base + rqst->rq_iov[0].iov_len,
2653+
0, num_padding);
2654+
rqst->rq_iov[0].iov_len += num_padding;
2655+
rqst->rq_nvec = 1;
2656+
} else {
26362657
rqst->rq_iov[rqst->rq_nvec].iov_base = smb2_padding;
26372658
rqst->rq_iov[rqst->rq_nvec].iov_len = num_padding;
26382659
rqst->rq_nvec++;
2639-
len += num_padding;
26402660
}
2661+
len += num_padding;
2662+
out:
26412663
shdr->NextCommand = cpu_to_le32(len);
26422664
}
26432665

0 commit comments

Comments
 (0)