Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp434452lqo; Fri, 10 May 2024 04:42:30 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWJgpOe4WK+yGs+2D1AAdzmSmULF+LtN71ygWkDqnMFX4Y7nWdCAGRpDDzs2PwENEfZ0FddOq3PUyQzw0FbPrGjyPqT5E6eWU86uSfWUg== X-Google-Smtp-Source: AGHT+IFVtQSTcg88s2er9tqJKDNRX8dupKxkxPFxtoWhrsfs8CTWqUNREwVtnIXv8GrQqh2z1qsp X-Received: by 2002:a05:6e02:154c:b0:36c:c51b:8157 with SMTP id e9e14a558f8ab-36cc51b847dmr13474735ab.15.1715341350222; Fri, 10 May 2024 04:42:30 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715341350; cv=pass; d=google.com; s=arc-20160816; b=sCxg20DVJtR+umxh2A3lw8EnSf26TMnx0S1ITlpZcQ4L3pVcGxTmGa5gj1tvcfrYJK EiXKKALQ44Y2zcstNcHqLlIhmVL8yDsKrgXUS2B6rVFGNpsI+hV51sKT4dCfkrhA106u Q31uHihhQo9VPG/fznhQmvQYJxb3TZMtPuLdbc/R05DBC7wRrhkYWB6VjOaV5QGKbT1h ZVvInM+dhMFEN4xvREY0fDJxGgMdSpAXvaDoi6/xHqPi14klUYI+EK6ziUR1YxHg55Qm 5mUX4HpSMc6RxAuaA+cPOevglUR+9q341PdpYR9Llvt38sea3RYz16ZeF1sS3vROU3rA dTeg== 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=4RMPKH+TQNrzZ2PnA//Rwblv6FI0zyZguuY8P1A2tCY=; fh=pzlPeHzK9fejhL8R1DiWAnQL6TcebBcbTMuqyJEJMGM=; b=FERkNk0WsdnEUw/0TCii3aukXUa1dOKgiQy+RuDoGRuFHbQkkt6LtCUIzdQSK/uw2R oyrN48S5hhYzoJKXyYkCA4DXgKh/o+1+p76KHOLVJ77lMVZXY6IsnK4LGWjMa5ViauNo +ma3B+WSL+DmwLRID+gAFUFYIkiF/4VekngKL5FvIAl2+nGTvPaZU6gHWTbLJzKnyRhS NKdJKkj/xGy9+IR03zVildCiIKOT/x45FpZO7Nxla+dnEvb/k+W7j1D3gjIM8nJC4QR2 gz5yPU1eZuj5/HmCpcqYaMuUOXr9RaX5BUotHrOZ964Rn7A0EUkwHV2B0f4L6Us7Yril QYbw==; 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-175688-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-175688-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id 41be03b00d2f7-63413d72e48si3390351a12.826.2024.05.10.04.42.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 May 2024 04:42:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-175688-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=sina.com); spf=pass (google.com: domain of linux-kernel+bounces-175688-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-175688-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id F37AE2888FD for ; Fri, 10 May 2024 11:36:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 49CA216F900; Fri, 10 May 2024 11:33:42 +0000 (UTC) Received: from mail114-240.sinamail.sina.com.cn (mail114-240.sinamail.sina.com.cn [218.30.114.240]) (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 91F2616E890 for ; Fri, 10 May 2024 11:33:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=218.30.114.240 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715340821; cv=none; b=XrS80yz6sWro/vKsNZRxs+wp1w03PBCg7wcU8gyvp7KctNC5ggKONH/nfOzvHuD/CF1jtd0DTkL74IimIpTAmpJgZ059nF4vOxmZ71TzdNZIl2zIWFRkdVW+XyMQ584XTSBpHH1BKEOmbsaV/+pc2fFVOkSP05wyAC8HTKk3LsY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715340821; c=relaxed/simple; bh=kWpB3hlt/N31SYsdYtQFsLZZ1ccECn5dZ0BwMIjrR7Q=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=fcy7GkgILJ6H4gBaXy5Hk8Matf56R+/8qx9y9LbWO+WYAGi8gbFRyKhJ3CnjeRxVG9bAKQ0yT7m0550MBudq8Ea7Qwq7MLjmxztd8yL836MCLqMWo4fLV9kttX/glhMgL/K/sDvqWDc+8xQt8loZD/HJC8mxXpy6RoEtaeybCTw= 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.114.240 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)([116.24.9.62]) by sina.com (172.16.235.24) with ESMTP id 663E060600000C3E; Fri, 10 May 2024 19:33:28 +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: 73734345089264 X-SMAIL-UIID: A9B4E614A6134A958D504D06E0FA46DC-20240510-193328-1 From: Hillf Danton To: Amir Goldstein Cc: syzbot , linux-fsdevel@vger.kernel.org, Al Viro , linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com, "Rafael J. Wysocki" , Pavel Machek , linux-pm@vger.kernel.org Subject: Re: [syzbot] [kernfs?] possible deadlock in kernfs_seq_start Date: Fri, 10 May 2024 19:33:17 +0800 Message-Id: <20240510113317.2573-1-hdanton@sina.com> In-Reply-To: <20240509232613.2459-1-hdanton@sina.com> References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On Fri, 10 May 2024 07:26:13 +0800 Hillf Danton wrote: > On Thu, 9 May 2024 17:52:21 +0300 Amir Goldstein > > On Thu, May 9, 2024 at 1:49 PM Hillf Danton wrote: > > > > > > The correct locking order is > > > > > > sb_writers > > > > This is sb of overlayfs > > > > > inode lock > > > > This is real inode > > > WRT sb_writers the order > > lock inode parent > lock inode kid > > becomes > lock inode kid > sb_writers > lock inode parent > > given call trace > > > -> #2 (sb_writers#4){.+.+}-{0:0}: > > lock_acquire+0x1ed/0x550 kernel/locking/lockdep.c:5754 > > percpu_down_read include/linux/percpu-rwsem.h:51 [inline] > > __sb_start_write include/linux/fs.h:1664 [inline] > > sb_start_write+0x4d/0x1c0 include/linux/fs.h:1800 > > mnt_want_write+0x3f/0x90 fs/namespace.c:409 > > ovl_create_object+0x13b/0x370 fs/overlayfs/dir.c:629 > > lookup_open fs/namei.c:3497 [inline] > > open_last_lookups fs/namei.c:3566 [inline] > > and code snippet [1] > > if (open_flag & O_CREAT) > inode_lock(dir->d_inode); > else > inode_lock_shared(dir->d_inode); > dentry = lookup_open(nd, file, op, got_write); > > [1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/fs/namei.c?id=dccb07f2914c#n3566 JFYI simply cutting off mnt_want_write() in ovl_create_object() survived the syzpot repro [2], so acquiring sb_writers with inode locked at least in the lookup path makes trouble. [2] https://lore.kernel.org/lkml/000000000000975906061817416b@google.com/