Skip to content
  • Dan Carpenter's avatar
    fbcmap: integer overflow bug · 1e7c7804
    Dan Carpenter authored
    
    
    There is an integer overflow in fb_set_user_cmap() because cmap->len * 2
    can wrap.  It's basically harmless.  Your terminal will be messed up
    until you type reset.
    
    This patch does three things to fix the bug.
    
    First, it checks the return value of fb_copy_cmap() in fb_alloc_cmap().
    That is enough to fix address the overflow.
    
    Second it checks for the integer overflow in fb_set_user_cmap().
    
    Lastly I wanted to cap "cmap->len" in fb_set_user_cmap() much lower
    because it gets used to determine the size of allocation.  Unfortunately
    no one knows what the limit should be.  Instead what this patch does
    is makes the allocation happen with GFP_KERNEL instead of GFP_ATOMIC
    and lets the kmalloc() decide what values of cmap->len are reasonable.
    To do this, the patch introduces a function called fb_alloc_cmap_gfp()
    which is like fb_alloc_cmap() except that it takes a GFP flag.
    
    Signed-off-by: default avatarDan Carpenter <error27@gmail.com>
    Signed-off-by: default avatarPaul Mundt <lethal@linux-sh.org>
    1e7c7804