From: Leon Romanovsky <leon@kernel.org>
To: Xiaomeng Tong <xiam0nd.tong@gmail.com>
Cc: bharat@chelsio.com, jgg@ziepe.ca, linux-kernel@vger.kernel.org,
linux-rdma@vger.kernel.org, roland@purestorage.com,
stable@vger.kernel.org, vipul@chelsio.com
Subject: Re: [PATCH] cxgb4: cm: fix a incorrect NULL check on list iterator
Date: Wed, 30 Mar 2022 15:53:38 +0300 [thread overview]
Message-ID: <YkRS0sImiTd+mhd3@unreal> (raw)
In-Reply-To: <20220330123027.25897-1-xiam0nd.tong@gmail.com>
On Wed, Mar 30, 2022 at 08:30:27PM +0800, Xiaomeng Tong wrote:
> On Sun, 27 Mar 2022 19:38:31 +0300, Leon Romanovsky wrote:
> >
> > On Sun, Mar 27, 2022 at 03:35:42PM +0800, Xiaomeng Tong wrote:
> > > The bug is here:
> > > if (!pdev) {
> > >
> > > The list iterator value 'pdev' will *always* be set and non-NULL
> > > by for_each_netdev(), so it is incorrect to assume that the
> > > iterator value will be NULL if the list is empty or no element
> > > found (in this case, the check 'if (!pdev)' can be bypassed as
> > > it always be false unexpectly).
> > >
> > > To fix the bug, use a new variable 'iter' as the list iterator,
> > > while use the original variable 'pdev' as a dedicated pointer to
> > > point to the found element.
> >
> > I don't think that the description is correct.
> > We are talking about loopback interface which received packet, the pdev will always exist.
>
> Do the both conditions impossible?
> 1. the list is empty or
> 2. we can not found a pdev due to this check
> if (ipv6_chk_addr(&init_net,
> (struct in6_addr *)peer_ip,
> pdev, 1))
> iter, 1))
Yes, both are impossible.
Thanks
>
> > Most likely. the check of "if (!pdev)" is to catch impossible situation where IPV6 packet
> > was sent over loopback, but IPV6 is not enabled.
>
> --
> Xiaomeng Tong
prev parent reply other threads:[~2022-03-30 12:53 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-27 7:35 [PATCH] cxgb4: cm: fix a incorrect NULL check on list iterator Xiaomeng Tong
2022-03-27 16:38 ` Leon Romanovsky
2022-03-30 12:30 ` Xiaomeng Tong
2022-03-30 12:53 ` Leon Romanovsky [this message]
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=YkRS0sImiTd+mhd3@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=roland@purestorage.com \
--cc=stable@vger.kernel.org \
--cc=vipul@chelsio.com \
--cc=xiam0nd.tong@gmail.com \
/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