Netdev Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Leon Romanovsky <leon@kernel.org>
To: Tuo Li <islituo@gmail.com>
Cc: ericvh@gmail.com, lucho@ionkov.net, asmadeus@codewreck.org,
	davem@davemloft.net, kuba@kernel.org,
	v9fs-developer@lists.sourceforge.net, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org, baijiaju1990@gmail.com,
	TOTE Robot <oslab@tsinghua.edu.cn>
Subject: Re: [PATCH] net: 9p: Fix possible null-pointer dereference in p9_cm_event_handler()
Date: Tue, 10 Aug 2021 16:55:42 +0300	[thread overview]
Message-ID: <YRKFXpilGXnKZ2yH@unreal> (raw)
In-Reply-To: <20210810132007.296008-1-islituo@gmail.com>

On Tue, Aug 10, 2021 at 06:20:07AM -0700, Tuo Li wrote:
> The variable rdma is checked when event->event is equal to 
> RDMA_CM_EVENT_DISCONNECTED:
>   if (rdma)
> 
> This indicates that it can be NULL. If so, a null-pointer dereference will 
> occur when calling complete():
>   complete(&rdma->cm_done);
> 
> To fix this possible null-pointer dereference, calling complete() only 
> when rdma is not NULL.

You need to explain how is it possible and blindly set if () checks.
I would say first "if (rdma)" is not needed, but don't know for sure.

> 
> Reported-by: TOTE Robot <oslab@tsinghua.edu.cn>
> Signed-off-by: Tuo Li <islituo@gmail.com>
> ---
>  net/9p/trans_rdma.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/net/9p/trans_rdma.c b/net/9p/trans_rdma.c
> index af0a8a6cd3fd..fb3435dfd071 100644
> --- a/net/9p/trans_rdma.c
> +++ b/net/9p/trans_rdma.c
> @@ -285,7 +285,8 @@ p9_cm_event_handler(struct rdma_cm_id *id, struct rdma_cm_event *event)
>  	default:
>  		BUG();
>  	}
> -	complete(&rdma->cm_done);
> +	if (rdma)
> +		complete(&rdma->cm_done);
>  	return 0;
>  }
>  
> -- 
> 2.25.1
> 

  reply	other threads:[~2021-08-10 13:55 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-10 13:20 Tuo Li
2021-08-10 13:55 ` Leon Romanovsky [this message]
2021-08-10 14:20   ` asmadeus

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YRKFXpilGXnKZ2yH@unreal \
    --to=leon@kernel.org \
    --cc=asmadeus@codewreck.org \
    --cc=baijiaju1990@gmail.com \
    --cc=davem@davemloft.net \
    --cc=ericvh@gmail.com \
    --cc=islituo@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lucho@ionkov.net \
    --cc=netdev@vger.kernel.org \
    --cc=oslab@tsinghua.edu.cn \
    --cc=v9fs-developer@lists.sourceforge.net \
    --subject='Re: [PATCH] net: 9p: Fix possible null-pointer dereference in p9_cm_event_handler()' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).