Skip to content

Commit c89f97a

Browse files
committed
smb: client: fix compound alignment with encryption
JIRA: https://issues.redhat.com/browse/RHEL-114295 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 f2f6317 commit c89f97a

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
@@ -2596,13 +2596,35 @@ smb2_set_next_command(struct cifs_tcon *tcon, struct smb_rqst *rqst)
25962596
}
25972597

25982598
/* SMB headers in a compound are 8 byte aligned. */
2599-
if (!IS_ALIGNED(len, 8)) {
2600-
num_padding = 8 - (len & 7);
2599+
if (IS_ALIGNED(len, 8))
2600+
goto out;
2601+
2602+
num_padding = 8 - (len & 7);
2603+
if (smb3_encryption_required(tcon)) {
2604+
int i;
2605+
2606+
/*
2607+
* Flatten request into a single buffer with required padding as
2608+
* the encryption layer can't handle the padding iovs.
2609+
*/
2610+
for (i = 1; i < rqst->rq_nvec; i++) {
2611+
memcpy(rqst->rq_iov[0].iov_base +
2612+
rqst->rq_iov[0].iov_len,
2613+
rqst->rq_iov[i].iov_base,
2614+
rqst->rq_iov[i].iov_len);
2615+
rqst->rq_iov[0].iov_len += rqst->rq_iov[i].iov_len;
2616+
}
2617+
memset(rqst->rq_iov[0].iov_base + rqst->rq_iov[0].iov_len,
2618+
0, num_padding);
2619+
rqst->rq_iov[0].iov_len += num_padding;
2620+
rqst->rq_nvec = 1;
2621+
} else {
26012622
rqst->rq_iov[rqst->rq_nvec].iov_base = smb2_padding;
26022623
rqst->rq_iov[rqst->rq_nvec].iov_len = num_padding;
26032624
rqst->rq_nvec++;
2604-
len += num_padding;
26052625
}
2626+
len += num_padding;
2627+
out:
26062628
shdr->NextCommand = cpu_to_le32(len);
26072629
}
26082630

0 commit comments

Comments
 (0)