From: Jia-Ju Bai <baijiaju1990@gmail.com>
To: davem@davemloft.net, sbrivio@redhat.com, sd@queasysnail.net,
liuhangbin@gmail.com, jbenc@redhat.com, dsahern@gmail.com,
natechancellor@gmail.com, tglx@linutronix.de
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
Jia-Ju Bai <baijiaju1990@gmail.com>
Subject: [PATCH] net: geneve: Fix a possible null-pointer dereference in geneve_link_config()
Date: Mon, 29 Jul 2019 18:26:11 +0800 [thread overview]
Message-ID: <20190729102611.2338-1-baijiaju1990@gmail.com> (raw)
In geneve_link_config(), there is an if statement on line 1524 to check
whether rt is NULL:
if (rt && rt->dst.dev)
When rt is NULL, it is used on line 1526:
ip6_rt_put(rt)
dst_release(&rt->dst);
Thus, a possible null-pointer dereference may occur.
To fix this bug, ip6_rt_put(rt) is called when rt is not NULL.
This bug is found by a static analysis tool STCheck written by us.
Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
---
drivers/net/geneve.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/net/geneve.c b/drivers/net/geneve.c
index cb2ea8facd8d..a47a1b31b166 100644
--- a/drivers/net/geneve.c
+++ b/drivers/net/geneve.c
@@ -1521,9 +1521,10 @@ static void geneve_link_config(struct net_device *dev,
rt = rt6_lookup(geneve->net, &info->key.u.ipv6.dst, NULL, 0,
NULL, 0);
- if (rt && rt->dst.dev)
+ if (rt && rt->dst.dev) {
ldev_mtu = rt->dst.dev->mtu - GENEVE_IPV6_HLEN;
- ip6_rt_put(rt);
+ ip6_rt_put(rt);
+ }
break;
}
#endif
--
2.17.0
next reply other threads:[~2019-07-29 10:26 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-29 10:26 Jia-Ju Bai [this message]
2019-07-29 10:30 ` Jiri Benc
2019-07-29 10:52 ` Jiri Benc
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=20190729102611.2338-1-baijiaju1990@gmail.com \
--to=baijiaju1990@gmail.com \
--cc=davem@davemloft.net \
--cc=dsahern@gmail.com \
--cc=jbenc@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=liuhangbin@gmail.com \
--cc=natechancellor@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=sbrivio@redhat.com \
--cc=sd@queasysnail.net \
--cc=tglx@linutronix.de \
/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®