Linux kernel -stable discussions
 help / color / mirror / Atom feed
* FAILED: patch "[PATCH] smb: smbdirect: fix buffer length underflow in RDMA transfers" failed to apply to 6.18-stable tree
@ 2026-11-04 18:29 gregkh
  2026-11-04 19:12 ` Stefan Metzmacher
  0 siblings, 1 reply; 4+ messages in thread
From: gregkh @ 2026-11-04 18:29 UTC (permalink / raw)
  To: metze, linkinjeon; +Cc: stable


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 <stable@vger.kernel.org>.

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 '<stable@vger.kernel.org>' --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 <metze@samba.org>
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")
Cc: stable@vger.kernel.org
Reported-by: zdi-disclosures@trendmicro.com # ZDI-CAN-33549
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>

diff --git a/fs/smb/smbdirect/rw.c b/fs/smb/smbdirect/rw.c
index 6fe38042cfb9..cb142c3c50b2 100644
--- a/fs/smb/smbdirect/rw.c
+++ b/fs/smb/smbdirect/rw.c
@@ -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,


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: FAILED: patch "[PATCH] smb: smbdirect: fix buffer length underflow in RDMA transfers" failed to apply to 6.18-stable tree
  2026-11-04 18:29 FAILED: patch "[PATCH] smb: smbdirect: fix buffer length underflow in RDMA transfers" failed to apply to 6.18-stable tree gregkh
@ 2026-11-04 19:12 ` Stefan Metzmacher
  2026-11-04 19:24   ` Greg KH
  0 siblings, 1 reply; 4+ messages in thread
From: Stefan Metzmacher @ 2026-11-04 19:12 UTC (permalink / raw)
  To: gregkh, linkinjeon; +Cc: stable

Am 04.11.26 um 19:29 schrieb gregkh@linuxfoundation.org:
> 
> 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 <stable@vger.kernel.org>.
> 
> 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 '<stable@vger.kernel.org>' --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 <metze@samba.org>
> 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")
> Cc: stable@vger.kernel.org
> Reported-by: zdi-disclosures@trendmicro.com # ZDI-CAN-33549
> Signed-off-by: Stefan Metzmacher <metze@samba.org>
> Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
> 
> diff --git a/fs/smb/smbdirect/rw.c b/fs/smb/smbdirect/rw.c
> index 6fe38042cfb9..cb142c3c50b2 100644
> --- a/fs/smb/smbdirect/rw.c
> +++ b/fs/smb/smbdirect/rw.c
> @@ -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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: FAILED: patch "[PATCH] smb: smbdirect: fix buffer length underflow in RDMA transfers" failed to apply to 6.18-stable tree
  2026-11-04 19:12 ` Stefan Metzmacher
@ 2026-11-04 19:24   ` Greg KH
  2026-11-04 20:25     ` Stefan Metzmacher
  0 siblings, 1 reply; 4+ messages in thread
From: Greg KH @ 2026-11-04 19:24 UTC (permalink / raw)
  To: Stefan Metzmacher; +Cc: linkinjeon, stable

On Wed, Nov 04, 2026 at 08:12:22PM +0100, Stefan Metzmacher wrote:
> Am 04.11.26 um 19:29 schrieb gregkh@linuxfoundation.org:
> > 
> > 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 <stable@vger.kernel.org>.
> > 
> > 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 '<stable@vger.kernel.org>' --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 <metze@samba.org>
> > 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")
> > Cc: stable@vger.kernel.org
> > Reported-by: zdi-disclosures@trendmicro.com # ZDI-CAN-33549
> > Signed-off-by: Stefan Metzmacher <metze@samba.org>
> > Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
> > 
> > diff --git a/fs/smb/smbdirect/rw.c b/fs/smb/smbdirect/rw.c
> > index 6fe38042cfb9..cb142c3c50b2 100644
> > --- a/fs/smb/smbdirect/rw.c
> > +++ b/fs/smb/smbdirect/rw.c
> > @@ -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.

A backported patch would help best :)

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: FAILED: patch "[PATCH] smb: smbdirect: fix buffer length underflow in RDMA transfers" failed to apply to 6.18-stable tree
  2026-11-04 19:24   ` Greg KH
@ 2026-11-04 20:25     ` Stefan Metzmacher
  0 siblings, 0 replies; 4+ messages in thread
From: Stefan Metzmacher @ 2026-11-04 20:25 UTC (permalink / raw)
  To: Greg KH; +Cc: linkinjeon, stable

[-- Attachment #1: Type: text/plain, Size: 3191 bytes --]

Am 04.11.26 um 20:24 schrieb Greg KH:
> On Wed, Nov 04, 2026 at 08:12:22PM +0100, Stefan Metzmacher wrote:
>> Am 04.11.26 um 19:29 schrieb gregkh@linuxfoundation.org:
>>>
>>> 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 <stable@vger.kernel.org>.
>>>
>>> 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 '<stable@vger.kernel.org>' --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 <metze@samba.org>
>>> 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")
>>> Cc: stable@vger.kernel.org
>>> Reported-by: zdi-disclosures@trendmicro.com # ZDI-CAN-33549
>>> Signed-off-by: Stefan Metzmacher <metze@samba.org>
>>> Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
>>>
>>> diff --git a/fs/smb/smbdirect/rw.c b/fs/smb/smbdirect/rw.c
>>> index 6fe38042cfb9..cb142c3c50b2 100644
>>> --- a/fs/smb/smbdirect/rw.c
>>> +++ b/fs/smb/smbdirect/rw.c
>>> @@ -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.
> 
> A backported patch would help best :)

Try this :-)

[-- Attachment #2: backport-6.18-smbdirect-rdma-xmit-underflow.txt --]
[-- Type: text/plain, Size: 2127 bytes --]

From 6f70ba1216ab44440a3afedac20af0fa5749bd80 Mon Sep 17 00:00:00 2001
From: Stefan Metzmacher <metze@samba.org>
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")
Cc: stable@vger.kernel.org
Reported-by: zdi-disclosures@trendmicro.com # ZDI-CAN-33549
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
[ 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(-)

diff --git a/fs/smb/server/transport_rdma.c b/fs/smb/server/transport_rdma.c
index 3f9bcd10a0b3..fed0c7db224f 100644
--- a/fs/smb/server/transport_rdma.c
+++ b/fs/smb/server/transport_rdma.c
@@ -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);
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-11-04 20:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-04 18:29 FAILED: patch "[PATCH] smb: smbdirect: fix buffer length underflow in RDMA transfers" failed to apply to 6.18-stable tree gregkh
2026-11-04 19:12 ` Stefan Metzmacher
2026-11-04 19:24   ` Greg KH
2026-11-04 20:25     ` Stefan Metzmacher

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox