[lkml]   [2010]   [Feb]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
    Patch in this message
    Subject[PATCH] mm: Make copy_from_user() in migrate.c statically predictable
    From: H. Peter Anvin <>

    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/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

    Reported-by: Len Brown <>
    Signed-off-by: H. Peter Anvin <>
    Cc: Arjan van de Ven <>
    Cc: Andrew Morton <>
    Cc: KOSAKI Motohiro <>
    Cc: Christoph Lameter <>
    Cc: Hugh Dickins <>
    Cc: Rik van Riel <>
    Cc: Ingo Molnar <>
    Cc: Thomas Gleixner <>

    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));
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to
    More majordomo info at
    Please read the FAQ at

     \ /
      Last update: 2010-02-18 23:47    [W:0.022 / U:46.152 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site