• L
    mm: make page ref count overflow check tighter and more explicit · 5026c0ae
    Linus Torvalds 提交于
    mainline inclusion
    from mainline-5.1-rc5
    commit f958d7b528b1b40c44cfda5eabe2d82760d868c3
    category: 13690
    bugzilla: NA
    CVE: CVE-2019-11487
    
    There are four commits to fix this CVE:
      fs: prevent page refcount overflow in pipe_buf_get
      mm: prevent get_user_pages() from overflowing page refcount
      mm: add 'try_get_page()' helper function
      mm: make page ref count overflow check tighter and more explicit
    
    -------------------------------------------------
    
    We have a VM_BUG_ON() to check that the page reference count doesn't
    underflow (or get close to overflow) by checking the sign of the count.
    
    That's all fine, but we actually want to allow people to use a "get page
    ref unless it's already very high" helper function, and we want that one
    to use the sign of the page ref (without triggering this VM_BUG_ON).
    
    Change the VM_BUG_ON to only check for small underflows (or _very_ close
    to overflowing), and ignore overflows which have strayed into negative
    territory.
    Acked-by: NMatthew Wilcox <willy@infradead.org>
    Cc: Jann Horn <jannh@google.com>
    Cc: stable@kernel.org
    Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
    Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
    Reviewed-by: Nzhong jiang <zhongjiang@huawei.com>
    Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
    5026c0ae
mm.h 87.2 KB