From: shaozhengchao <shaozhengchao@huawei.com>
To: Hangbin Liu <liuhangbin@gmail.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 22:36:08 +0800 [thread overview]
Message-ID: <e3488110-e3c2-49cd-401b-a6ef51a79f9d@huawei.com> (raw)
In-Reply-To: <ZVwcWmg5NtuTSV7q@Laptop-X1>
On 2023/11/21 10:56, Hangbin Liu wrote:
> 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?
I also think mld has the same issue.
Thread A Thread B
icmpv6_rcv br_dev_stop
igmp6_event_query br_multicast_leave_snoopers
start mc_query_work ipv6_dev_mc_dec
Thread C __ipv6_dev_mc_dec
mld_query_work mutex_lock
... igmp6_group_dropped//r=1
... mutex_unlock
... ma_put
... refcount_dec_...//r=0
mutex_lock
__mld_query_work
igmp6_group_queried
refcount_inc(&ma->mca_refcnt) //r increased from 0
mutex_lock
Check whether the value of mcs_uses is 0 will solve the issue.
also I think checking whether the device is still running in IGMP does
not solve the uaf issue, but reduces the probability of the issue. I
will try to use a lock to solve the IGMP refcnt uaf issue.
>
> Thanks
> Hangbin
>
next prev parent reply other threads:[~2023-11-21 14:36 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
2023-11-21 12:38 ` shaozhengchao
2023-11-21 14:36 ` shaozhengchao [this message]
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=e3488110-e3c2-49cd-401b-a6ef51a79f9d@huawei.com \
--to=shaozhengchao@huawei.com \
--cc=davem@davemloft.net \
--cc=dsahern@kernel.org \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=liuhangbin@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.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).