From: "H. Peter Anvin" <hpa@linux.intel.com>
To: torvalds@linux-foundation.org
Cc: linux-kernel@vger.kernel.org, "H. Peter Anvin" <hpa@zytor.com>,
Arjan van de Ven <arjan@linux.kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>,
Christoph Lameter <cl@linux-foundation.org>,
Hugh Dickins <hugh.dickins@tiscali.co.uk>,
Rik van Riel <riel@redhat.com>, Ingo Molnar <mingo@elte.hu>,
Thomas Gleixner <tglx@linutronix.de>
Subject: [PATCH] mm: Make copy_from_user() in migrate.c statically predictable
Date: Thu, 18 Feb 2010 14:43:53 -0800 [thread overview]
Message-ID: <1266533033-24457-1-git-send-email-hpa@linux.intel.com> (raw)
From: H. Peter Anvin <hpa@zytor.com>
x86-32 has had a static test for copy_on_user() overflow for a while.
This test currently fails in mm/migrate.c resulting in an
allyesconfig/allmodconfig build failure on x86-32:
In function ‘copy_from_user’,
inlined from ‘do_pages_stat’ at
/home/hpa/kernel/git/mm/migrate.c:1012:
/home/hpa/kernel/git/arch/x86/include/asm/uaccess_32.h:212: error:
call to ‘copy_from_user_overflow’ declared
Make the logic more explicit and therefore easier for gcc to
understand.
Reported-by: Len Brown <lenb@kernel.org>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Cc: Arjan van de Ven <arjan@linux.kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Cc: Christoph Lameter <cl@linux-foundation.org>
Cc: Hugh Dickins <hugh.dickins@tiscali.co.uk>
Cc: Rik van Riel <riel@redhat.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Thomas Gleixner <tglx@linutronix.de>
---
NOTE: Sending this patch directly rather than queueing it up since it is a
current build failure.
mm/migrate.c | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/mm/migrate.c b/mm/migrate.c
index 9a0db5b..1a12f15 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -1002,12 +1002,12 @@ static int do_pages_stat(struct mm_struct *mm, unsigned long nr_pages,
#define DO_PAGES_STAT_CHUNK_NR 16
const void __user *chunk_pages[DO_PAGES_STAT_CHUNK_NR];
int chunk_status[DO_PAGES_STAT_CHUNK_NR];
- unsigned long i, chunk_nr = DO_PAGES_STAT_CHUNK_NR;
+ unsigned long i, chunk_nr;
int err;
for (i = 0; i < nr_pages; i += chunk_nr) {
- if (chunk_nr > nr_pages - i)
- chunk_nr = nr_pages - i;
+ chunk_nr = min(nr_pages - i,
+ (unsigned long)DO_PAGES_STAT_CHUNK_NR);
err = copy_from_user(chunk_pages, &pages[i],
chunk_nr * sizeof(*chunk_pages));
--
1.6.5.2
next reply other threads:[~2010-02-18 22:45 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-02-18 22:43 H. Peter Anvin [this message]
2010-02-18 23:02 ` [PATCH] mm: Make copy_from_user() in migrate.c statically predictable Linus Torvalds
2010-02-19 0:17 ` H. Peter Anvin
2010-02-19 1:25 ` KOSAKI Motohiro
2010-02-19 1:27 ` H. Peter Anvin
2010-02-21 11:45 ` KOSAKI Motohiro
2010-02-19 14:55 ` Christoph Lameter
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=1266533033-24457-1-git-send-email-hpa@linux.intel.com \
--to=hpa@linux.intel.com \
--cc=akpm@linux-foundation.org \
--cc=arjan@linux.kernel.org \
--cc=cl@linux-foundation.org \
--cc=hpa@zytor.com \
--cc=hugh.dickins@tiscali.co.uk \
--cc=kosaki.motohiro@jp.fujitsu.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=riel@redhat.com \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox