[lkml]   [1998]   [Sep]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
    Patch in this message
    Subjectfunny mmap() behaviour + FIX

    Hi Linus + all,

    for those who didn't read my last post a few days ago (the response
    wasn't very overwhelming...), again the problem:

    I do the following mappings:

    #define MAP_ADDR 0xfd000000 /* high mem area, eg. framebuf */
    #define MAP_SIZE 0x200000
    map_b=mmap(0,MAP_SIZE,PROT_READ | PROT_WRITE,
    map_c=mmap(map_a,MAP_SIZE,PROT_READ | PROT_WRITE,
    MAP_SHARED | MAP_FIXED,proc_self_mem_fd,

    When doing the map_c mapping, 2.1.1xx kernels put the process into
    jail (D-state) and 2.0.x kernels oops or become inconsistent (unable
    to start new processes etc.). It depends a little bit on the MAP_ADDR,

    The reason is, that the mem_mmap() function in fs/proc/mem.c accesses
    the mem_map table with a mapnr out of range.

    I did this fix with my very little VM/paging knowledge, so there might
    be a better one. At least it fixes the crashes and the annoying
    D-state behaviour.

    Please include it into the main tree. Thanks.


    --- linux-2.1.122/fs/proc/ Thu Sep 17 12:23:47 1998
    +++ linux-2.1.122/fs/proc/mem.c Wed Sep 23 23:14:22 1998
    @@ -215,7 +215,7 @@
    pgd_t *src_dir, *dest_dir;
    pmd_t *src_middle, *dest_middle;
    pte_t *src_table, *dest_table;
    - unsigned long stmp, dtmp;
    + unsigned long stmp, dtmp, mapnr;
    struct vm_area_struct *src_vma = NULL;
    struct inode *inode = file->f_dentry->d_inode;

    @@ -296,7 +296,9 @@

    set_pte(src_table, pte_mkdirty(*src_table));
    set_pte(dest_table, *src_table);
    - atomic_inc(&mem_map[MAP_NR(pte_page(*src_table))].count);
    + mapnr=MAP_NR(pte_page(*src_table));
    + if (mapnr < max_mapnr)
    + atomic_inc(&mem_map[mapnr].count);

    stmp += PAGE_SIZE;
    dtmp += PAGE_SIZE;

    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to
    Please read the FAQ at

     \ /
      Last update: 2005-03-22 13:44    [W:0.019 / U:2.364 seconds]
    ©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site