From: Gerd Rausch <[email protected]>
[ Upstream commit fb4b1373dcab086d0619c29310f0466a0b2ceb8a ]
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 <[email protected]>
Acked-by: Santosh Shilimkar <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jakub Kicinski <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>
---
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 3d9c4c6397c3..20d045faf07c 100644
--- a/net/rds/ib_frmr.c
+++ b/net/rds/ib_frmr.c
@@ -112,9 +112,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;
/* Perform a WR for the fast_reg_mr. Each individual page
--
2.30.2
Hi!
> [ Upstream commit fb4b1373dcab086d0619c29310f0466a0b2ceb8a ]
>
> 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.
I see this queued for 4.19 and 5.10 where "iommu/vt-d: Convert intel
iommu driver to the iommu ops" is not present. It may be okay for
older kernels, too, but I wanted to double-check.
Best regards,
Pavel
> +++ b/net/rds/ib_frmr.c
> @@ -112,9 +112,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;
>
> /* Perform a WR for the fast_reg_mr. Each individual page
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Hi Pavel,
On 02/09/2021 23.50, Pavel Machek wrote:
>> [ Upstream commit fb4b1373dcab086d0619c29310f0466a0b2ceb8a ]
>>
>> 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.
>
> I see this queued for 4.19 and 5.10 where "iommu/vt-d: Convert intel
> iommu driver to the iommu ops" is not present. It may be okay for
> older kernels, too, but I wanted to double-check.
>
It should be okay for older kernels as well.
The bug has always been there, but only started to cause panics
in cases where "dma_map_sg" actually did merge adjacent entries.
We bisected the crash down to the commit mentioned above (c588072bba6b),
on platforms that use the intel iommu.
That intel-iommu commit wasn't there on Linux-5.10 and older.
But the RDS bug was.
Hope this helps,
Gerd