Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp1259133rbb; Mon, 26 Feb 2024 04:07:45 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVjYRW8hn/uRJ6weVYiZfeZAGHQr0os+r7JJPRpTlLbBrXiMOdF49aLOtuPe/CCeEIp93xE0TH6C42L9XinWf0zN3iq3acEd1defkNa9A== X-Google-Smtp-Source: AGHT+IEK/rTIbgxdKQnnhyC1DNwbJmxBb7UR3BE9pXKcWskWwllCm6jRhOoabShXClA4qtS3FQfQ X-Received: by 2002:a17:902:d352:b0:1dc:1ef:aeb4 with SMTP id l18-20020a170902d35200b001dc01efaeb4mr6710266plk.35.1708949265686; Mon, 26 Feb 2024 04:07:45 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708949265; cv=pass; d=google.com; s=arc-20160816; b=nd4mmDtSnIwIfjF36ifYx/kT3Pv8+8XE0grMaeOmwjvtsKvKfJA3cRt/sDxoNbZQZt NGO0qws+rR5yU+BEMvIUZ0nB2GL3VQ/252agpNY0xgSlKGxryb0DINKnsUJkORwOEApL 8L0gSbvdHFH9GcBW9v0EcxnUt0SMAVA4cCztKX8QFR+LDge8sCeXBf1gLtxP/fm9svTd K35fhM3iaKcGcKIaJeYC7fm/Gm3eIUViEWQKjco+W1cr4d/zy0o7c8ZbwETj3Qujil9u FApbeofThZKDe9eUMmIVJ+AXwK0vOx/OGoPoi7dgj/i4wPcckorqkazIY9wcPyhfbqIt zrVQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=6vaLHwGYdHSK0O6y8dTAV4fMzKnacEZWYihgEQHBUX0=; fh=dVEJ0Amfet4LBFYRC9KWSPZvnudIFTENya8Ppnrqhc8=; b=XY8upslBcxCPvaL65dX7p42j5OOCLcDQoTLBxZjvp5kFOvMA1L3FaR9SaxKNEClZuB yetLnjH82zXwmeQ2LnXs+PC5oV1/QJGBIxOoD5jbCCLy9AHE/CLu8HRXHDeEcDgEXkt4 NS60Ph4PZkt1q1XQZu74qhMhh0vffr51iaSHiTvMDDvUnnE4y3YQ6vvX/1do1Wgw8W6H YSz0423QAnKXWtx2JWjdrOGBmrXt32R8qJ5oBDBVGtU/PTRZ6J3NX2b/zVQ9ZZRNvF0s kW30Q0iiNMUKXGZQeAEk+1RWxOmN88qLaTse1mwuvj1VFI0mAkDr9GszOet5RWEBzK1I bX7A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=sina.com); spf=pass (google.com: domain of linux-kernel+bounces-81230-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81230-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id y10-20020a17090322ca00b001db5b403704si3541691plg.313.2024.02.26.04.07.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 04:07:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-81230-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=sina.com); spf=pass (google.com: domain of linux-kernel+bounces-81230-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81230-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 05077B37C11 for ; Mon, 26 Feb 2024 10:57:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3BCBD1CD30; Mon, 26 Feb 2024 10:56:03 +0000 (UTC) Received: from mail115-76.sinamail.sina.com.cn (mail115-76.sinamail.sina.com.cn [218.30.115.76]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 559CC1CAAE for ; Mon, 26 Feb 2024 10:55:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=218.30.115.76 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708944962; cv=none; b=lGGyjasc0+1XQ+u+1I9pFIZRD4tb7nFcZZ71io0ffkCIUxJvKqQQDbndPTdOj19LF+8apmTRDUZePn7iZJB6S2p+K4l9jf6xC80ppqSjyIbz1zOZJY3ZFx2O673m93vtxX6ncFOwUma0y8A8VwutGPnG4wSNHHAkJ0+HAZtWaXU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708944962; c=relaxed/simple; bh=Hp2oMV39/LFmyfumxS6WCc8rlgTTMUsnMRb84o1Z+ks=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=gwrgFSaqdCO3447TIpN5NbnzkBLXPD/N4/o7VAEJK5lNUzi7+0D65Zb3vhIJ3OOmsjIcFs4OmP6qWiBh0cwdeRMj0lYY/jZrxlHY0IW7twApQAl+Xr/FsPwvNIKhGciauTsJyV00gN+n97va/2oUh0P0glj+4sayqGffbwx+3oQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sina.com; spf=pass smtp.mailfrom=sina.com; arc=none smtp.client-ip=218.30.115.76 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sina.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sina.com X-SMAIL-HELO: localhost.localdomain Received: from unknown (HELO localhost.localdomain)([113.88.50.169]) by sina.com (10.75.12.45) with ESMTP id 65DC6E1400005AA5; Mon, 26 Feb 2024 18:55:19 +0800 (CST) X-Sender: hdanton@sina.com X-Auth-ID: hdanton@sina.com Authentication-Results: sina.com; spf=none smtp.mailfrom=hdanton@sina.com; dkim=none header.i=none; dmarc=none action=none header.from=hdanton@sina.com X-SMAIL-MID: 3718231457759 X-SMAIL-UIID: C180C45CB92344D9A4E456E3C4AA5979-20240226-185519-1 From: Hillf Danton To: Boqun Feng Cc: syzbot , almaz.alexandrovich@paragon-software.com, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, ntfs3@lists.linux.dev, Tetsuo Handa , Linus Torvalds , syzkaller-bugs@googlegroups.com Subject: Re: [syzbot] [ntfs3?] possible deadlock in ntfs_set_state (2) Date: Mon, 26 Feb 2024 18:55:06 +0800 Message-Id: <20240226105506.1398-1-hdanton@sina.com> In-Reply-To: References: <000000000000998cff06113e1d91@google.com> <20240213114151.982-1-hdanton@sina.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit On Sun, 25 Feb 2024 20:23:56 -0800 Boqun Feng wrote: > On Tue, Feb 13, 2024 at 07:41:50PM +0800, Hillf Danton wrote: > > On Mon, 12 Feb 2024 23:12:22 -0800 > > > HEAD commit: 716f4aaa7b48 Merge tag 'vfs-6.8-rc5.fixes' of git://git.ke.. > > > git tree: upstream > > > console+strace: https://syzkaller.appspot.com/x/log.txt?x=100fd062180000 > > > kernel config: https://syzkaller.appspot.com/x/.config?x=1d7c92dd8d5c7a1e > > > dashboard link: https://syzkaller.appspot.com/bug?extid=c2ada45c23d98d646118 > > > compiler: Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40 > > > syz repro: https://syzkaller.appspot.com/x/repro.syz?x=11fcbd48180000 > > > C reproducer: https://syzkaller.appspot.com/x/repro.c?x=17f6e642180000 > > > > > > ============================================ > > > WARNING: possible recursive locking detected > > > 6.8.0-rc4-syzkaller-00003-g716f4aaa7b48 #0 Not tainted > > > -------------------------------------------- > > > syz-executor354/5071 is trying to acquire lock: > > > ffff888070ee0100 (&ni->ni_lock#3){+.+.}-{3:3}, at: ntfs_set_state+0x1ff/0x6c0 fs/ntfs3/fsntfs.c:947 > > this is a mutex_lock_nested() with a subkey 0. > > > > > > > but task is already holding lock: > > > ffff888070de3c00 (&ni->ni_lock#3){+.+.}-{3:3}, at: ni_trylock fs/ntfs3/ntfs_fs.h:1141 [inline] > > > ffff888070de3c00 (&ni->ni_lock#3){+.+.}-{3:3}, at: ni_write_inode+0x1bc/0x1010 fs/ntfs3/frecord.c:3265 > > These two are try locks. > > > > > > This report looks false positive but raises the question -- what made lockedp > > This is not a false positive by lockdep locking rules, basically it > reported deadlock cases as the follow: > > mutex_trylock(A1); > mutex_trylock(A2); > mutex_lock(A1 /* or A2 */); > > Two things to notice here: 1) these two trylock()s not resulting in > real deadlock cases must be because they are on different lock > instances, 2) deadlock detectors work on lock classes, so although the > mutex_lock() above may be on a different instance (say A3), currently > there is no way for lockdep to tell that. In this case, users need to > use subkeys to tell lockdep mutex_lock() and mutex_trylock() are on > different sets of instannces (i.e. sub classes). Note that subkey == 0 > means the main class. Test non-zero subkey. #syz test https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 716f4aaa7b48 --- x/fs/ntfs3/fsntfs.c +++ y/fs/ntfs3/fsntfs.c @@ -944,7 +944,7 @@ int ntfs_set_state(struct ntfs_sb_info * if (!ni) return -EINVAL; - mutex_lock_nested(&ni->ni_lock, NTFS_INODE_MUTEX_DIRTY); + mutex_lock_nested(&ni->ni_lock, NTFS_INODE_MUTEX_NORMAL); attr = ni_find_attr(ni, NULL, NULL, ATTR_VOL_INFO, NULL, 0, NULL, &mi); if (!attr) { --