linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jason Gunthorpe <jgg@ziepe.ca>
To: Nikita Zhandarovich <n.zhandarovich@fintech.ru>
Cc: Potnuri Bharat Teja <bharat@chelsio.com>,
	Leon Romanovsky <leon@kernel.org>,
	linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org,
	lvc-project@linuxtesting.org
Subject: Re: [PATCH] RDMA/cxgb4: Fix potential null-ptr-deref in pass_establish()
Date: Thu, 2 Feb 2023 11:58:21 -0400	[thread overview]
Message-ID: <Y9vdndjG0e9cCaI/@ziepe.ca> (raw)
In-Reply-To: <20230202145222.25571-1-n.zhandarovich@fintech.ru>

On Thu, Feb 02, 2023 at 06:52:22AM -0800, Nikita Zhandarovich wrote:
> If get_ep_from_tid() fails to lookup non-NULL value for ep, ep is
> dereferenced later regardless of whether it is empty.
> This patch adds a simple sanity check to fix the issue.
> 
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
> 
> Fixes: 944661dd97f4 ("RDMA/iw_cxgb4: atomically lookup ep and get a reference")
> Signed-off-by: Nikita Zhandarovich <n.zhandarovich@fintech.ru>
> ---
>  drivers/infiniband/hw/cxgb4/cm.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/infiniband/hw/cxgb4/cm.c b/drivers/infiniband/hw/cxgb4/cm.c
> index c16017f6e8db..f4a02c2ec02f 100644
> --- a/drivers/infiniband/hw/cxgb4/cm.c
> +++ b/drivers/infiniband/hw/cxgb4/cm.c
> @@ -2683,6 +2683,10 @@ static int pass_establish(struct c4iw_dev *dev, struct sk_buff *skb)
>  	u16 tcp_opt = ntohs(req->tcp_opt);
>  
>  	ep = get_ep_from_tid(dev, tid);
> +	if (!ep) {
> +		pr_warn("%s tid %d lookup failure!\n", __func__, tid);
> +		return 0;
> +	}

don't print please

Jason

  reply	other threads:[~2023-02-02 16:00 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-02 14:52 [PATCH] RDMA/cxgb4: Fix potential null-ptr-deref in pass_establish() Nikita Zhandarovich
2023-02-02 15:58 ` Jason Gunthorpe [this message]
2023-02-02 18:48   ` [PATCH v2] " Nikita Zhandarovich
2023-02-06 13:55     ` Leon Romanovsky
2023-02-06 13:58     ` Leon Romanovsky

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=Y9vdndjG0e9cCaI/@ziepe.ca \
    --to=jgg@ziepe.ca \
    --cc=bharat@chelsio.com \
    --cc=leon@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=lvc-project@linuxtesting.org \
    --cc=n.zhandarovich@fintech.ru \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).