All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Dumazet <dada1@cosmosbay.com>
To: Andi Kleen <ak@suse.de>
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] MM, NUMA : sys_set_mempolicy() doesnt check if mode < 0
Date: Tue, 02 Aug 2005 00:07:23 +0200	[thread overview]
Message-ID: <42EE9D1B.108@cosmosbay.com> (raw)
In-Reply-To: <20050729074647.GC3726@bragg.suse.de>

[-- Attachment #1: Type: text/plain, Size: 921 bytes --]

MM, NUMA : sys_set_mempolicy() doesnt check if mode < 0

A kernel BUG() is triggered by a call to set_mempolicy() with a negative first argument.
This is because the mode is declared as an int, and the validity check doesnt check < 0 values.
Alternatively, mode could be declared as unsigned int or unsigned long.

Thank you
Eric
---------------------------------
Test program for x86_64:
---------------------------------
#include <unistd.h>
#include <stdio.h>
#include <errno.h>
#include <linux/unistd.h>

#define __NR_set_mempolicy      238
#define __sys_set_mempolicy(mode, nmask, maxnode) _syscall3(int, set_mempolicy, int, mode, unsigned long *, nmask, unsigned long, maxnode)
static __sys_set_mempolicy(mode, nmask, maxnode)

unsigned long nodes = 3;

int main()
{
int ret = set_mempolicy(-6, &nodes, 2);
printf("result=%d errno=%d\n", ret, errno);
return 0;
}


Signed-off-by: Eric Dumazet <dada1@cosmosbay.com>


[-- Attachment #2: mempolicy.patch --]
[-- Type: text/plain, Size: 371 bytes --]

--- linux-2.6.13-rc4/mm/mempolicy.c	2005-07-29 00:44:44.000000000 +0200
+++ linux-2.6.13-rc4-ed/mm/mempolicy.c	2005-08-01 23:52:43.000000000 +0200
@@ -443,7 +443,7 @@
 	struct mempolicy *new;
 	DECLARE_BITMAP(nodes, MAX_NUMNODES);
 
-	if (mode > MPOL_MAX)
+	if ((unsigned int)mode > MPOL_MAX)
 		return -EINVAL;
 	err = get_nodes(nodes, nmask, maxnode, mode);
 	if (err)

  reply	other threads:[~2005-08-01 22:10 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-07-28  1:15 [patch] x86_64: fix cpu_to_node setup for sparse apic_ids Ravikiran G Thirumalai
2005-07-28  1:24 ` Andrew Morton
2005-07-28  1:50   ` Ravikiran G Thirumalai
2005-07-29  7:46   ` Andi Kleen
2005-08-01 22:07     ` Eric Dumazet [this message]
2005-08-03  9:13       ` [PATCH] MM, NUMA : sys_set_mempolicy() doesnt check if mode < 0 Andi Kleen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=42EE9D1B.108@cosmosbay.com \
    --to=dada1@cosmosbay.com \
    --cc=ak@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.