From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757443AbbKFPmT (ORCPT ); Fri, 6 Nov 2015 10:42:19 -0500 Received: from mail-pa0-f43.google.com ([209.85.220.43]:33265 "EHLO mail-pa0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757364AbbKFPmR (ORCPT ); Fri, 6 Nov 2015 10:42:17 -0500 Message-ID: <1446824535.4184.69.camel@edumazet-glaptop2.roam.corp.google.com> Subject: Re: Deadlock between bind and splice From: Eric Dumazet To: Dmitry Vyukov , Al Viro , linux-fsdevel@vger.kernel.org, "linux-kernel@vger.kernel.org" Cc: netdev , David Miller , Eric Dumazet , Kostya Serebryany , Alexander Potapenko , Sasha Levin , syzkaller , Alexey Kuznetsov Date: Fri, 06 Nov 2015 07:42:15 -0800 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.10.4-0ubuntu2 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 2015-11-06 at 13:58 +0100, Dmitry Vyukov wrote: > Hello, > > I am on revision d1e41ff11941784f469f17795a4d9425c2eb4b7a (Nov 5) and > seeing the following lockdep reports. I don't have exact reproducer > program as it is caused by several independent programs (state > accumulated in kernel across invocations); if the report is not enough > I can try to cook a reproducer. > > Thanks. > > [ INFO: possible circular locking dependency detected ] > 4.3.0+ #30 Not tainted > ------------------------------------------------------- > a.out/9972 is trying to acquire lock: > (&pipe->mutex/1){+.+.+.}, at: [< inline >] pipe_lock_nested > fs/pipe.c:59 > (&pipe->mutex/1){+.+.+.}, at: [] > pipe_lock+0x56/0x70 fs/pipe.c:67 > > but task is already holding lock: > (sb_writers#5){.+.+.+}, at: [] > __sb_start_write+0xec/0x130 fs/super.c:1198 > > which lock already depends on the new lock. > > the existing dependency chain (in reverse order) is: > > -> #2 (sb_writers#5){.+.+.+}: > [] lock_acquire+0x16d/0x2f0 > kernel/locking/lockdep.c:3585 > [] percpu_down_read+0x3c/0xa0 > kernel/locking/percpu-rwsem.c:73 > [] __sb_start_write+0xec/0x130 fs/super.c:1198 > [< inline >] sb_start_write include/linux/fs.h:1449 > [] mnt_want_write+0x3f/0xb0 fs/namespace.c:386 > [] filename_create+0x106/0x450 fs/namei.c:3425 > [] kern_path_create+0x33/0x40 fs/namei.c:3471 > [< inline >] unix_mknod net/unix/af_unix.c:849 > [] unix_bind+0x41b/0xa10 net/unix/af_unix.c:917 > [] SYSC_bind+0x1ea/0x250 net/socket.c:1383 > [] SyS_bind+0x24/0x30 net/socket.c:1369 > [] entry_SYSCALL_64_fastpath+0x31/0x9a > arch/x86/entry/entry_64.S:187 > > -> #1 (&u->readlock){+.+.+.}: > [] lock_acquire+0x16d/0x2f0 > kernel/locking/lockdep.c:3585 > [< inline >] __mutex_lock_common kernel/locking/mutex.c:518 > [] mutex_lock_interruptible_nested+0xa9/0xa30 > kernel/locking/mutex.c:647 > [] unix_stream_sendpage+0x23c/0x700 > net/unix/af_unix.c:1768 > [] kernel_sendpage+0x90/0xe0 net/socket.c:3278 > [] sock_sendpage+0xa5/0xd0 net/socket.c:765 > [] pipe_to_sendpage+0x26a/0x320 fs/splice.c:720 > [< inline >] splice_from_pipe_feed fs/splice.c:772 > [] __splice_from_pipe+0x268/0x740 fs/splice.c:889 > [] splice_from_pipe+0xf7/0x140 fs/splice.c:924 > [] generic_splice_sendpage+0x40/0x50 fs/splice.c:1097 > [< inline >] do_splice_from fs/splice.c:1116 > [< inline >] do_splice fs/splice.c:1392 > [< inline >] SYSC_splice fs/splice.c:1695 > [] SyS_splice+0x845/0x17c0 fs/splice.c:1678 > [] entry_SYSCALL_64_fastpath+0x31/0x9a > arch/x86/entry/entry_64.S:187 > > -> #0 (&pipe->mutex/1){+.+.+.}: > [< inline >] check_prev_add kernel/locking/lockdep.c:1853 > [< inline >] check_prevs_add kernel/locking/lockdep.c:1958 > [< inline >] validate_chain kernel/locking/lockdep.c:2144 > [] __lock_acquire+0x36d9/0x40e0 > kernel/locking/lockdep.c:3206 > [] lock_acquire+0x16d/0x2f0 > kernel/locking/lockdep.c:3585 > [< inline >] __mutex_lock_common kernel/locking/mutex.c:518 > [] mutex_lock_nested+0x9c/0x8f0 > kernel/locking/mutex.c:618 > [< inline >] pipe_lock_nested fs/pipe.c:59 > [] pipe_lock+0x56/0x70 fs/pipe.c:67 > [] iter_file_splice_write+0x199/0xb20 fs/splice.c:962 > [< inline >] do_splice_from fs/splice.c:1116 > [< inline >] do_splice fs/splice.c:1392 > [< inline >] SYSC_splice fs/splice.c:1695 > [] SyS_splice+0x845/0x17c0 fs/splice.c:1678 > [] entry_SYSCALL_64_fastpath+0x31/0x9a > arch/x86/entry/entry_64.S:187 > > other info that might help us debug this: > > Chain exists of: > &pipe->mutex/1 --> &u->readlock --> sb_writers#5 > > Possible unsafe locking scenario: > > CPU0 CPU1 > ---- ---- > lock(sb_writers#5); > lock(&u->readlock); > lock(sb_writers#5); > lock(&pipe->mutex/1); > > *** DEADLOCK *** > > 1 lock held by a.out/9972: > #0: (sb_writers#5){.+.+.+}, at: [] > __sb_start_write+0xec/0x130 fs/super.c:1198 > > stack backtrace: > CPU: 1 PID: 9972 Comm: a.out Not tainted 4.3.0+ #30 > Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Bochs 01/01/2011 > 00000000ffffffff ffff88003d777938 ffffffff81aad406 ffffffff846046a0 > ffffffff84606860 ffffffff846086c0 ffff88003d777980 ffffffff811ec511 > ffff88003d777a80 000000003cf79640 ffff88003cf79df0 ffff88003cf79e12 > Call Trace: > [< inline >] __dump_stack lib/dump_stack.c:15 > [] dump_stack+0x68/0x92 lib/dump_stack.c:50 > [] print_circular_bug+0x2d1/0x390 > kernel/locking/lockdep.c:1226 > [< inline >] check_prev_add kernel/locking/lockdep.c:1853 > [< inline >] check_prevs_add kernel/locking/lockdep.c:1958 > [< inline >] validate_chain kernel/locking/lockdep.c:2144 > [] __lock_acquire+0x36d9/0x40e0 kernel/locking/lockdep.c:3206 > [] lock_acquire+0x16d/0x2f0 kernel/locking/lockdep.c:3585 > [< inline >] __mutex_lock_common kernel/locking/mutex.c:518 > [] mutex_lock_nested+0x9c/0x8f0 kernel/locking/mutex.c:618 > [< inline >] pipe_lock_nested fs/pipe.c:59 > [] pipe_lock+0x56/0x70 fs/pipe.c:67 > [] iter_file_splice_write+0x199/0xb20 fs/splice.c:962 > [< inline >] do_splice_from fs/splice.c:1116 > [< inline >] do_splice fs/splice.c:1392 > [< inline >] SYSC_splice fs/splice.c:1695 > [] SyS_splice+0x845/0x17c0 fs/splice.c:1678 > [] entry_SYSCALL_64_fastpath+0x31/0x9a > arch/x86/entry/entry_64.S:187 > -- Thank you for this report. pipe is part of fs, not net ;) CC Al Viro.