Re: [PATCH 3.4 022/214] filter: prevent nla extensions to peek beyond the end of the message

From: Greg Kroah-Hartman
Date: Thu Jun 05 2014 - 14:11:51 EST


On Thu, Jun 05, 2014 at 03:49:48PM +0200, Mathias Krause wrote:
> On 5 June 2014 15:33, Luis Henriques <luis.henriques@xxxxxxxxxxxxx> wrote:
> > On Wed, Jun 04, 2014 at 09:16:25PM -0700, Greg Kroah-Hartman wrote:
> >> 3.4-stable review patch. If anyone has any objections, please let me know.
> >> [...]
> >> --- a/net/core/filter.c
> >> +++ b/net/core/filter.c
> >> @@ -338,11 +338,15 @@ load_b:
> >>
> >> if (skb_is_nonlinear(skb))
> >> return 0;
> >> + if (skb->len < sizeof(struct nlattr))
> >> + return 0;
> >> + if (skb->len < sizeof(struct nlattr))
> >> + return 0;
> >
> > There above code is duplicated this backport. The same comment
> > applies to the 3.2.y backport (I've added Ben to the CC list).
> >
>
> Good catch! The diff should look more like the the one in the
> attachment. I guess patch(1) just failed here to find the right place
> to apply the hunk to.
>
> Thanks,
> Mathias

> diff --git a/net/core/filter.c b/net/core/filter.c
> index 6f755cc..3b7398a 100644
> --- a/net/core/filter.c
> +++ b/net/core/filter.c
> @@ -322,6 +322,8 @@ load_b:
>
> if (skb_is_nonlinear(skb))
> return 0;
> + if (skb->len < sizeof(struct nlattr))
> + return 0;
> if (A > skb->len - sizeof(struct nlattr))
> return 0;
>
> @@ -338,11 +340,13 @@ load_b:
>
> if (skb_is_nonlinear(skb))
> return 0;
> + if (skb->len < sizeof(struct nlattr))
> + return 0;
> if (A > skb->len - sizeof(struct nlattr))
> return 0;
>
> nla = (struct nlattr *)&skb->data[A];
> - if (nla->nla_len > A - skb->len)
> + if (nla->nla_len > skb->len - A)
> return 0;
>
> nla = nla_find_nested(nla, X);


Thanks, I've fixed up the patch in the 3.4-stable queue to match this
version instead.

greg k-h
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/