Skip to contentSkip to conversation

FAILED: patch "[PATCH] smb: smbdirect: fix buffer length underflow in RDMA transfers" failed to apply to 6.18-stable tree

PATCH [email protected] 2 participants 4 messages Nov 4

Subsystems (3)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

The patch below does not apply to the 6.18-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-6.18.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 '2026110436-thee-asleep-2059@gregkh' --subject-prefix 'PATCH 6.18.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.

Fixes e628bf939aaf ("ksmbd: reduce descriptor size if remaining bytes is less than request size")
fs/smb/smbdirect/rw.c +0 -1
index 6fe38042cfb9..cb142c3c50b2 100644
@@ -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,
#1 lore raw

Am 04.11.26 um 19:29 schrieb [email protected]:

Quoted 57 lines

The patch below does not apply to the 6.18-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-6.18.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 '2026110436-thee-asleep-2059@gregkh' --subject-prefix 'PATCH 6.18.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.

Fixes e628bf939aaf ("ksmbd: reduce descriptor size if remaining bytes is less than request size")
fs/smb/smbdirect/rw.c +0 -0
index 6fe38042cfb9..cb142c3c50b2 100644

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,

In older releases this is smb_direct_rdma_xmit() in fs/smb/server/transport_rdma.c

I hope that helps.

metze

author maintainer
#2 lore raw
Quoted 67 lines · Stefan Metzmacher

Am 04.11.26 um 19:29 schrieb [email protected]:

Quoted 57 lines

The patch below does not apply to the 6.18-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-6.18.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 '2026110436-thee-asleep-2059@gregkh' --subject-prefix 'PATCH 6.18.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.

Fixes e628bf939aaf ("ksmbd: reduce descriptor size if remaining bytes is less than request size")
fs/smb/smbdirect/rw.c +0 -0
index 6fe38042cfb9..cb142c3c50b2 100644

fs/smb/smbdirect/rw.c int smbdirect_connection_rdma_xmit(struct smbdirect_socket *sc, · line 147

Quoted 6 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,

In older releases this is smb_direct_rdma_xmit() in fs/smb/server/transport_rdma.c

Quoted 1 line

I hope that helps.

A backported patch would help best :)

#3 lore raw

Am 04.11.26 um 20:24 schrieb Greg KH:

Quoted 68 lines · Stefan Metzmacher
Quoted 67 lines

Am 04.11.26 um 19:29 schrieb [email protected]:

Quoted 57 lines

The patch below does not apply to the 6.18-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-6.18.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 '2026110436-thee-asleep-2059@gregkh' --subject-prefix 'PATCH 6.18.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.

Fixes e628bf939aaf ("ksmbd: reduce descriptor size if remaining bytes is less than request size")
fs/smb/smbdirect/rw.c +0 -0
index 6fe38042cfb9..cb142c3c50b2 100644

fs/smb/smbdirect/rw.c int smbdirect_connection_rdma_xmit(struct smbdirect_socket *sc, · line 147

Quoted 6 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,

In older releases this is smb_direct_rdma_xmit() in fs/smb/server/transport_rdma.c

Quoted 3 lines
Quoted 1 line

I hope that helps.

A backported patch would help best :)

Try this :-)

From 6f70ba1216ab44440a3afedac20af0fa5749bd80 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

[ 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.

Fixes e628bf939aaf ("ksmbd: reduce descriptor size if remaining bytes is less than request size")

[ metze: in 6.18 the code is smb_direct_rdma_xmit() in
fs/smb/server/transport_rdma.c ]

Assisted-by Claude:claude-opus-5-5
---
 fs/smb/server/transport_rdma.c | 1 -
 1 file changed, 1 deletion(-)
fs/smb/server/transport_rdma.c +0 -1
index 3f9bcd10a0b3..fed0c7db224f 100644
@@ -1724,7 +1724,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(sc, desc_buf, desc_buf_len);
Signature · 1 line
2.43.0