# \[PATCH net 1/1\] net/rds: dma\_map\_sg is entitled to merge entries

- Subsystems: NETWORKING \[GENERAL\], RDS - RELIABLE DATAGRAM SOCKETS, THE REST
- Maintainers: "David S. Miller", Eric Dumazet, Jakub Kicinski, Paolo Abeni, Allison Henderson, Linus Torvalds
- Status: LANDED (fb4b1373dcab · 2021-08-18 22:35)
- Landed in mainline as fb4b1373dcab on 2021-08-18.
- List: netdev
- 3 messages, 3 authors
- Page: https://ratatoskr.run/netdev/2021/08/11209533/t

## \[PATCH net 1/1\] net/rds: dma\_map\_sg is entitled to merge entries

- From: Gerd Rausch \<hidden\>
- Date: 2021-08-17 17:04:52 
- Message: https://ratatoskr.run/netdev/2021/08/11209533.md

```text
Function "dma_map_sg" is entitled to merge adjacent entries
and return a value smaller than what was passed as "nents".

Subsequently "ib_map_mr_sg" needs to work with this value ("sg_dma_len")
rather than the original "nents" parameter ("sg_len").

This old RDS bug was exposed and reliably causes kernel panics
(using RDMA operations "rds-stress -D") on x86_64 starting with:
commit c588072bba6b ("iommu/vt-d: Convert intel iommu driver to the iommu ops")

Simply put: Linux 5.11 and later.

Signed-off-by: Gerd Rausch <redacted>
---
 net/rds/ib_frmr.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/rds/ib_frmr.c b/net/rds/ib_frmr.c
index 9b6ffff72f2d..28c1b0022178 100644
--- a/net/rds/ib_frmr.c
+++ b/net/rds/ib_frmr.c
@@ -131,9 +131,9 @@ static int rds_ib_post_reg_frmr(struct rds_ib_mr *ibmr)
 		cpu_relax();
 	}
 
-	ret = ib_map_mr_sg_zbva(frmr->mr, ibmr->sg, ibmr->sg_len,
+	ret = ib_map_mr_sg_zbva(frmr->mr, ibmr->sg, ibmr->sg_dma_len,
 				&off, PAGE_SIZE);
-	if (unlikely(ret != ibmr->sg_len))
+	if (unlikely(ret != ibmr->sg_dma_len))
 		return ret < 0 ? ret : -EINVAL;
 
 	if (cmpxchg(&frmr->fr_state,
-- 
2.24.1

```

## Re: \[PATCH net 1/1\] net/rds: dma\_map\_sg is entitled to merge entries

- From: Santosh Shilimkar \<hidden\>
- Date: 2021-08-17 17:07:25 
- Message: https://ratatoskr.run/netdev/2021/08/11209537.md

```text


> On Aug 17, 2021, at 10:04 AM, Gerd Rausch [ref] wrote:
> 
> Function "dma_map_sg" is entitled to merge adjacent entries
> and return a value smaller than what was passed as "nents".
> 
> Subsequently "ib_map_mr_sg" needs to work with this value ("sg_dma_len")
> rather than the original "nents" parameter ("sg_len").
> 
> This old RDS bug was exposed and reliably causes kernel panics
> (using RDMA operations "rds-stress -D") on x86_64 starting with:
> commit c588072bba6b ("iommu/vt-d: Convert intel iommu driver to the iommu ops")
> 
> Simply put: Linux 5.11 and later.
> 
> Signed-off-by: Gerd Rausch <redacted>
> ---
> net/rds/ib_frmr.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)

Looks good to me Gerd. Thanks !!

Acked-by: Santosh Shilimkar <redacted>
```

## Re: \[PATCH net 1/1\] net/rds: dma\_map\_sg is entitled to merge entries

- From: patchwork-bot+netdevbpf@kernel.org
- Date: 2021-08-18 22:40:11 
- Message: https://ratatoskr.run/netdev/2021/08/11209677.md

```text
Hello:

This patch was applied to netdev/net.git (refs/heads/master):

On Tue, 17 Aug 2021 10:04:37 -0700 you wrote:
> Function "dma_map_sg" is entitled to merge adjacent entries
> and return a value smaller than what was passed as "nents".
> 
> Subsequently "ib_map_mr_sg" needs to work with this value ("sg_dma_len")
> rather than the original "nents" parameter ("sg_len").
> 
> This old RDS bug was exposed and reliably causes kernel panics
> (using RDMA operations "rds-stress -D") on x86_64 starting with:
> commit c588072bba6b ("iommu/vt-d: Convert intel iommu driver to the iommu ops")
> 
> [...]

Here is the summary with links:
  - [net,1/1] net/rds: dma_map_sg is entitled to merge entries
    https://git.kernel.org/netdev/net/c/fb4b1373dcab

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html


```
