2006-02-27 22:42:07

by Chris Wright

[permalink] [raw]
Subject: [patch 18/39] [PATCH] sys_mbind sanity checking

-stable review patch. If anyone has any objections, please let us know.
------------------

Make sure maxnodes is safe size before calculating nlongs in
get_nodes().

Signed-off-by: Chris Wright <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
[chrisw: fix units, pointed out by Andi]
Cc: Andi Kleen <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
---

mm/mempolicy.c | 2 ++
1 files changed, 2 insertions(+)

--- linux-2.6.15.4.orig/mm/mempolicy.c
+++ linux-2.6.15.4/mm/mempolicy.c
@@ -524,6 +524,8 @@ static int get_nodes(nodemask_t *nodes,
nodes_clear(*nodes);
if (maxnode == 0 || !nmask)
return 0;
+ if (maxnode > PAGE_SIZE*BITS_PER_BYTE)
+ return -EINVAL;

nlongs = BITS_TO_LONGS(maxnode);
if ((maxnode % BITS_PER_LONG) == 0)

--


2006-03-02 04:17:19

by Dave Jones

[permalink] [raw]
Subject: Re: [patch 18/39] [PATCH] sys_mbind sanity checking

On Mon, Feb 27, 2006 at 02:32:18PM -0800, Chris Wright wrote:
> -stable review patch. If anyone has any objections, please let us know.
> ------------------
>
> Make sure maxnodes is safe size before calculating nlongs in
> get_nodes().
>
> Signed-off-by: Chris Wright <[email protected]>
> Signed-off-by: Linus Torvalds <[email protected]>
> [chrisw: fix units, pointed out by Andi]
> Cc: Andi Kleen <[email protected]>
> Signed-off-by: Greg Kroah-Hartman <[email protected]>
> ---
>
> mm/mempolicy.c | 2 ++
> 1 files changed, 2 insertions(+)
>
> --- linux-2.6.15.4.orig/mm/mempolicy.c
> +++ linux-2.6.15.4/mm/mempolicy.c
> @@ -524,6 +524,8 @@ static int get_nodes(nodemask_t *nodes,
> nodes_clear(*nodes);
> if (maxnode == 0 || !nmask)
> return 0;
> + if (maxnode > PAGE_SIZE*BITS_PER_BYTE)
> + return -EINVAL;
>
> nlongs = BITS_TO_LONGS(maxnode);
> if ((maxnode % BITS_PER_LONG) == 0)

Gar..

mm/mempolicy.c: In function 'get_nodes':
mm/mempolicy.c:527: error: 'BITS_PER_BYTE' undeclared (first use in this function)
mm/mempolicy.c:527: error: (Each undeclared identifier is reported only once
mm/mempolicy.c:527: error: for each function it appears in.)

About to retry a build with the below patch which should do the trick.
(How did this *ever* build?)

Signed-off-by: Dave Jones <[email protected]>

--- linux-2.6.15/include/linux/types.h~ 2006-03-01 23:05:24.000000000 -0500
+++ linux-2.6.15/include/linux/types.h 2006-03-01 23:05:57.000000000 -0500
@@ -8,6 +8,7 @@
(((bits)+BITS_PER_LONG-1)/BITS_PER_LONG)
#define DECLARE_BITMAP(name,bits) \
unsigned long name[BITS_TO_LONGS(bits)]
+#define BITS_PER_BYTE 8
#endif

#include <linux/posix_types.h>

2006-03-02 06:07:03

by Chris Wright

[permalink] [raw]
Subject: Re: [stable] Re: [patch 18/39] [PATCH] sys_mbind sanity checking

* Dave Jones ([email protected]) wrote:
> Gar..
>
> mm/mempolicy.c: In function 'get_nodes':
> mm/mempolicy.c:527: error: 'BITS_PER_BYTE' undeclared (first use in this function)
> mm/mempolicy.c:527: error: (Each undeclared identifier is reported only once
> mm/mempolicy.c:527: error: for each function it appears in.)
>
> About to retry a build with the below patch which should do the trick.
> (How did this *ever* build?)

Egads, this is a terrible release. Thanks, that is the same macro
that's in Linus' tree which is the base I tested the original patch on,
and it's off on the configs I'm testing -stable with so I completely
missed the trivial brokeness.

thanks,
-chris