FAILED: patch "[PATCH] smb: smbdirect: fix buffer length underflow in RDMA transfers" failed to apply to 5.15-stable tree
[email protected]
maintainerThe patch below does not apply to the 5.15-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.15.y
git checkout FETCH_HEAD
git cherry-pick -x 7193241a49c958782ba4b8df06da3734d1e317d2
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026110439-qualify-confiding-f593@gregkh' --subject-prefix 'PATCH 5.15.y' 'HEAD^..'
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 7193241a49c958782ba4b8df06da3734d1e317d2 Mon Sep 17 00:00:00 2001
From: Stefan Metzmacher <[email protected]>
Date: Fri, 23 Oct 2026 19:26:09 +0900
Subject: [PATCH] smb: smbdirect: fix buffer length underflow in RDMA transfers
When a remote buffer descriptor is larger than the remaining local buffer, smbdirect_connection_rdma_xmit() clamps its length and sets buf_len to zero. The common accounting code then subtracts the clamped length from buf_len, causing it to underflow. If another descriptor follows, the loop processes it with a wrapped remaining length and includes memory beyond the local buffer in the RDMA transfer.
A client can trigger an out-of-bounds kernel write with an SMB WRITE request, or an out-of-bounds kernel read with an SMB READ request, by supplying multiple RDMA buffer descriptors with an oversized descriptor before the last one.
Remove the premature assignment to buf_len. Subtracting the clamped length already consumes the remaining buffer, so the next iteration stops and only descriptors within the local buffer are used to build work requests.
fs/smb/smbdirect/rw.c +0 -1
@@ -143,7 +143,6 @@ int smbdirect_connection_rdma_xmit(struct smbdirect_socket *sc,if (desc_buf_len > buf_len) { desc_buf_len = buf_len; desc[i].length =cpu_to_le32 (desc_buf_len); - buf_len =0 ; } credits_needed += smbdirect_connection_calc_rw_credits(sc,
Stefan Metzmacher
reviewerAm 04.11.26 um 19:29 schrieb [email protected]:
Quoted 57 lines
The patch below does not apply to the 5.15-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.15.y
git checkoutFETCH_HEAD
git cherry-pick -x7193241a49c958782ba4b8df06da3734d1e317d2
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026110439-qualify-confiding-f593@gregkh' --subject-prefix 'PATCH 5.15.y' 'HEAD^..'Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From
7193241a49c958782ba4b8df06da3734d1e317d2Mon Sep 17 00:00:00 2001
From: Stefan Metzmacher <[email protected]>
Date: Fri, 23 Oct 2026 19:26:09 +0900
Subject: [PATCH] smb: smbdirect: fix buffer length underflow in RDMA transfersWhen a remote buffer descriptor is larger than the remaining local buffer,
smbdirect_connection_rdma_xmit()clamps its length and setsbuf_lento zero. The common accounting code then subtracts the clamped length frombuf_len, causing it to underflow. If another descriptor follows, the loop processes it with a wrapped remaining length and includes memory beyond the local buffer in the RDMA transfer.A client can trigger an out-of-bounds kernel write with an SMB WRITE request, or an out-of-bounds kernel read with an SMB READ request, by supplying multiple RDMA buffer descriptors with an oversized descriptor before the last one.
Remove the premature assignment to
buf_len. Subtracting the clamped length already consumes the remaining buffer, so the next iteration stops and only descriptors within the local buffer are used to build work requests.Fixes e628bf939aaf ("ksmbd: reduce descriptor size if remaining bytes is less than request size")Reported-by [email protected] # ZDI-CAN-33549Signed-off-by Stefan Metzmacher <[email protected]>Signed-off-by Namjae Jeon <[email protected]>fs/smb/smbdirect/rw.c +0
-0
fs/smb/smbdirect/rw.c int smbdirect_connection_rdma_xmit(struct smbdirect_socket *sc, · line 148
Quoted 7 lines
fs/smb/smbdirect/rw.c +0
-1@@ -143,7 +143,6 @@ int smbdirect_connection_rdma_xmit(struct smbdirect_socket *sc,if (desc_buf_len > buf_len) { desc_buf_len = buf_len; desc[i].length =cpu_to_le32 (desc_buf_len); - buf_len =0 ; } credits_needed += smbdirect_connection_calc_rw_credits(sc,
From f7ea2b682fbfd53a107078bd009a0ee6818b2dc1 Mon Sep 17 00:00:00 2001
From: Stefan Metzmacher <[email protected]>
Date: Fri, 23 Oct 2026 19:26:09 +0900
Subject: [PATCH 5.15.y] smb: smbdirect: fix buffer length underflow in RDMA
transfers
[ Upstream commit 7193241a49c958782ba4b8df06da3734d1e317d2 ]
When a remote buffer descriptor is larger than the remaining local buffer, smbdirect_connection_rdma_xmit() clamps its length and sets buf_len to zero. The common accounting code then subtracts the clamped length from buf_len, causing it to underflow. If another descriptor follows, the loop processes it with a wrapped remaining length and includes memory beyond the local buffer in the RDMA transfer.
A client can trigger an out-of-bounds kernel write with an SMB WRITE request, or an out-of-bounds kernel read with an SMB READ request, by supplying multiple RDMA buffer descriptors with an oversized descriptor before the last one.
Remove the premature assignment to buf_len. Subtracting the clamped length already consumes the remaining buffer, so the next iteration stops and only descriptors within the local buffer are used to build work requests.
[ metze: in 5.15 the code is smb_direct_rdma_xmit() in
fs/ksmbd/transport_rdma.c ]
--- fs/ksmbd/transport_rdma.c | 1 - 1 file changed, 1 deletion(-)
fs/ksmbd/transport_rdma.c +0 -1
@@ -1361,7 +1361,6 @@ static int smb_direct_rdma_xmit(struct smb_direct_transport *t,if (desc_buf_len > buf_len) { desc_buf_len = buf_len; desc[i].length =cpu_to_le32 (desc_buf_len); - buf_len =0 ; } credits_needed +=calc_rw_credits (t, desc_buf, desc_buf_len);
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 1/1 smb: smbdirect: fix buffer length underflow in RDMA transfers
In reply to [email protected]From: Stefan Metzmacher <[email protected]>
[ Upstream commit 7193241a49c958782ba4b8df06da3734d1e317d2 ]
When a remote buffer descriptor is larger than the remaining local buffer, smbdirect_connection_rdma_xmit() clamps its length and sets buf_len to zero. The common accounting code then subtracts the clamped length from buf_len, causing it to underflow. If another descriptor follows, the loop processes it with a wrapped remaining length and includes memory beyond the local buffer in the RDMA transfer.
A client can trigger an out-of-bounds kernel write with an SMB WRITE request, or an out-of-bounds kernel read with an SMB READ request, by supplying multiple RDMA buffer descriptors with an oversized descriptor before the last one.
Remove the premature assignment to buf_len. Subtracting the clamped length already consumes the remaining buffer, so the next iteration stops and only descriptors within the local buffer are used to build work requests.
--- fs/ksmbd/transport_rdma.c | 1 - 1 file changed, 1 deletion(-)
fs/ksmbd/transport_rdma.c +0 -1
@@ -1361,7 +1361,6 @@ static int smb_direct_rdma_xmit(struct smb_direct_transport *t,if (desc_buf_len > buf_len) { desc_buf_len = buf_len; desc[i].length =cpu_to_le32 (desc_buf_len); - buf_len =0 ; } credits_needed +=calc_rw_credits (t, desc_buf, desc_buf_len);
Signature · 1 line
2.53.0
Quoted 1 line
smb: smbdirect: fix buffer length underflow in RDMA transfers
Queued your backport for 5.15, thanks.
Signature · 2 lines
Thanks, Sasha