From: Tobias Lindskog Date: Mon, 9 Feb 2015 07:10:39 +0000 (+0100) Subject: Shrink ashmem directly through shmem_fallocate X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=9cba14efb869b58f55e248012d4f4ea73f02dd8d;p=GitHub%2Fexynos8895%2Fandroid_kernel_samsung_universal8895.git Shrink ashmem directly through shmem_fallocate When ashmem_shrink is called from direct reclaim on a user thread, a call to do_fallocate will check for permissions against the security policy of that user thread. It can thus fail by chance if called on a thread that isn't permitted to modify the relevant ashmem areas. Because we know that we have a shmem file underneath, call the shmem implementation of fallocate directly instead of going through the user-space interface for fallocate. FIX=DMS06243560 Area: Kernel/Linux Kernel Bug: 21951515 Change-Id: Ie98fff18a2bdeb535cd24d4fbdd13677e12681a7 Signed-off-by: Jeff Vander Stoep --- diff --git a/drivers/staging/android/ashmem.c b/drivers/staging/android/ashmem.c index 1830548e29a2..3f1133230a1a 100644 --- a/drivers/staging/android/ashmem.c +++ b/drivers/staging/android/ashmem.c @@ -440,9 +440,9 @@ ashmem_shrink_scan(struct shrinker *shrink, struct shrink_control *sc) loff_t start = range->pgstart * PAGE_SIZE; loff_t end = (range->pgend + 1) * PAGE_SIZE; - vfs_fallocate(range->asma->file, - FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, - start, end - start); + range->asma->file->f_op->fallocate(range->asma->file, + FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, + start, end - start); range->purged = ASHMEM_WAS_PURGED; lru_del(range);