[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20080911.150434.99620481.davem@davemloft.net>
Date: Thu, 11 Sep 2008 15:04:34 -0700 (PDT)
From: David Miller <davem@...emloft.net>
To: vegard.nossum@...il.com
Cc: netdev@...r.kernel.org, tgraf@...g.ch, penberg@...helsinki.fi,
mingo@...e.hu, viro@...iv.linux.org.uk,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH] netlink: fix overrun in attribute iteration
From: Vegard Nossum <vegard.nossum@...il.com>
Date: Thu, 11 Sep 2008 22:59:33 +0200
> A short example illustrating this point is here:
>
> #include <stdio.h>
>
> main(void)
> {
> printf("%d\n", -1 >= sizeof(int));
> }
>
> ...which prints "1".
Someone should print that out on a huge poster, it's a good
example of why C promotion rules suck :)
> This patch adds a cast in front of the sizeof so that GCC will make
> a signed comparison and fix the illegal memory dereference. With the
> patch applied, there is no kmemcheck report.
>
> Cc: Thomas Graf <tgraf@...g.ch>
> Signed-off-by: Vegard Nossum <vegard.nossum@...il.com>
Thomas, please review.
> diff --git a/include/net/netlink.h b/include/net/netlink.h
> index 18024b8..208fe5a 100644
> --- a/include/net/netlink.h
> +++ b/include/net/netlink.h
> @@ -702,7 +702,7 @@ static inline int nla_len(const struct nlattr *nla)
> */
> static inline int nla_ok(const struct nlattr *nla, int remaining)
> {
> - return remaining >= sizeof(*nla) &&
> + return remaining >= (int) sizeof(*nla) &&
> nla->nla_len >= sizeof(*nla) &&
> nla->nla_len <= remaining;
> }
> --
> 1.5.5.1
>
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists