diff mbox series

[v2,2/2] RDMA/rxe: Prevent faulty rkey generation

Message ID 20221219054644.4530-2-matsuda-daisuke@fujitsu.com (mailing list archive)
State Superseded
Headers show
Series [v2,1/2] RDMA/rxe: Fix inaccurate constants in rxe_type_info | expand

Commit Message

Daisuke Matsuda (Fujitsu) Dec. 19, 2022, 5:46 a.m. UTC
If you create MRs more than 0x10000 times after loading the module,
responder starts to reply NAKs for RDMA/Atomic operations because of rkey
violation detected in check_rkey(). The root cause is that rkeys are
incremented each time a new MR is created and the value overflows into the
range reserved for MWs.

This commit also increases the value of RXE_MAX_MW that has been limited
unlike other parameters.

Fixes: 0994a1bcd5f7 ("RDMA/rxe: Bump up default maximum values used via uverbs")
Signed-off-by: Daisuke Matsuda <matsuda-daisuke@fujitsu.com>
---
v1->v2:
 Fixed the value of RXE_MAX_MR as suggested by Li.
 Increased the value of RXE_MAX_MW.

 drivers/infiniband/sw/rxe/rxe_param.h | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

Comments

Zhijian Li (Fujitsu) Dec. 20, 2022, 6:27 a.m. UTC | #1
On 19/12/2022 13:46, Daisuke Matsuda wrote:
> If you create MRs more than 0x10000 times after loading the module,
> responder starts to reply NAKs for RDMA/Atomic operations because of rkey
> violation detected in check_rkey(). The root cause is that rkeys are
> incremented each time a new MR is created and the value overflows into the
> range reserved for MWs.
> 
> This commit also increases the value of RXE_MAX_MW that has been limited
> unlike other parameters.
> 
> Fixes: 0994a1bcd5f7 ("RDMA/rxe: Bump up default maximum values used via uverbs")
> Signed-off-by: Daisuke Matsuda <matsuda-daisuke@fujitsu.com>
> ---
> v1->v2:
>   Fixed the value of RXE_MAX_MR as suggested by Li.
>   Increased the value of RXE_MAX_MW.
> 
>   drivers/infiniband/sw/rxe/rxe_param.h | 10 +++++-----
>   1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/infiniband/sw/rxe/rxe_param.h b/drivers/infiniband/sw/rxe/rxe_param.h
> index a754fc902e3d..9c9b5f0d929b 100644
> --- a/drivers/infiniband/sw/rxe/rxe_param.h
> +++ b/drivers/infiniband/sw/rxe/rxe_param.h
> @@ -98,11 +98,11 @@ enum rxe_device_param {
>   	RXE_MAX_SRQ			= DEFAULT_MAX_VALUE - RXE_MIN_SRQ_INDEX,
>   
>   	RXE_MIN_MR_INDEX		= 0x00000001,
> -	RXE_MAX_MR_INDEX		= DEFAULT_MAX_VALUE,
> -	RXE_MAX_MR			= DEFAULT_MAX_VALUE - RXE_MIN_MR_INDEX,
> -	RXE_MIN_MW_INDEX		= 0x00010001,
> -	RXE_MAX_MW_INDEX		= 0x00020000,
> -	RXE_MAX_MW			= 0x00001000,
> +	RXE_MAX_MR_INDEX		= DEFAULT_MAX_VALUE >> 1,
> +	RXE_MAX_MR			= RXE_MAX_MR_INDEX - RXE_MIN_MR_INDEX,
> +	RXE_MIN_MW_INDEX		= (DEFAULT_MAX_VALUE >> 1) + 1,

Please change to:
RXE_MIN_MW_INDEX = RXE_MAX_MR_INDEX + 1

Otherwise, LGTM

Tested-by: Li Zhijian <lizhijian@fujitsu.com>
Reviewed-by: Li Zhijian <lizhijian@fujitsu.com>



> +	RXE_MAX_MW_INDEX		= DEFAULT_MAX_VALUE,
> +	RXE_MAX_MW			= RXE_MAX_MW_INDEX - RXE_MIN_MW_INDEX,
>   
>   	RXE_MAX_PKT_PER_ACK		= 64,
>
diff mbox series

Patch

diff --git a/drivers/infiniband/sw/rxe/rxe_param.h b/drivers/infiniband/sw/rxe/rxe_param.h
index a754fc902e3d..9c9b5f0d929b 100644
--- a/drivers/infiniband/sw/rxe/rxe_param.h
+++ b/drivers/infiniband/sw/rxe/rxe_param.h
@@ -98,11 +98,11 @@  enum rxe_device_param {
 	RXE_MAX_SRQ			= DEFAULT_MAX_VALUE - RXE_MIN_SRQ_INDEX,
 
 	RXE_MIN_MR_INDEX		= 0x00000001,
-	RXE_MAX_MR_INDEX		= DEFAULT_MAX_VALUE,
-	RXE_MAX_MR			= DEFAULT_MAX_VALUE - RXE_MIN_MR_INDEX,
-	RXE_MIN_MW_INDEX		= 0x00010001,
-	RXE_MAX_MW_INDEX		= 0x00020000,
-	RXE_MAX_MW			= 0x00001000,
+	RXE_MAX_MR_INDEX		= DEFAULT_MAX_VALUE >> 1,
+	RXE_MAX_MR			= RXE_MAX_MR_INDEX - RXE_MIN_MR_INDEX,
+	RXE_MIN_MW_INDEX		= (DEFAULT_MAX_VALUE >> 1) + 1,
+	RXE_MAX_MW_INDEX		= DEFAULT_MAX_VALUE,
+	RXE_MAX_MW			= RXE_MAX_MW_INDEX - RXE_MIN_MW_INDEX,
 
 	RXE_MAX_PKT_PER_ACK		= 64,