From: Robert Shearman <rshearma@brocade.com>
To: David Miller <davem@davemloft.net>
Cc: <netdev@vger.kernel.org>, Robert Shearman <rshearma@brocade.com>,
"Eric W. Biederman" <ebiederm@xmission.com>
Subject: [PATCH net-next] mpls: Properly validate RTA_VIA payload length
Date: Fri, 6 Mar 2015 10:47:00 +0000 [thread overview]
Message-ID: <1425638820-19990-1-git-send-email-rshearma@brocade.com> (raw)
If the nla length is less than 2 then the nla data could be accessed
beyond the accessible bounds. So ensure that the nla is big enough to
at least read the via_family before doing so. Replace magic value of
2.
Fixes: 03c0566542f4 ("mpls: Basic support for adding and removing routes")
Cc: Eric W. Biederman <ebiederm@xmission.com>
Signed-off-by: Robert Shearman <rshearma@brocade.com>
---
net/mpls/af_mpls.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/net/mpls/af_mpls.c b/net/mpls/af_mpls.c
index 23e51d1..4ce39f6 100644
--- a/net/mpls/af_mpls.c
+++ b/net/mpls/af_mpls.c
@@ -585,8 +585,11 @@ static int rtm_to_route_config(struct sk_buff *skb, struct nlmsghdr *nlh,
case RTA_VIA:
{
struct rtvia *via = nla_data(nla);
+ if (nla_len(nla) < offsetof(struct rtvia, rtvia_addr))
+ goto errout;
cfg->rc_via_family = via->rtvia_family;
- cfg->rc_via_alen = nla_len(nla) - 2;
+ cfg->rc_via_alen = nla_len(nla) -
+ offsetof(struct rtvia, rtvia_addr);
if (cfg->rc_via_alen > MAX_VIA_ALEN)
goto errout;
--
2.1.4
next reply other threads:[~2015-03-06 10:48 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-06 10:47 Robert Shearman [this message]
2015-03-06 20:06 ` [PATCH net-next] mpls: Properly validate RTA_VIA payload length Eric W. Biederman
2015-03-06 20:19 ` 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=1425638820-19990-1-git-send-email-rshearma@brocade.com \
--to=rshearma@brocade.com \
--cc=davem@davemloft.net \
--cc=ebiederm@xmission.com \
--cc=netdev@vger.kernel.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;
as well as URLs for NNTP newsgroup(s).