netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Hangbin Liu <liuhangbin@gmail.com>
To: Zhengchao Shao <shaozhengchao@huawei.com>
Cc: netdev@vger.kernel.org, davem@davemloft.net, dsahern@kernel.org,
	edumazet@google.com, kuba@kernel.org, pabeni@redhat.com,
	weiyongjun1@huawei.com, yuehaibing@huawei.com
Subject: Re: [PATCH net] ipv4: igmp: fix refcnt uaf issue when receiving igmp query packet
Date: Tue, 21 Nov 2023 10:56:26 +0800	[thread overview]
Message-ID: <ZVwcWmg5NtuTSV7q@Laptop-X1> (raw)
In-Reply-To: <20231121020558.240321-1-shaozhengchao@huawei.com>

Hi Zhengchao,
On Tue, Nov 21, 2023 at 10:05:58AM +0800, Zhengchao Shao wrote:
> ---
>  net/ipv4/igmp.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/net/ipv4/igmp.c b/net/ipv4/igmp.c
> index 76c3ea75b8dd..f217581904d6 100644
> --- a/net/ipv4/igmp.c
> +++ b/net/ipv4/igmp.c
> @@ -1044,6 +1044,8 @@ static bool igmp_heard_query(struct in_device *in_dev, struct sk_buff *skb,
>  	for_each_pmc_rcu(in_dev, im) {
>  		int changed;
>  
> +		if (!netif_running(im->interface->dev))
> +			continue;

I haven't checked this part for a long time. What's the difference of in_dev->dev
and im->interface->dev? I though they are the same, no?

If they are the same, should we stop processing the query earlier? e.g.

diff --git a/net/ipv4/igmp.c b/net/ipv4/igmp.c
index 76c3ea75b8dd..f4e1d229c9aa 100644
--- a/net/ipv4/igmp.c
+++ b/net/ipv4/igmp.c
@@ -1082,6 +1082,9 @@ int igmp_rcv(struct sk_buff *skb)
                        goto drop;
        }

+       if (!netif_running(dev))
+               goto drop;
+
        in_dev = __in_dev_get_rcu(dev);
        if (!in_dev)
                goto drop;


BTW, does IPv6 MLD has this issue?

Thanks
Hangbin

  reply	other threads:[~2023-11-21  2:56 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-21  2:05 [PATCH net] ipv4: igmp: fix refcnt uaf issue when receiving igmp query packet Zhengchao Shao
2023-11-21  2:56 ` Hangbin Liu [this message]
2023-11-21 12:38   ` shaozhengchao
2023-11-21 14:36   ` shaozhengchao
2023-11-21 17:37 ` Eric Dumazet
2023-11-22  2:43   ` shaozhengchao

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=ZVwcWmg5NtuTSV7q@Laptop-X1 \
    --to=liuhangbin@gmail.com \
    --cc=davem@davemloft.net \
    --cc=dsahern@kernel.org \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=shaozhengchao@huawei.com \
    --cc=weiyongjun1@huawei.com \
    --cc=yuehaibing@huawei.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;
as well as URLs for NNTP newsgroup(s).