netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] mpls: Properly validate RTA_VIA payload length
@ 2015-03-06 10:47 Robert Shearman
  2015-03-06 20:06 ` Eric W. Biederman
  2015-03-06 20:19 ` David Miller
  0 siblings, 2 replies; 3+ messages in thread
From: Robert Shearman @ 2015-03-06 10:47 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, Robert Shearman, Eric W. Biederman

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

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH net-next] mpls: Properly validate RTA_VIA payload length
  2015-03-06 10:47 [PATCH net-next] mpls: Properly validate RTA_VIA payload length Robert Shearman
@ 2015-03-06 20:06 ` Eric W. Biederman
  2015-03-06 20:19 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: Eric W. Biederman @ 2015-03-06 20:06 UTC (permalink / raw)
  To: Robert Shearman; +Cc: David Miller, netdev

Robert Shearman <rshearma@brocade.com> writes:

> 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.
>

Acked-by: "Eric W. Biederman" <ebiederm@xmission.com>
> 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;

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net-next] mpls: Properly validate RTA_VIA payload length
  2015-03-06 10:47 [PATCH net-next] mpls: Properly validate RTA_VIA payload length Robert Shearman
  2015-03-06 20:06 ` Eric W. Biederman
@ 2015-03-06 20:19 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2015-03-06 20:19 UTC (permalink / raw)
  To: rshearma; +Cc: netdev, ebiederm

From: Robert Shearman <rshearma@brocade.com>
Date: Fri, 6 Mar 2015 10:47:00 +0000

> 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>

Applied, thank you.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-03-06 20:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-06 10:47 [PATCH net-next] mpls: Properly validate RTA_VIA payload length Robert Shearman
2015-03-06 20:06 ` Eric W. Biederman
2015-03-06 20:19 ` David Miller

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).