======================================================
WARNING: possible circular locking dependency detected
4.16.0-rc2+ #328 Not tainted
------------------------------------------------------
syz-executor3/19420 is trying to acquire lock:
 (&mm->mmap_sem){++++}, at: [<00000000944f2785>] __might_fault+0xe0/0x1d0 mm/memory.c:4570

but task is already holding lock:
 (ashmem_mutex){+.+.}, at: [<000000003ff9cd21>] ashmem_pin_unpin drivers/staging/android/ashmem.c:705 [inline]
 (ashmem_mutex){+.+.}, at: [<000000003ff9cd21>] ashmem_ioctl+0x3db/0x11b0 drivers/staging/android/ashmem.c:782

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #1 (ashmem_mutex){+.+.}:
       __mutex_lock_common kernel/locking/mutex.c:756 [inline]
       __mutex_lock+0x16f/0x1a80 kernel/locking/mutex.c:893
       mutex_lock_nested+0x16/0x20 kernel/locking/mutex.c:908
       ashmem_mmap+0x53/0x410 drivers/staging/android/ashmem.c:362
       call_mmap include/linux/fs.h:1786 [inline]
       mmap_region+0xa99/0x15a0 mm/mmap.c:1705
       do_mmap+0x6c0/0xe00 mm/mmap.c:1483
       do_mmap_pgoff include/linux/mm.h:2223 [inline]
       vm_mmap_pgoff+0x1de/0x280 mm/util.c:355
       SYSC_mmap_pgoff mm/mmap.c:1533 [inline]
       SyS_mmap_pgoff+0x462/0x5f0 mm/mmap.c:1491
       SYSC_mmap arch/x86/kernel/sys_x86_64.c:100 [inline]
       SyS_mmap+0x16/0x20 arch/x86/kernel/sys_x86_64.c:91
       do_syscall_64+0x280/0x940 arch/x86/entry/common.c:287
       entry_SYSCALL_64_after_hwframe+0x42/0xb7

-> #0 (&mm->mmap_sem){++++}:
       lock_acquire+0x1d5/0x580 kernel/locking/lockdep.c:3920
       __might_fault+0x13a/0x1d0 mm/memory.c:4571
       _copy_from_user+0x2c/0x110 lib/usercopy.c:10
       copy_from_user include/linux/uaccess.h:147 [inline]
       ashmem_pin_unpin drivers/staging/android/ashmem.c:710 [inline]
       ashmem_ioctl+0x438/0x11b0 drivers/staging/android/ashmem.c:782
       vfs_ioctl fs/ioctl.c:46 [inline]
       do_vfs_ioctl+0x1b1/0x1520 fs/ioctl.c:686
       SYSC_ioctl fs/ioctl.c:701 [inline]
       SyS_ioctl+0x8f/0xc0 fs/ioctl.c:692
       do_syscall_64+0x280/0x940 arch/x86/entry/common.c:287
       entry_SYSCALL_64_after_hwframe+0x42/0xb7

other info that might help us debug this:

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock(ashmem_mutex);
                               lock(&mm->mmap_sem);
                               lock(ashmem_mutex);
  lock(&mm->mmap_sem);

 *** DEADLOCK ***

1 lock held by syz-executor3/19420:
 #0:  (ashmem_mutex){+.+.}, at: [<000000003ff9cd21>] ashmem_pin_unpin drivers/staging/android/ashmem.c:705 [inline]
 #0:  (ashmem_mutex){+.+.}, at: [<000000003ff9cd21>] ashmem_ioctl+0x3db/0x11b0 drivers/staging/android/ashmem.c:782

stack backtrace:
CPU: 0 PID: 19420 Comm: syz-executor3 Not tainted 4.16.0-rc2+ #328
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
 __dump_stack lib/dump_stack.c:17 [inline]
 dump_stack+0x194/0x24d lib/dump_stack.c:53
 print_circular_bug.isra.38+0x2cd/0x2dc kernel/locking/lockdep.c:1223
 check_prev_add kernel/locking/lockdep.c:1863 [inline]
 check_prevs_add kernel/locking/lockdep.c:1976 [inline]
 validate_chain kernel/locking/lockdep.c:2417 [inline]
 __lock_acquire+0x30a8/0x3e00 kernel/locking/lockdep.c:3431
 lock_acquire+0x1d5/0x580 kernel/locking/lockdep.c:3920
 __might_fault+0x13a/0x1d0 mm/memory.c:4571
 _copy_from_user+0x2c/0x110 lib/usercopy.c:10
 copy_from_user include/linux/uaccess.h:147 [inline]
 ashmem_pin_unpin drivers/staging/android/ashmem.c:710 [inline]
 ashmem_ioctl+0x438/0x11b0 drivers/staging/android/ashmem.c:782
 vfs_ioctl fs/ioctl.c:46 [inline]
 do_vfs_ioctl+0x1b1/0x1520 fs/ioctl.c:686
 SYSC_ioctl fs/ioctl.c:701 [inline]
 SyS_ioctl+0x8f/0xc0 fs/ioctl.c:692
 do_syscall_64+0x280/0x940 arch/x86/entry/common.c:287
 entry_SYSCALL_64_after_hwframe+0x42/0xb7
RIP: 0033:0x453de9
RSP: 002b:00007fd163037c68 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 00007fd1630386d4 RCX: 0000000000453de9
RDX: 0000000000000000 RSI: 0000000000007709 RDI: 0000000000000013
RBP: 000000000072bea0 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00000000ffffffff
R13: 000000000000017a R14: 00000000006f2410 R15: 0000000000000000
xt_NFQUEUE: number of total queues is 0
xt_NFQUEUE: number of total queues is 0
ipt_rpfilter: only valid in 'raw' or 'mangle' table, not 'raw�'
device eql entered promiscuous mode
ipt_rpfilter: only valid in 'raw' or 'mangle' table, not 'raw�'
ipt_CLUSTERIP: bad num_local_nodes 855
QAT: Invalid ioctl
device syz4 entered promiscuous mode
QAT: Invalid ioctl
device syz4 left promiscuous mode
QAT: Invalid ioctl
device syz4 entered promiscuous mode
device syz4 left promiscuous mode
QAT: Invalid ioctl
encrypted_key: master key parameter '' is invalid
encrypted_key: master key parameter '' is invalid
xt_NFQUEUE: number of total queues is 0
xt_NFQUEUE: number of total queues is 0
kauditd_printk_skb: 1095 callbacks suppressed
audit: type=1400 audit(1519567548.569:9193): avc:  denied  { net_admin } for  pid=4234 comm="syz-executor1" capability=12  scontext=unconfined_u:system_r:insmod_t:s0-s0:c0.c1023 tcontext=unconfined_u:system_r:insmod_t:s0-s0:c0.c1023 tclass=cap_userns permissive=1
audit: type=1400 audit(1519567548.570:9194): avc:  denied  { net_admin } for  pid=4234 comm="syz-executor1" capability=12  scontext=unconfined_u:system_r:insmod_t:s0-s0:c0.c1023 tcontext=unconfined_u:system_r:insmod_t:s0-s0:c0.c1023 tclass=cap_userns permissive=1
audit: type=1400 audit(1519567548.575:9195): avc:  denied  { net_admin } for  pid=4234 comm="syz-executor1" capability=12  scontext=unconfined_u:system_r:insmod_t:s0-s0:c0.c1023 tcontext=unconfined_u:system_r:insmod_t:s0-s0:c0.c1023 tclass=cap_userns permissive=1
audit: type=1400 audit(1519567548.585:9196): avc:  denied  { map_create } for  pid=20158 comm="syz-executor2" scontext=unconfined_u:system_r:insmod_t:s0-s0:c0.c1023 tcontext=unconfined_u:system_r:insmod_t:s0-s0:c0.c1023 tclass=bpf permissive=1
audit: type=1400 audit(1519567548.586:9197): avc:  denied  { map_read map_write } for  pid=20158 comm="syz-executor2" scontext=unconfined_u:system_r:insmod_t:s0-s0:c0.c1023 tcontext=unconfined_u:system_r:insmod_t:s0-s0:c0.c1023 tclass=bpf permissive=1
audit: type=1400 audit(1519567548.588:9198): avc:  denied  { prog_load } for  pid=20158 comm="syz-executor2" scontext=unconfined_u:system_r:insmod_t:s0-s0:c0.c1023 tcontext=unconfined_u:system_r:insmod_t:s0-s0:c0.c1023 tclass=bpf permissive=1
audit: type=1400 audit(1519567548.589:9199): avc:  denied  { map_create } for  pid=20158 comm="syz-executor2" scontext=unconfined_u:system_r:insmod_t:s0-s0:c0.c1023 tcontext=unconfined_u:system_r:insmod_t:s0-s0:c0.c1023 tclass=bpf permissive=1
encrypted_key: master key parameter '' is invalid
audit: type=1400 audit(1519567548.591:9200): avc:  denied  { dac_override } for  pid=20160 comm="syz-executor6" capability=1  scontext=unconfined_u:system_r:insmod_t:s0-s0:c0.c1023 tcontext=unconfined_u:system_r:insmod_t:s0-s0:c0.c1023 tclass=cap_userns permissive=1
audit: type=1400 audit(1519567548.594:9201): avc:  denied  { prog_load } for  pid=20158 comm="syz-executor2" scontext=unconfined_u:system_r:insmod_t:s0-s0:c0.c1023 tcontext=unconfined_u:system_r:insmod_t:s0-s0:c0.c1023 tclass=bpf permissive=1
audit: type=1400 audit(1519567548.595:9202): avc:  denied  { dac_override } for  pid=20160 comm="syz-executor6" capability=1  scontext=unconfined_u:system_r:insmod_t:s0-s0:c0.c1023 tcontext=unconfined_u:system_r:insmod_t:s0-s0:c0.c1023 tclass=cap_userns permissive=1
encrypted_key: master key parameter '' is invalid
binder: 20168:20188 IncRefs 0 refcount change on invalid ref 0 ret -22
dccp_xmit_packet: Payload too large (65423) for featneg.
dccp_xmit_packet: Payload too large (65423) for featneg.
binder: 20255:20256 ioctl c0306201 20007000 returned -14
binder_alloc: binder_alloc_mmap_handler: 20255 20000000-20002000 already mapped failed -16
binder: BINDER_SET_CONTEXT_MGR already set
binder: 20255:20259 ioctl c0306201 20007000 returned -14
binder: 20255:20257 ioctl 40046207 0 returned -16
binder: send failed reply for transaction 65 to 20255:20256
binder: undelivered TRANSACTION_COMPLETE
binder: undelivered TRANSACTION_ERROR: 29189
QAT: Invalid ioctl
l2tp_core: tunl 4: fd 20 wrong protocol, got 1, expected 17
SELinux: failed to load policy
SELinux: failed to load policy
kernel msg: ebtables bug: please report to author: Valid hook without chain
kernel msg: ebtables bug: please report to author: Valid hook without chain
xt_ecn: cannot match TCP bits for non-tcp packets
xt_ecn: cannot match TCP bits for non-tcp packets
ptrace attach of "/root/syz-executor0"[12064] was attempted by "/root/syz-executor0"[20791]
binder: 20792 RLIMIT_NICE not set
ieee80211 phy4: Selected rate control algorithm 'minstrel_ht'
binder: BINDER_SET_CONTEXT_MGR already set
ptrace attach of "/root/syz-executor0"[12064] was attempted by "/root/syz-executor0"[20791]
ieee80211 phy5: Selected rate control algorithm 'minstrel_ht'
binder: 20792 RLIMIT_NICE not set
binder: 20788:20799 ioctl 40046207 0 returned -16
binder: BINDER_SET_CONTEXT_MGR already set
binder: 20963:20976 ioctl 40046207 0 returned -16
binder_alloc: 20963: binder_alloc_buf, no vma
binder: 20963:20965 transaction failed 29189/-3, size 0-0 line 2963
binder_alloc: 20963: binder_alloc_buf, no vma
binder: 20963:20976 transaction failed 29189/-3, size 0-0 line 2963
binder: undelivered TRANSACTION_ERROR: 29189
binder: undelivered TRANSACTION_ERROR: 29189
binder: undelivered TRANSACTION_COMPLETE
binder: undelivered TRANSACTION_COMPLETE
binder: undelivered transaction 71, process died.
binder: undelivered transaction 70, process died.
ipt_CLUSTERIP: no config found for 255.255.255.255, need 'new'
ipt_CLUSTERIP: no config found for 255.255.255.255, need 'new'
netlink: 'syz-executor3': attribute type 1 has an invalid length.
binder: 21092:21104 BC_FREE_BUFFER u0000000000000000 no match
netlink: 'syz-executor3': attribute type 1 has an invalid length.
binder: 21092:21117 BC_FREE_BUFFER u0000000000000000 no match