From: YueHaibing <yuehaibing@huawei.com>
To: <davem@davemloft.net>, <kuznet@ms2.inr.ac.ru>, <yoshfuji@linux-ipv6.org>
Cc: <linux-kernel@vger.kernel.org>, <netdev@vger.kernel.org>,
YueHaibing <yuehaibing@huawei.com>
Subject: [PATCH] ipv4: fib_rules: Fix possible infinite loop in fib_empty_table
Date: Wed, 26 Dec 2018 16:34:20 +0800 [thread overview]
Message-ID: <20181226083420.20436-1-yuehaibing@huawei.com> (raw)
gcc warn this:
net/ipv4/fib_rules.c:203 fib_empty_table() warn:
always true condition '(id <= 4294967295) => (0-u32max <= u32max)'
'id' is u32, which always not greater than RT_TABLE_MAX
(0xFFFFFFFF), So add a check to break while wrap around.
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
---
net/ipv4/fib_rules.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
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;
}
--
2.7.4
next reply other threads:[~2018-12-26 8:37 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-26 8:34 YueHaibing [this message]
2018-12-29 5:15 ` David Miller
2018-12-29 6:46 ` YueHaibing
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=20181226083420.20436-1-yuehaibing@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®