From: Baozeng Ding <sploving1@gmail.com>
To: jon.maloy@ericsson.com, ying.xue@windriver.com, davem@davemloft.net
Cc: netdev@vger.kernel.org, tipc-discussion@lists.sourceforge.net
Subject: [PATCH] tipc: fix potential null pointer dereference in the nla_data function
Date: Fri, 10 Jun 2016 10:26:59 +0800 [thread overview]
Message-ID: <a692a179-6f59-fdbb-9c49-e943677fce43@gmail.com> (raw)
In-Reply-To: <4b00b274-d144-2809-fa86-1ea38d913fd5@gmail.com>
Before calling the nla_data function, make sure the argument is not null.
Fix potential null pointer dereference vulnerability for this.
Signed-off-by: Baozeng Ding <sploving1@gmail.com>
---
net/tipc/netlink_compat.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/net/tipc/netlink_compat.c b/net/tipc/netlink_compat.c
index f795b1d..efbba26 100644
--- a/net/tipc/netlink_compat.c
+++ b/net/tipc/netlink_compat.c
@@ -356,6 +356,9 @@ static int tipc_nl_compat_bearer_dump(struct tipc_nl_compat_msg *msg,
if (err)
return err;
+ if (!bearer[TIPC_NLA_BEARER_NAME])
+ return -EINVAL;
+
return tipc_add_tlv(msg->rep, TIPC_TLV_BEARER_NAME,
nla_data(bearer[TIPC_NLA_BEARER_NAME]),
nla_len(bearer[TIPC_NLA_BEARER_NAME]));
@@ -492,6 +495,9 @@ static int tipc_nl_compat_link_stat_dump(struct tipc_nl_compat_msg *msg,
if (err)
return err;
+ if (!link[TIPC_NLA_LINK_NAME])
+ return -EINVAL;
+
name = (char *)TLV_DATA(msg->req);
if (strcmp(name, nla_data(link[TIPC_NLA_LINK_NAME])) != 0)
return 0;
@@ -602,6 +608,9 @@ static int tipc_nl_compat_link_dump(struct tipc_nl_compat_msg *msg,
if (err)
return err;
+ if (!link[TIPC_NLA_LINK_NAME])
+ return -EINVAL;
+
link_info.dest = nla_get_flag(link[TIPC_NLA_LINK_DEST]);
link_info.up = htonl(nla_get_flag(link[TIPC_NLA_LINK_UP]));
strcpy(link_info.str, nla_data(link[TIPC_NLA_LINK_NAME]));
@@ -981,6 +990,9 @@ static int tipc_nl_compat_media_dump(struct tipc_nl_compat_msg *msg,
if (err)
return err;
+ if (!media[TIPC_NLA_MEDIA_NAME])
+ return -EINVAL;
+
return tipc_add_tlv(msg->rep, TIPC_TLV_MEDIA_NAME,
nla_data(media[TIPC_NLA_MEDIA_NAME]),
nla_len(media[TIPC_NLA_MEDIA_NAME]));
--
1.9.1
next prev parent reply other threads:[~2016-06-10 2:27 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-24 14:33 [PATCH v2] tipc: fix potential null pointer dereferences in some compat functions Baozeng Ding
2016-05-25 19:34 ` David Miller
2016-06-10 2:26 ` Baozeng Ding [this message]
2016-06-11 6:23 ` [PATCH] tipc: fix potential null pointer dereference in the nla_data function David Miller
2016-06-11 7:46 ` Erik Hugne
2016-06-11 17:32 ` [tipc-discussion] " David Miller
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=a692a179-6f59-fdbb-9c49-e943677fce43@gmail.com \
--to=sploving1@gmail.com \
--cc=davem@davemloft.net \
--cc=jon.maloy@ericsson.com \
--cc=netdev@vger.kernel.org \
--cc=tipc-discussion@lists.sourceforge.net \
--cc=ying.xue@windriver.com \
/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;
as well as URLs for NNTP newsgroup(s).