2011-02-28 20:36:03

by Lars Ellenberg

[permalink] [raw]
Subject: [patch] fix nla_policy_len to actually _iterate_ over the policy

Currently nla_policy_len always returns n * NLA_HDRLEN:
It loops, but does not advance it's iterator.
NLA_UNSPEC == 0 does not contain a .len in any policy.

Trivially fixed by adding p++.

Signed-off-by: Lars Ellenberg <[email protected]>

diff --git a/lib/nlattr.c b/lib/nlattr.c
index 5021cbc..ac09f22 100644
--- a/lib/nlattr.c
+++ b/lib/nlattr.c
@@ -148,7 +148,7 @@ nla_policy_len(const struct nla_policy *p, int n)
{
int i, len = 0;

- for (i = 0; i < n; i++) {
+ for (i = 0; i < n; i++, p++) {
if (p->len)
len += nla_total_size(p->len);
else if (nla_attr_minlen[p->type])


2011-02-28 20:37:59

by David Miller

[permalink] [raw]
Subject: Re: [patch] fix nla_policy_len to actually _iterate_ over the policy

From: Lars Ellenberg <[email protected]>
Date: Mon, 28 Feb 2011 21:35:59 +0100

> Currently nla_policy_len always returns n * NLA_HDRLEN:
> It loops, but does not advance it's iterator.
> NLA_UNSPEC == 0 does not contain a .len in any policy.
>
> Trivially fixed by adding p++.
>
> Signed-off-by: Lars Ellenberg <[email protected]>

Applied, thanks.

2011-02-28 21:26:27

by Greg KH

[permalink] [raw]
Subject: Re: [stable] [patch] fix nla_policy_len to actually _iterate_ over the policy

On Mon, Feb 28, 2011 at 09:35:59PM +0100, Lars Ellenberg wrote:
> Currently nla_policy_len always returns n * NLA_HDRLEN:
> It loops, but does not advance it's iterator.
> NLA_UNSPEC == 0 does not contain a .len in any policy.
>
> Trivially fixed by adding p++.
>
> Signed-off-by: Lars Ellenberg <[email protected]>
>
> diff --git a/lib/nlattr.c b/lib/nlattr.c

Please read how to properly get patches into the stable kernel tree in
the file Documentation/stable_kernel_rules.txt (hint, randomly cc:ing
[email protected] is NOT how to do it...)

thanks,

greg k-h