1
0
Fork 0
alistair23-linux/drivers/staging/android
Suren Baghdasaryan 6a7626c479 staging: android: ashmem: Fix lockdep warning for write operation
commit 3e338d3c95 upstream.

syzbot report [1] describes a deadlock when write operation against an
ashmem fd executed at the time when ashmem is shrinking its cache results
in the following lock sequence:

Possible unsafe locking scenario:

        CPU0                    CPU1
        ----                    ----
   lock(fs_reclaim);
                                lock(&sb->s_type->i_mutex_key#13);
                                lock(fs_reclaim);
   lock(&sb->s_type->i_mutex_key#13);

kswapd takes fs_reclaim and then inode_lock while generic_perform_write
takes inode_lock and then fs_reclaim. However ashmem does not support
writing into backing shmem with a write syscall. The only way to change
its content is to mmap it and operate on mapped memory. Therefore the race
that lockdep is warning about is not valid. Resolve this by introducing a
separate lockdep class for the backing shmem inodes.

[1]: https://lkml.kernel.org/lkml/0000000000000b5f9d059aa2037f@google.com/

Reported-by: syzbot+7a0d9d0b26efefe61780@syzkaller.appspotmail.com
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Cc: stable <stable@vger.kernel.org>
Reviewed-by: Joel Fernandes (Google) <joel@joelfernandes.org>
Link: https://lore.kernel.org/r/20200730192632.3088194-1-surenb@google.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-08-11 15:33:34 +02:00
..
ion staging: android: ion: use vmap instead of vm_map_ram 2020-06-22 09:30:57 +02:00
uapi staging: android: ion: Add the GPL exception for syscalls 2019-02-14 10:47:20 +01:00
Kconfig staging: remove redundant 'default n' from Kconfig 2019-04-16 13:39:01 +02:00
Makefile staging: add missing SPDX lines to Makefile files 2019-04-03 11:10:15 +02:00
TODO staging: android: Remove ion device tree bindings from the TODO 2019-08-21 05:48:06 -07:00
ashmem.c staging: android: ashmem: Fix lockdep warning for write operation 2020-08-11 15:33:34 +02:00
ashmem.h staging: android: Clean up license identifiers 2018-05-08 13:24:15 +02:00
vsoc.c hrtimer/treewide: Use hrtimer_sleeper_start_expires() 2019-08-01 17:43:16 +02:00