Received: by 2002:ab2:2441:0:b0:1f3:1f8c:d0c6 with SMTP id k1csp179581lqe; Thu, 4 Apr 2024 03:37:27 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVtHamLMAubcG0ZP5j6odStutbQAYLkUgtLHPhfR3lquLyMakrXprXcXvGk6vx9CsIB81J+xloZOmslWPpD6Qq0KxdJkqr2i53s/VbSIw== X-Google-Smtp-Source: AGHT+IGmx+4ibi0EodOJQeyTuetfy5LeIFwNLMtdjAZp2Esj/mjHDGqk8UNYRwiYnS1QVB68Vtx8 X-Received: by 2002:a17:906:140d:b0:a4e:109f:7b4b with SMTP id p13-20020a170906140d00b00a4e109f7b4bmr1367346ejc.41.1712227047207; Thu, 04 Apr 2024 03:37:27 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712227047; cv=pass; d=google.com; s=arc-20160816; b=p4yVksVT/IxnK2GVIoK/JzQNC5Wp0pKTATuy7tIVgJcRU6r5GQLdxTtdvDeWxhX1t5 y1JA4oNEBjYAW8yNvcmZR7Ir7W6XftjD8GTvgoOMCloi3m78phLeDHgmOuwHKCsyvC/f otYSQJ97oO0IxIJ2kSLSrpFbO1GVoW0ljWibrPTbal7+PPwL0dPv95i4JdM7h8BKFtwR x/qdClaIIL6k0PjuwDD8ciVxbSmiB5WLMGIwRUdLmoxjsnhDXEh9Kne+tpydVk48uY/h zsuJcb9x6YZMinQi3DN2AifbePQVEIVXV/QkvASc4VFAWBumU9FXomiAjLRHh9njKRWN +ccA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:in-reply-to:content-disposition:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:references :message-id:subject:cc:to:from:date:dkim-signature; bh=27elc/0JyttPz1kY3/vtLS2LPISJSolxcUu3hILMtfU=; fh=yiZaDL1IeCHrUUayVEIqweIygAmg6JG/r7EFhHKURr4=; b=Hu/ISRamjZbNrCi3DfoRQYegQ+7zqqbQOv+01jQ6hQAOi9UNqhd+8MZ1Ms9gE/giHh WK9zTa22FXwmLo2+KAhrE02GUIUVVME9os80Iw54I7prKcfiro5WYvke2+r9CFoUdTDN IdbA68y1Atwnn0AjIPdphpBlVGzJvNFSoUG/v7JrXwmvxp0Mk2WnqrYqneB10x4AKPS2 xGUtcdi3WM7UKYle1eyH0HFQCgQrWAqXyIL23EZOr0wjkMz/4kVIKMTCPdwFN+T1uvd2 h+CdicbK6tTxibuv6DrLMSlYh1snyfXK/bInV83iHcs9Q8C/3OchD3TIekxTe8M4fl1q aFcA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.org.uk header.s=zeniv-20220401 header.b=dfbD9D7B; arc=pass (i=1 dkim=pass dkdomain=linux.org.uk dmarc=pass fromdomain=zeniv.linux.org.uk); spf=pass (google.com: domain of linux-kernel+bounces-131084-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-131084-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zeniv.linux.org.uk Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id x11-20020a1709064bcb00b00a4e77933f08si3442761ejv.423.2024.04.04.03.37.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Apr 2024 03:37:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-131084-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.org.uk header.s=zeniv-20220401 header.b=dfbD9D7B; arc=pass (i=1 dkim=pass dkdomain=linux.org.uk dmarc=pass fromdomain=zeniv.linux.org.uk); spf=pass (google.com: domain of linux-kernel+bounces-131084-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-131084-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zeniv.linux.org.uk 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 am.mirrors.kernel.org (Postfix) with ESMTPS id 2FABA1F294F2 for ; Thu, 4 Apr 2024 08:11:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 835F567A15; Thu, 4 Apr 2024 08:11:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linux.org.uk header.i=@linux.org.uk header.b="dfbD9D7B" Received: from zeniv.linux.org.uk (zeniv.linux.org.uk [62.89.141.173]) (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 D9EF55CDE4; Thu, 4 Apr 2024 08:11:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=62.89.141.173 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712218291; cv=none; b=RLUHPsDPdNWVvWXttH0xWDnd/FEVQI931dDhozHt3VkALF0avAcEk0x4byV1hdrjlFzX0dnWyS7G8v5C7dDmAY5n0ggp0v0zESlb8k7IXy2x282ReRG9YKVDpWz0uRwS5G5s5x3qCBel4iIHLwwCMiqtnExmNgRBHWYRc66kI2w= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712218291; c=relaxed/simple; bh=Np/ATqeBvhdlucSIywisivuAlnZMAqOyGIALpnO61+Q=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=BshL5aBAG6FFgoTzzGvb6Eo1f24TUTjq+cQNdiKcjdbZKW4qalBwqB9BKhGC+gT9m3Ho3E/p7V68ZB79bBnYIJL+NAKz5SWeRVYjqMfyVDjP2bYlSQRuOqBGBFDf3E8ogG9skgQL5ggFqxpqLEQx0tbQi9VebrHWvzMqhfpkZfU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=zeniv.linux.org.uk; spf=none smtp.mailfrom=ftp.linux.org.uk; dkim=pass (2048-bit key) header.d=linux.org.uk header.i=@linux.org.uk header.b=dfbD9D7B; arc=none smtp.client-ip=62.89.141.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=zeniv.linux.org.uk Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=ftp.linux.org.uk DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=linux.org.uk; s=zeniv-20220401; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=27elc/0JyttPz1kY3/vtLS2LPISJSolxcUu3hILMtfU=; b=dfbD9D7BwYukgL6jr+GhbCiugb 7d5jwRK2BpCBg1hAgy8LvJPy/5FJY0aRr7s//zLeYAhu6pwquFoj4WbTN8KQnqnP7mfQhvhU5RWUK mzoe9xPN4/E3egGdvUhkEDKB12LpVU1mVkfZTes5Mr8yAj/myTpww3vyQoR8a2OsH18ZE6hjYHC7s +QA5kL/FlNz3RQSjcPcSTPq4XoQUaKrlfkt6CPu6hz/y97HLs15ZtnWjZ8HNjxYkM05SSOaVYW9X8 8E+iFK0TiZM0luE69GQmEIpIcK6vevJtVntsD3x0Lv0jk8f5gCbmvFI86eUAPO7bxPX4C+sMKPhI0 DclA6n3A==; Received: from viro by zeniv.linux.org.uk with local (Exim 4.96 #2 (Red Hat Linux)) id 1rsIBu-005Rj8-1f; Thu, 04 Apr 2024 08:11:22 +0000 Date: Thu, 4 Apr 2024 09:11:22 +0100 From: Al Viro To: Amir Goldstein Cc: syzbot , gregkh@linuxfoundation.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com, tj@kernel.org, valesini@yandex-team.ru, Christoph Hellwig , Christian Brauner , Jan Kara , Miklos Szeredi Subject: Re: [syzbot] [kernfs?] possible deadlock in kernfs_fop_llseek Message-ID: <20240404081122.GQ538574@ZenIV> References: <00000000000098f75506153551a1@google.com> <0000000000002f2066061539e54b@google.com> 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=us-ascii Content-Disposition: inline In-Reply-To: Sender: Al Viro On Thu, Apr 04, 2024 at 09:54:35AM +0300, Amir Goldstein wrote: > > In the lockdep dependency chain, overlayfs inode lock is taken > before kernfs internal of->mutex, where kernfs (sysfs) is the lower > layer of overlayfs, which is sane. > > With /sys/power/resume (and probably other files), sysfs also > behaves as a stacking filesystem, calling vfs helpers, such as > lookup_bdev() -> kern_path(), which is a behavior of a stacked > filesystem, without all the precautions that comes with behaving > as a stacked filesystem. No. This is far worse than anything stacked filesystems do - it's an arbitrary pathname resolution while holding a lock. It's not local. Just about anything (including automounts, etc.) can be happening there and it pushes the lock in question outside of *ALL* pathwalk-related locks. Pathname doesn't have to resolve to anything on overlayfs - it can just go through a symlink on it, or walk into it and traverse a bunch of .. afterwards, etc. Don't confuse that with stacking - it's not even close. You can't use that anywhere near overlayfs layers. Maybe isolate it into a separate filesystem, to be automounted on /sys/power. And make anyone playing with overlayfs with sysfs as a layer mount the damn thing on top of power/ in your overlayfs. But using that thing as a part of layer is a non-starter.