* [PATCH net] dibs: loopback: validate offset and size in move_data()
@ 2026-07-07 7:43 Dust Li
2026-07-07 14:31 ` Dust Li
2026-07-09 11:10 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 5+ messages in thread
From: Dust Li @ 2026-07-07 7:43 UTC (permalink / raw)
To: Alexandra Winter
Cc: Wenjia Zhang, Wen Gu, Paolo Abeni, Mahanta Jambigi, D . Wythe,
Sidraya Jayagond, netdev, linux-kernel, stable,
Federico Kirschbaum
The loopback move_data() performs a memcpy into the registered DMB
without checking whether offset + size exceeds the DMB length. Unlike
real ISM hardware, which enforces memory region bounds natively, the
software loopback has no such protection.
A peer-supplied out-of-bounds offset or oversized write would result in
an OOB write past the allocated kernel buffer. Add an explicit bounds
check before the memcpy to reject such requests with -EINVAL.
Fixes: f7a22071dbf3("net/smc: implement DMB-related operations of loopback-ism")
Cc: stable@vger.kernel.org
Reported-by: Federico Kirschbaum <federico.kirschbaum@xbow.com>
Signed-off-by: Dust Li <dust.li@linux.alibaba.com>
---
drivers/dibs/dibs_loopback.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/dibs/dibs_loopback.c b/drivers/dibs/dibs_loopback.c
index ec3b48cb0e87..0f2e09311152 100644
--- a/drivers/dibs/dibs_loopback.c
+++ b/drivers/dibs/dibs_loopback.c
@@ -254,6 +254,11 @@ static int dibs_lo_move_data(struct dibs_dev *dibs, u64 dmb_tok,
read_unlock_bh(&ldev->dmb_ht_lock);
return -EINVAL;
}
+ if ((u64)offset + size > rmb_node->len) {
+ read_unlock_bh(&ldev->dmb_ht_lock);
+ return -EINVAL;
+ }
+
memcpy((char *)rmb_node->cpu_addr + offset, data, size);
sba_idx = rmb_node->sba_idx;
read_unlock_bh(&ldev->dmb_ht_lock);
--
2.43.7
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH net] dibs: loopback: validate offset and size in move_data()
2026-07-07 7:43 [PATCH net] dibs: loopback: validate offset and size in move_data() Dust Li
@ 2026-07-07 14:31 ` Dust Li
2026-07-07 18:31 ` Andrew Lunn
2026-07-09 11:10 ` patchwork-bot+netdevbpf
1 sibling, 1 reply; 5+ messages in thread
From: Dust Li @ 2026-07-07 14:31 UTC (permalink / raw)
To: Alexandra Winter
Cc: Wenjia Zhang, Wen Gu, Paolo Abeni, Mahanta Jambigi, D . Wythe,
Sidraya Jayagond, netdev, linux-kernel, stable,
Federico Kirschbaum
On 2026-07-07 15:43:18, Dust Li wrote:
>The loopback move_data() performs a memcpy into the registered DMB
>without checking whether offset + size exceeds the DMB length. Unlike
>real ISM hardware, which enforces memory region bounds natively, the
>software loopback has no such protection.
>
>A peer-supplied out-of-bounds offset or oversized write would result in
>an OOB write past the allocated kernel buffer. Add an explicit bounds
>check before the memcpy to reject such requests with -EINVAL.
>
>Fixes: f7a22071dbf3("net/smc: implement DMB-related operations of loopback-ism")
>Cc: stable@vger.kernel.org
>Reported-by: Federico Kirschbaum <federico.kirschbaum@xbow.com>
Reported-by: Baul Lee <baul.lee@xbow.com>
Best regards,
Dust
>Signed-off-by: Dust Li <dust.li@linux.alibaba.com>
>---
> drivers/dibs/dibs_loopback.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
>diff --git a/drivers/dibs/dibs_loopback.c b/drivers/dibs/dibs_loopback.c
>index ec3b48cb0e87..0f2e09311152 100644
>--- a/drivers/dibs/dibs_loopback.c
>+++ b/drivers/dibs/dibs_loopback.c
>@@ -254,6 +254,11 @@ static int dibs_lo_move_data(struct dibs_dev *dibs, u64 dmb_tok,
> read_unlock_bh(&ldev->dmb_ht_lock);
> return -EINVAL;
> }
>+ if ((u64)offset + size > rmb_node->len) {
>+ read_unlock_bh(&ldev->dmb_ht_lock);
>+ return -EINVAL;
>+ }
>+
> memcpy((char *)rmb_node->cpu_addr + offset, data, size);
> sba_idx = rmb_node->sba_idx;
> read_unlock_bh(&ldev->dmb_ht_lock);
>--
>2.43.7
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH net] dibs: loopback: validate offset and size in move_data()
2026-07-07 14:31 ` Dust Li
@ 2026-07-07 18:31 ` Andrew Lunn
2026-07-09 10:46 ` Paolo Abeni
0 siblings, 1 reply; 5+ messages in thread
From: Andrew Lunn @ 2026-07-07 18:31 UTC (permalink / raw)
To: Dust Li
Cc: Alexandra Winter, Wenjia Zhang, Wen Gu, Paolo Abeni,
Mahanta Jambigi, D . Wythe, Sidraya Jayagond, netdev,
linux-kernel, stable, Federico Kirschbaum
On Tue, Jul 07, 2026 at 10:31:00PM +0800, Dust Li wrote:
> On 2026-07-07 15:43:18, Dust Li wrote:
> >The loopback move_data() performs a memcpy into the registered DMB
> >without checking whether offset + size exceeds the DMB length. Unlike
> >real ISM hardware, which enforces memory region bounds natively, the
> >software loopback has no such protection.
> >
> >A peer-supplied out-of-bounds offset or oversized write would result in
> >an OOB write past the allocated kernel buffer. Add an explicit bounds
> >check before the memcpy to reject such requests with -EINVAL.
> >
> >Fixes: f7a22071dbf3("net/smc: implement DMB-related operations of loopback-ism")
> >Cc: stable@vger.kernel.org
> >Reported-by: Federico Kirschbaum <federico.kirschbaum@xbow.com>
>
> Reported-by: Baul Lee <baul.lee@xbow.com>
Could you provide a link to the report?
Thanks
Andrew
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH net] dibs: loopback: validate offset and size in move_data()
2026-07-07 18:31 ` Andrew Lunn
@ 2026-07-09 10:46 ` Paolo Abeni
0 siblings, 0 replies; 5+ messages in thread
From: Paolo Abeni @ 2026-07-09 10:46 UTC (permalink / raw)
To: Andrew Lunn, Dust Li
Cc: Alexandra Winter, Wenjia Zhang, Wen Gu, Mahanta Jambigi,
D . Wythe, Sidraya Jayagond, netdev, linux-kernel, stable,
Federico Kirschbaum
On 7/7/26 8:31 PM, Andrew Lunn wrote:
> On Tue, Jul 07, 2026 at 10:31:00PM +0800, Dust Li wrote:
>> On 2026-07-07 15:43:18, Dust Li wrote:
>>> The loopback move_data() performs a memcpy into the registered DMB
>>> without checking whether offset + size exceeds the DMB length. Unlike
>>> real ISM hardware, which enforces memory region bounds natively, the
>>> software loopback has no such protection.
>>>
>>> A peer-supplied out-of-bounds offset or oversized write would result in
>>> an OOB write past the allocated kernel buffer. Add an explicit bounds
>>> check before the memcpy to reject such requests with -EINVAL.
>>>
>>> Fixes: f7a22071dbf3("net/smc: implement DMB-related operations of loopback-ism")
>>> Cc: stable@vger.kernel.org
>>> Reported-by: Federico Kirschbaum <federico.kirschbaum@xbow.com>
>>
>> Reported-by: Baul Lee <baul.lee@xbow.com>
>
> Could you provide a link to the report?
Since both reporters belong to the same org, I assume they
co-partecipated at the initial report.
Also there is a problem with the fixes tag that I'll address while
applying the patch.
/P
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net] dibs: loopback: validate offset and size in move_data()
2026-07-07 7:43 [PATCH net] dibs: loopback: validate offset and size in move_data() Dust Li
2026-07-07 14:31 ` Dust Li
@ 2026-07-09 11:10 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 5+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-07-09 11:10 UTC (permalink / raw)
To: Dust Li
Cc: wintera, wenjia, guwen, pabeni, mjambigi, alibuda, sidraya,
netdev, linux-kernel, stable, federico.kirschbaum
Hello:
This patch was applied to netdev/net.git (main)
by Paolo Abeni <pabeni@redhat.com>:
On Tue, 7 Jul 2026 15:43:18 +0800 you wrote:
> The loopback move_data() performs a memcpy into the registered DMB
> without checking whether offset + size exceeds the DMB length. Unlike
> real ISM hardware, which enforces memory region bounds natively, the
> software loopback has no such protection.
>
> A peer-supplied out-of-bounds offset or oversized write would result in
> an OOB write past the allocated kernel buffer. Add an explicit bounds
> check before the memcpy to reject such requests with -EINVAL.
>
> [...]
Here is the summary with links:
- [net] dibs: loopback: validate offset and size in move_data()
https://git.kernel.org/netdev/net/c/78237e3c0720
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-07-09 11:10 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-07 7:43 [PATCH net] dibs: loopback: validate offset and size in move_data() Dust Li
2026-07-07 14:31 ` Dust Li
2026-07-07 18:31 ` Andrew Lunn
2026-07-09 10:46 ` Paolo Abeni
2026-07-09 11:10 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox