linux/drivers/staging/android
Joel Fernandes a06d9fa17c staging: android: ashmem: Fix lockdep issue during llseek
commit cb57469c95 upstream.

ashmem_mutex create a chain of dependencies like so:

(1)
mmap syscall ->
  mmap_sem ->  (acquired)
  ashmem_mmap
  ashmem_mutex (try to acquire)
  (block)

(2)
llseek syscall ->
  ashmem_llseek ->
  ashmem_mutex ->  (acquired)
  inode_lock ->
  inode->i_rwsem (try to acquire)
  (block)

(3)
getdents ->
  iterate_dir ->
  inode_lock ->
  inode->i_rwsem   (acquired)
  copy_to_user ->
  mmap_sem         (try to acquire)

There is a lock ordering created between mmap_sem and inode->i_rwsem
causing a lockdep splat [2] during a syzcaller test, this patch fixes
the issue by unlocking the mutex earlier. Functionally that's Ok since
we don't need to protect vfs_llseek.

[1] https://patchwork.kernel.org/patch/10185031/
[2] https://lkml.org/lkml/2018/1/10/48

Acked-by: Todd Kjos <tkjos@google.com>
Cc: Arve Hjonnevag <arve@android.com>
Reported-by: syzbot+8ec30bb7bf1a981a2012@syzkaller.appspotmail.com
Signed-off-by: Joel Fernandes <joelaf@google.com>
Acked-by: Greg Hackmann <ghackmann@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
[bwh: Backported to 3.16: adjust context]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
History 2018-06-16 22:22:31 +01:00
..
ion staging/android/ion : fix a race condition in the ion driver 2017-02-23 03:54:47 +00:00
trace staging: sync: Add tracepoint support 2013-03-04 17:46:55 +08:00
uapi staging: android: uapi: fix coding style 2014-04-16 20:17:31 -07:00
alarm-dev.c staging: android: fix missing a blank line after declarations 2014-05-03 19:46:30 -04:00
android_alarm.h staging: android: Split uapi out of android_alarm.h 2014-02-18 11:03:28 -08:00
ashmem.c staging: android: ashmem: Fix lockdep issue during llseek 2018-06-16 22:22:31 +01:00
ashmem.h staging: android: Split uapi out of ashmem.h 2014-02-18 11:03:28 -08:00
binder.c binder: replace "%p" with "%pK" 2018-06-16 22:22:17 +01:00
binder.h staging: binder: Support concurrent 32 bit and 64 bit processes. 2014-02-24 16:29:40 -08:00
binder_trace.h staging: binder: Support concurrent 32 bit and 64 bit processes. 2014-02-24 16:29:40 -08:00
Kconfig Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/trivial 2014-04-02 16:23:38 -07:00
logger.c staging: android: fix missing a blank line after declarations 2014-05-03 19:46:30 -04:00
logger.h staging: android: logger: use kuid_t instead of uid_t 2013-05-16 15:37:51 -07:00
lowmemorykiller.c staging: android: lowmemorykiller: neglect swap cached pages in other_file 2014-02-27 14:51:27 -08:00
Makefile ion: Reenable the build 2013-12-15 09:40:11 -08:00
sw_sync.c staging: android: fix missing a blank line after declarations 2014-05-03 19:46:30 -04:00
sw_sync.h staging: android: split uapi out of sync.h and sw_sync.h 2014-02-18 11:03:28 -08:00
sync.c staging: android: describe use of memory barrier on sync.c 2014-05-25 11:09:14 -07:00
sync.h staging: android: split uapi out of sync.h and sw_sync.h 2014-02-18 11:03:28 -08:00
timed_gpio.c staging : android: Fixes a coding style issue in timed_gpio.c 2014-05-24 01:54:55 +09:00
timed_gpio.h Staging: android: timed_gpio: Removed spaces before tabs 2012-02-29 15:52:52 -08:00
timed_output.c staging: android: timed_output: fix use after free of dev 2014-06-19 17:33:37 -07:00
timed_output.h staging: android: timed_output: fix a checkpatch warning 2014-02-11 12:27:30 -08:00
TODO drivers:staging:android Typos: fix some comments that have typos in them. 2012-02-08 16:47:50 -08:00