From: YueHaibing <yuehaibing@huawei.com>
To: David Miller <davem@davemloft.net>
Cc: <kuznet@ms2.inr.ac.ru>, <yoshfuji@linux-ipv6.org>,
<linux-kernel@vger.kernel.org>, <netdev@vger.kernel.org>
Subject: Re: [PATCH] ipv4: fib_rules: Fix possible infinite loop in fib_empty_table
Date: Sat, 29 Dec 2018 14:46:50 +0800 [thread overview]
Message-ID: <3cb9f28c-534f-701a-19bf-63ebadac303f@huawei.com> (raw)
In-Reply-To: <20181228.211503.1983080144355610600.davem@davemloft.net>
On 2018/12/29 13:15, David Miller wrote:
> From: YueHaibing <yuehaibing@huawei.com>
> Date: Wed, 26 Dec 2018 16:34:20 +0800
>
>> diff --git a/net/ipv4/fib_rules.c b/net/ipv4/fib_rules.c
>> index f8eb78d..1567e12 100644
>> --- a/net/ipv4/fib_rules.c
>> +++ b/net/ipv4/fib_rules.c
>> @@ -200,9 +200,13 @@ static struct fib_table *fib_empty_table(struct net *net)
>> {
>> u32 id;
>>
>> - for (id = 1; id <= RT_TABLE_MAX; id++)
>> + for (id = 1; id <= RT_TABLE_MAX; id++) {
>> if (!fib_get_table(net, id))
>> return fib_new_table(net, id);
>> +
>> + if (id == RT_TABLE_MAX)
>> + break;
>> + }
>> return NULL;
>> }
>
> The loop now has two exit conditions, one of which (by your analysis
> is completely impossible).
>
Thanks, will do it in v2.
> Please clean this up into a loop with better structure and no
> impossible tests. One approach could be simply:
>
> id = 1;
> while (1) {
> ...
> if (id++ == RT_TABLE_MAX)
> break;
> }
>
> Or even:
>
> id = 0;
> while (++id) {
> ...
> }
>
> .
>
prev parent reply other threads:[~2018-12-29 6:47 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-26 8:34 YueHaibing
2018-12-29 5:15 ` David Miller
2018-12-29 6:46 ` YueHaibing [this message]
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=3cb9f28c-534f-701a-19bf-63ebadac303f@huawei.com \
--to=yuehaibing@huawei.com \
--cc=davem@davemloft.net \
--cc=kuznet@ms2.inr.ac.ru \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=yoshfuji@linux-ipv6.org \
/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
all inboxes | Powered by JetHome®