Netdev Archive on lore.kernel.org
help / color / mirror / Atom feed
From: David Ahern <dsahern@gmail.com>
To: Jakub Kicinski <kuba@kernel.org>, Pavel Skripkin <paskripkin@gmail.com>
Cc: syzbot <syzbot+c5ac86461673ef58847c@syzkaller.appspotmail.com>,
	davem@davemloft.net, dsahern@kernel.org,
	linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
	syzkaller-bugs@googlegroups.com, yoshfuji@linux-ipv6.org
Subject: Re: [syzbot] net-next boot error: WARNING: refcount bug in fib_create_info
Date: Tue, 3 Aug 2021 16:32:02 -0600	[thread overview]
Message-ID: <80ea9025-05a7-ab21-ed53-5527356c4464@gmail.com> (raw)
In-Reply-To: <20210803140435.19e560fe@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com>

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.


  reply	other threads:[~2021-08-03 22:32 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-03 16:07 syzbot
2021-08-03 16:12 ` Pavel Skripkin
2021-08-03 16:31   ` Pavel Skripkin
2021-08-03 21:04     ` Jakub Kicinski
2021-08-03 22:32       ` David Ahern [this message]
2021-08-04  5:05       ` Pavel Skripkin

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=80ea9025-05a7-ab21-ed53-5527356c4464@gmail.com \
    --to=dsahern@gmail.com \
    --cc=davem@davemloft.net \
    --cc=dsahern@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=paskripkin@gmail.com \
    --cc=syzbot+c5ac86461673ef58847c@syzkaller.appspotmail.com \
    --cc=syzkaller-bugs@googlegroups.com \
    --cc=yoshfuji@linux-ipv6.org \
    --subject='Re: [syzbot] net-next boot error: WARNING: refcount bug in fib_create_info' \
    /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

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).