drm/ttm: Fix possible stack overflow by recursive shrinker calls.
authorTetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Sun, 3 Aug 2014 11:02:03 +0000 (20:02 +0900)
committerDave Airlie <airlied@redhat.com>
Tue, 5 Aug 2014 00:54:10 +0000 (10:54 +1000)
commit71336e011d1d2312bcbcaa8fcec7365024f3a95d
tree3e4a416ed2730c64b5fbb4975776d6f0b7041903
parent22e71691fd54c637800d10816bbeba9cf132d218
drm/ttm: Fix possible stack overflow by recursive shrinker calls.

While ttm_dma_pool_shrink_scan() tries to take mutex before doing GFP_KERNEL
allocation, ttm_pool_shrink_scan() does not do it. This can result in stack
overflow if kmalloc() in ttm_page_pool_free() triggered recursion due to
memory pressure.

  shrink_slab()
  => ttm_pool_shrink_scan()
     => ttm_page_pool_free()
        => kmalloc(GFP_KERNEL)
           => shrink_slab()
              => ttm_pool_shrink_scan()
                 => ttm_page_pool_free()
                    => kmalloc(GFP_KERNEL)

Change ttm_pool_shrink_scan() to do like ttm_dma_pool_shrink_scan() does.

Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Cc: stable <stable@kernel.org> [2.6.35+]
Signed-off-by: Dave Airlie <airlied@redhat.com>
drivers/gpu/drm/ttm/ttm_page_alloc.c