2023-09-18 16:39:28

by Artem Chernyshev

[permalink] [raw]
Subject: [PATCH] net: rds: Fix possible NULL-pointer dereference

In rds_rdma_cm_event_handler_cmn() check, if conn pointer exists
before dereferencing it as rdma_set_service_type() argument

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes: fd261ce6a30e ("rds: rdma: update rdma transport for tos")
Signed-off-by: Artem Chernyshev <[email protected]>
---
net/rds/rdma_transport.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/net/rds/rdma_transport.c b/net/rds/rdma_transport.c
index d36f3f6b4351..b506d9bd215c 100644
--- a/net/rds/rdma_transport.c
+++ b/net/rds/rdma_transport.c
@@ -86,11 +86,13 @@ static int rds_rdma_cm_event_handler_cmn(struct rdma_cm_id *cm_id,
break;

case RDMA_CM_EVENT_ADDR_RESOLVED:
- rdma_set_service_type(cm_id, conn->c_tos);
- rdma_set_min_rnr_timer(cm_id, IB_RNR_TIMER_000_32);
- /* XXX do we need to clean up if this fails? */
- ret = rdma_resolve_route(cm_id,
- RDS_RDMA_RESOLVE_TIMEOUT_MS);
+ if (conn) {
+ rdma_set_service_type(cm_id, conn->c_tos);
+ rdma_set_min_rnr_timer(cm_id, IB_RNR_TIMER_000_32);
+ /* XXX do we need to clean up if this fails? */
+ ret = rdma_resolve_route(cm_id,
+ RDS_RDMA_RESOLVE_TIMEOUT_MS);
+ }
break;

case RDMA_CM_EVENT_ROUTE_RESOLVED:
--
2.37.3


2023-09-20 08:05:19

by patchwork-bot+netdevbpf

[permalink] [raw]
Subject: Re: [PATCH] net: rds: Fix possible NULL-pointer dereference

Hello:

This patch was applied to netdev/net.git (main)
by David S. Miller <[email protected]>:

On Mon, 18 Sep 2023 16:56:23 +0300 you wrote:
> In rds_rdma_cm_event_handler_cmn() check, if conn pointer exists
> before dereferencing it as rdma_set_service_type() argument
>
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
>
> Fixes: fd261ce6a30e ("rds: rdma: update rdma transport for tos")
> Signed-off-by: Artem Chernyshev <[email protected]>
>
> [...]

Here is the summary with links:
- net: rds: Fix possible NULL-pointer dereference
https://git.kernel.org/netdev/net/c/f1d95df0f310

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