[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <80ea9025-05a7-ab21-ed53-5527356c4464@gmail.com>
Date: Tue, 3 Aug 2021 16:32:02 -0600
From: David Ahern <dsahern@...il.com>
To: Jakub Kicinski <kuba@...nel.org>,
Pavel Skripkin <paskripkin@...il.com>
Cc: syzbot <syzbot+c5ac86461673ef58847c@...kaller.appspotmail.com>,
davem@...emloft.net, dsahern@...nel.org,
linux-kernel@...r.kernel.org, netdev@...r.kernel.org,
syzkaller-bugs@...glegroups.com, yoshfuji@...ux-ipv6.org
Subject: Re: [syzbot] net-next boot error: WARNING: refcount bug in
fib_create_info
On 8/3/21 3:04 PM, Jakub Kicinski wrote:
>>>
>>> diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
>>> index f29feb7772da..bb9949f6bb70 100644
>>> --- a/net/ipv4/fib_semantics.c
>>> +++ b/net/ipv4/fib_semantics.c
>>> @@ -1428,6 +1428,7 @@ struct fib_info *fib_create_info(struct fib_config
>>> *cfg,
>>> }
>>>
>>> fib_info_cnt++;
>>> + refcount_set(&fi->fib_treeref, 1);
>>> fi->fib_net = net;
>>> fi->fib_protocol = cfg->fc_protocol;
>>> fi->fib_scope = cfg->fc_scope;
>>
>> Oops, it's already fixed in -next, so
>>
>> #syz fix: ipv4: Fix refcount warning for new fib_info
>>
>>
>> BTW: there is one more bug with refcounts:
>>
>> link_it:
>> ofi = fib_find_info(fi);
>> if (ofi) {
>> fi->fib_dead = 1;
>> free_fib_info(fi);
>> refcount_inc(&ofi->fib_treeref);
>>
>> ^^^^^^^^^^^^^^^^^^^^^^^
>> / *fib_treeref is 0 here */
>
> Why 0? ofi is an existing object it's already initialized.
yes, it is an existing object with a non-0 refcount.
>
>> return ofi;
>> }
>>
>> refcount_set(&fi->fib_treeref, 1);
>>
>>
>> diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
>> index f29feb7772da..38d1fc4d0be1 100644
>> --- a/net/ipv4/fib_semantics.c
>> +++ b/net/ipv4/fib_semantics.c
>> @@ -1543,6 +1543,8 @@ struct fib_info *fib_create_info(struct fib_config
>> *cfg,
>> }
>>
>> link_it:
>> + refcount_set(&fi->fib_treeref, 1);
moving the refcount_set here causes all kinds of problems with the
release and error paths in this function.
Powered by blists - more mailing lists