dibs: loopback: validate offset and size in move_data()
PATCH 1/1 dibs: loopback: validate offset and size in move_data()
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.
--- drivers/dibs/dibs_loopback.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/dibs/dibs_loopback.c +5 -0
@@ -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);
Signature · 1 line
2.43.7
Quoted 5 lines · Dust Li
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.
Quoted 7 lines
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")Reported-by Federico Kirschbaum <[email protected]>
Best regards,
Dust
Quoted 23 lines
Signed-off-by Dust Li <[email protected]>---
drivers/dibs/dibs_loopback.c| 5 +++++1 file changed, 5 insertions(+)drivers/dibs/dibs_loopback.c +5
-0@@ -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);Signature · 1 line
2.43.7
Quoted 10 lines · Dust Li
Quoted 9 lines · Dust Li
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.
Quoted 5 lines
Quoted 3 lines
Fixes f7a22071dbf3("net/smc: implement DMB-related operations of loopback-ism")Reported-by Federico Kirschbaum <[email protected]>Reported-by Baul Lee <[email protected]>
Could you provide a link to the report?
Thanks
Andrew
Paolo Abeni
maintainerQuoted 11 lines · Andrew Lunn
Quoted 10 lines · Dust Li
Quoted 9 lines · Dust Li
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.
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Fixes f7a22071dbf3("net/smc: implement DMB-related operations of loopback-ism")Reported-by Federico Kirschbaum <[email protected]>Reported-by Baul Lee <[email protected]>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
This patch was applied to netdev/net.git (main) by Paolo Abeni <[email protected]>:
Hello:
This patch was applied to netdev/net.git (main)
by Paolo Abeni <[email protected]>:
Quoted 10 lines · 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!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html