All of lore.kernel.org
 help / color / mirror / Atom feed
From: Leon Romanovsky <leon@kernel.org>
To: Nikita Zhandarovich <n.zhandarovich@fintech.ru>
Cc: Potnuri Bharat Teja <bharat@chelsio.com>,
	Jason Gunthorpe <jgg@ziepe.ca>,
	linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org,
	lvc-project@linuxtesting.org
Subject: Re: [PATCH v2] RDMA/cxgb4: Fix potential null-ptr-deref in pass_establish()
Date: Mon, 6 Feb 2023 15:55:46 +0200	[thread overview]
Message-ID: <Y+EG4uZnMr0lYPwU@unreal> (raw)
In-Reply-To: <20230202184850.29882-1-n.zhandarovich@fintech.ru>

On Thu, Feb 02, 2023 at 10:48:50AM -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>
> ---
> v2: do not use pr_warn() when get_ep_from_tid() returns NULL as
> Jason Gunthorpe <jgg@ziepe.ca> suggested.
> 
>  drivers/infiniband/hw/cxgb4/cm.c | 2 ++
>  1 file changed, 2 insertions(+)

I applied, but please next time.
1. Don't send patches as reply-to. It messes whole patch flow.
2. Use target in subject line, e.g. [PATCH rdma-next] or [PATCH rdma-rc]

Thanks


> 
> diff --git a/drivers/infiniband/hw/cxgb4/cm.c b/drivers/infiniband/hw/cxgb4/cm.c
> index 499a425a3379..f5f4579f037c 100644
> --- a/drivers/infiniband/hw/cxgb4/cm.c
> +++ b/drivers/infiniband/hw/cxgb4/cm.c
> @@ -2676,6 +2676,8 @@ 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)
> +		return 0;
>  	pr_debug("ep %p tid %u\n", ep, ep->hwtid);
>  	ep->snd_seq = be32_to_cpu(req->snd_isn);
>  	ep->rcv_seq = be32_to_cpu(req->rcv_isn);
> -- 
> 2.25.1
> 

  reply	other threads:[~2023-02-06 13:57 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
2023-02-02 18:48   ` [PATCH v2] " Nikita Zhandarovich
2023-02-06 13:55     ` Leon Romanovsky [this message]
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=Y+EG4uZnMr0lYPwU@unreal \
    --to=leon@kernel.org \
    --cc=bharat@chelsio.com \
    --cc=jgg@ziepe.ca \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.