Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2572493imu; Wed, 21 Nov 2018 13:54:39 -0800 (PST) X-Google-Smtp-Source: AFSGD/XgL2a486ikU5DQMyoPGGtUv+tuld6/jknhwtYAPFvTBq9uHoAYcyLzvr69K9ooDfwLu+il X-Received: by 2002:a65:534b:: with SMTP id w11mr7559517pgr.125.1542837279637; Wed, 21 Nov 2018 13:54:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542837279; cv=none; d=google.com; s=arc-20160816; b=xS4UooA8rVPtB2qugCjvxcoNaMlS4db8r5ZMa4ko3sJnD42jJ/8hwYjddVFIGEKpw9 CDbKkSAU0w5mt6IECb84+ORZInSfFivlY7IXAKn1dRpeY2gPilKLorERty9ZRcjsXLdb 06gQDMKnKe8B+ocSnj8i/j+ERD+oCj+4bvfDG67Ccf9Whi5mY+H6RkJaiLpkjhiQIijk +/0wrcRS3HZZ2rdIgQOn2+Ux0uriD0kqiiNDshP9UITK3hde03wjFkn+DBke+ImkP3rh EZm2Gs468lN2c5gFlZRDAwNCFqIR4Laxp9GLAJ8tCOXJ5jcZDBfS4tU7qVD0LsvlRAk3 a19g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=4oYS75YM4IWbVPPXD2djKR3FyB+TT4dtQ9+y5k60DBI=; b=0L9aIdfpLEl8cLFfQWdDU6A/7icdUewamjJ6vJR2ToaHRT65GnLm+px7XHf4R/dGF6 llg7m4M0nqzk+eFcfnaKhoarm7pxX1Qm/M6oNq0SV61IZkTjNtcWAoJqJ9JjUmNJFOrG 2h1z4uFYr7G7E1VBQ+m1roa3hBzeMvbUiUsX1V4r4MbmxUT12MtqpPX+JupChsg2a8yq or787mnUb3ryG71iDhGoNwrGq7EPwkT4P3Qk8EYJm+j38K4ujKNd7h6Lxb864pXiG+5I pN3C5aA9KyhiQ2n4PBPLSDkPdHqVYcH/3g5HTU/+qKfDFYTsPweeLFAhebpW06fe/678 p6Zw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Jkjd48l8; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l4si43401462pgr.346.2018.11.21.13.54.21; Wed, 21 Nov 2018 13:54:39 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Jkjd48l8; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731655AbeKVFdB (ORCPT + 99 others); Thu, 22 Nov 2018 00:33:01 -0500 Received: from mail-yb1-f196.google.com ([209.85.219.196]:35068 "EHLO mail-yb1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731406AbeKVFdB (ORCPT ); Thu, 22 Nov 2018 00:33:01 -0500 Received: by mail-yb1-f196.google.com with SMTP id z2-v6so2635894ybj.2; Wed, 21 Nov 2018 10:57:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=4oYS75YM4IWbVPPXD2djKR3FyB+TT4dtQ9+y5k60DBI=; b=Jkjd48l8j8Wh9lqGjPEcIl0iW3kMjIc2agzRnAeDB3LcpGqJyGLMkkGGBThEhli4iC Tk4rZZzTmPKec7GszWY0GAciKFhdpZXlaovSeL3Xlwz4yIiN6lDC0g89D29O42/d+wDX co0hq60SMDyEY2A+vL8TsBvec9iJaNxXz0pbaC6suwlkfxhQ+PjtcG/x8PBSRV9OSrve LS3uz8s0mguyXOPtn7BlSTXfajXzh0ahdI2wUyerM9gu6gPWqtphDA7jGzH/+JjPVrNf o8c+lRWDKVoi1+A2aXtGLXiW788mYDwekqJ+nWw3FBjNVzP9Ocd0G8+kSMxaNYmIN2Bc gsZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=4oYS75YM4IWbVPPXD2djKR3FyB+TT4dtQ9+y5k60DBI=; b=SZCrnUccbp6yt8avKCOHPJrXCvspTE2siUyODBD8a0SEdWdahfwi03dwqCIBGwHwMz hE9C1YF7VSpZqj0cW/XaKisn0J3+8zR7yscwe/Q18pd2oxUWxCJfhykwI9yxIQGEDPGV pNeGR3UKH28iiS/00LE9A7q7+1usjTGi5o6pnbzQcHh1ktEunR3EBUva8UnqhlC2GZ5b /S1H/8QrE1RQuyIezul1dEzgV/mwS9oMd6xSUMsZ+7gvAF77/bXws3MYfVZjNqnT5Kym cWVD57OFfm1vFAkxoLURBwdU0kiTM5wIlInLeUSXnY1USssEKGIHss2Hb83RmTgAUbSx 4bqg== X-Gm-Message-State: AA+aEWYfikyYuCxDFTtn5XtGkeOZ6lQ1L/n+CFrpfBw6JUmNSJWF+Ga5 MF2JzqC+kjQeVUzbc0ObqmcDZ5A8ta4eFksUNBA= X-Received: by 2002:a25:ca96:: with SMTP id a144-v6mr3901961ybg.507.1542826648841; Wed, 21 Nov 2018 10:57:28 -0800 (PST) MIME-Version: 1.0 References: <000000000000d03eea0571adfe83@google.com> <000000000000a8e163057b2f2ddf@google.com> In-Reply-To: <000000000000a8e163057b2f2ddf@google.com> From: Amir Goldstein Date: Wed, 21 Nov 2018 20:57:17 +0200 Message-ID: Subject: Re: possible deadlock in mnt_want_write To: syzbot+ae82084b07d0297e566b@syzkaller.appspotmail.com, Mimi Zohar , Miklos Szeredi , Goldwyn Rodrigues Cc: linux-fsdevel , linux-kernel , syzkaller-bugs@googlegroups.com, Al Viro Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Nov 21, 2018 at 8:33 PM syzbot wrote: > > syzbot has found a reproducer for the following crash on: > > HEAD commit: 442b8cea2477 Add linux-next specific files for 20181109 > git tree: linux-next > console output: https://syzkaller.appspot.com/x/log.txt?x=11a1426d400000 > kernel config: https://syzkaller.appspot.com/x/.config?x=2f72bdb11df9fbe8 > dashboard link: https://syzkaller.appspot.com/bug?extid=ae82084b07d0297e566b > compiler: gcc (GCC) 8.0.1 20180413 (experimental) > syz repro: https://syzkaller.appspot.com/x/repro.syz?x=1632326d400000 > C reproducer: https://syzkaller.appspot.com/x/repro.c?x=17a16ed5400000 > > IMPORTANT: if you fix the bug, please add the following tag to the commit: > Reported-by: syzbot+ae82084b07d0297e566b@syzkaller.appspotmail.com > > IPv6: ADDRCONF(NETDEV_CHANGE): veth1: link becomes ready > IPv6: ADDRCONF(NETDEV_CHANGE): veth0: link becomes ready > 8021q: adding VLAN 0 to HW filter on device team0 > > ====================================================== > WARNING: possible circular locking dependency detected > 4.20.0-rc1-next-20181109+ #110 Not tainted > ------------------------------------------------------ > syz-executor599/5968 is trying to acquire lock: > 00000000e42cbf00 (sb_writers#3){.+.+}, at: sb_start_write > include/linux/fs.h:1607 [inline] > 00000000e42cbf00 (sb_writers#3){.+.+}, at: mnt_want_write+0x3f/0xc0 > fs/namespace.c:359 > > but task is already holding lock: > 00000000166f985a (&iint->mutex){+.+.}, at: process_measurement+0x438/0x1bf0 > security/integrity/ima/ima_main.c:224 > > which lock already depends on the new lock. > > > the existing dependency chain (in reverse order) is: > > -> #1 (&iint->mutex){+.+.}: > __mutex_lock_common kernel/locking/mutex.c:925 [inline] > __mutex_lock+0x166/0x16f0 kernel/locking/mutex.c:1072 > mutex_lock_nested+0x16/0x20 kernel/locking/mutex.c:1087 > process_measurement+0x438/0x1bf0 > security/integrity/ima/ima_main.c:224 > ima_file_check+0xe5/0x130 security/integrity/ima/ima_main.c:391 > do_last fs/namei.c:3422 [inline] > path_openat+0x134a/0x5150 fs/namei.c:3534 > do_filp_open+0x255/0x380 fs/namei.c:3564 > do_sys_open+0x568/0x700 fs/open.c:1063 > __do_sys_open fs/open.c:1081 [inline] > __se_sys_open fs/open.c:1076 [inline] > __x64_sys_open+0x7e/0xc0 fs/open.c:1076 > do_syscall_64+0x1b9/0x820 arch/x86/entry/common.c:290 > entry_SYSCALL_64_after_hwframe+0x49/0xbe > > -> #0 (sb_writers#3){.+.+}: > lock_acquire+0x1ed/0x520 kernel/locking/lockdep.c:3844 > percpu_down_read_preempt_disable include/linux/percpu-rwsem.h:36 > [inline] > percpu_down_read include/linux/percpu-rwsem.h:59 [inline] > __sb_start_write+0x214/0x370 fs/super.c:1564 > sb_start_write include/linux/fs.h:1607 [inline] > mnt_want_write+0x3f/0xc0 fs/namespace.c:359 > ovl_want_write+0x76/0xa0 fs/overlayfs/util.c:24 > ovl_open_maybe_copy_up+0x12c/0x190 fs/overlayfs/copy_up.c:888 > ovl_open+0xb3/0x260 fs/overlayfs/file.c:123 > do_dentry_open+0x499/0x1250 fs/open.c:771 > vfs_open fs/open.c:880 [inline] > dentry_open+0x143/0x1d0 fs/open.c:896 > ima_calc_file_hash+0x324/0x570 I suppose ima_calc_file_hash opens the file with write flags and cause overlay to try to copy up which takes mnt_want_write(). Why does IMA need to open the file with write flags? Isn't this commit supposed to prevent that: a408e4a86b36 ima: open a new file instance if no read permissions Thanks, Amir.