From: Tobias Lindskog Date: Fri, 6 Jul 2018 21:44:16 +0000 (-0700) Subject: staging: android: ashmem: Shrink directly through shmem_fallocate X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=173a4906aebe14fccc6cd338efda618fd69d56de;p=openwrt%2Fstaging%2Fblogic.git staging: android: ashmem: Shrink 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. Signed-off-by: Tobias Lindskog Signed-off-by: Jeff Vander Stoep Signed-off-by: Joel Fernandes (Google) Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/android/ashmem.c b/drivers/staging/android/ashmem.c index e392358ec244..b73cc1e089a3 100644 --- a/drivers/staging/android/ashmem.c +++ b/drivers/staging/android/ashmem.c @@ -450,9 +450,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);