[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CANn89iKHfah8DjiDOwge6AkEU075W3M+-UBBBzh6P6a47hWLww@mail.gmail.com>
Date: Mon, 14 Feb 2022 17:13:38 -0800
From: Eric Dumazet <edumazet@...gle.com>
To: Cong Wang <xiyou.wangcong@...il.com>
Cc: Eric Dumazet <eric.dumazet@...il.com>,
"David S . Miller" <davem@...emloft.net>,
Jakub Kicinski <kuba@...nel.org>,
netdev <netdev@...r.kernel.org>,
David Ahern <dsahern@...nel.org>,
Cong Wang <cong.wang@...edance.com>,
syzbot <syzkaller@...glegroups.com>
Subject: Re: [PATCH net] ipmr,ip6mr: acquire RTNL before calling
ip[6]mr_free_table() on failure path
On Mon, Feb 14, 2022 at 4:54 PM Cong Wang <xiyou.wangcong@...il.com> wrote:
>
> On Mon, Feb 14, 2022 at 4:36 PM Eric Dumazet <edumazet@...gle.com> wrote:
> >
> > On Mon, Feb 14, 2022 at 4:24 PM Cong Wang <xiyou.wangcong@...il.com> wrote:
> > >
> > > On Mon, Feb 07, 2022 at 09:34:51PM -0800, Eric Dumazet wrote:
> > > > From: Eric Dumazet <edumazet@...gle.com>
> > > >
> > > > ip[6]mr_free_table() can only be called under RTNL lock.
> > > >
> > > > RTNL: assertion failed at net/core/dev.c (10367)
> > > > WARNING: CPU: 1 PID: 5890 at net/core/dev.c:10367 unregister_netdevice_many+0x1246/0x1850 net/core/dev.c:10367
> > > > Modules linked in:
> > > > CPU: 1 PID: 5890 Comm: syz-executor.2 Not tainted 5.16.0-syzkaller-11627-g422ee58dc0ef #0
> > > > Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
> > > > RIP: 0010:unregister_netdevice_many+0x1246/0x1850 net/core/dev.c:10367
> > > > Code: 0f 85 9b ee ff ff e8 69 07 4b fa ba 7f 28 00 00 48 c7 c6 00 90 ae 8a 48 c7 c7 40 90 ae 8a c6 05 6d b1 51 06 01 e8 8c 90 d8 01 <0f> 0b e9 70 ee ff ff e8 3e 07 4b fa 4c 89 e7 e8 86 2a 59 fa e9 ee
> > > > RSP: 0018:ffffc900046ff6e0 EFLAGS: 00010286
> > > > RAX: 0000000000000000 RBX: 0000000000000000 RCX: 0000000000000000
> > > > RDX: ffff888050f51d00 RSI: ffffffff815fa008 RDI: fffff520008dfece
> > > > RBP: 0000000000000000 R08: 0000000000000000 R09: 0000000000000000
> > > > R10: ffffffff815f3d6e R11: 0000000000000000 R12: 00000000fffffff4
> > > > R13: dffffc0000000000 R14: ffffc900046ff750 R15: ffff88807b7dc000
> > > > FS: 00007f4ab736e700(0000) GS:ffff8880b9d00000(0000) knlGS:0000000000000000
> > > > CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
> > > > CR2: 00007fee0b4f8990 CR3: 000000001e7d2000 CR4: 00000000003506e0
> > > > DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
> > > > DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
> > > > Call Trace:
> > > > <TASK>
> > > > mroute_clean_tables+0x244/0xb40 net/ipv6/ip6mr.c:1509
> > > > ip6mr_free_table net/ipv6/ip6mr.c:389 [inline]
> > > > ip6mr_rules_init net/ipv6/ip6mr.c:246 [inline]
> > > > ip6mr_net_init net/ipv6/ip6mr.c:1306 [inline]
> > >
> > > Isn't that new table still empty in this case? Which means
> > > mroute_clean_tables() should not actually unregister any netdevice??
> > >
> > > Should we just move that assertion after list empty check?
> > >
> > >
> > > diff --git a/net/core/dev.c b/net/core/dev.c
> > > index 909fb3815910..ff6e7d0074dd 100644
> > > --- a/net/core/dev.c
> > > +++ b/net/core/dev.c
> > > @@ -10359,11 +10359,11 @@ void unregister_netdevice_many(struct list_head *head)
> > > LIST_HEAD(close_head);
> > >
> > > BUG_ON(dev_boot_phase);
> > > - ASSERT_RTNL();
> > >
> > > if (list_empty(head))
> >
> > The rule is that we need to hold RTNL when calling unregister_netdevice_many().
> >
> > Adding a special case for empty list would avoid this safety check,
> > and perhaps hide future bugs.
>
> Why is that? What bugs are you talking about when it is just a nop?
>
> >
> > This ASSER_RTNL() check has been there forever (before git)
>
> So is this bug? ;)
>
> >
> > Not sure what this brings, my patch only fixed a super-rare case ?
> > Do you think the added rtrnl acquisition is an issue ?
>
> Yes, it is just completely unnecessary, I fail to see why we want to
> use RTNL to protect a nop.
>
Should we revert your patch then ?
There was no explanation of why was it needed to call p6mr_free_table()',
if later we had to shortcut innocent functions that are simply
assuming RTNL is held.
commit f243e5a7859a24d10975afb9a1708cac624ba6f1
Author: WANG Cong <xiyou.wangcong@...il.com>
Date: Wed Mar 25 14:45:03 2015 -0700
ipmr,ip6mr: call ip6mr_free_table() on failure path
Signed-off-by: Cong Wang <xiyou.wangcong@...il.com>
Signed-off-by: David S. Miller <davem@...emloft.net>
What was the reason to break the kernel, then complain later that
someone had to spend time to fix it ?
Powered by blists - more mailing lists