Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2830726lqp; Mon, 25 Mar 2024 10:21:35 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWqQpOufQIOABy0mQz1TweNV/zNBeKUMPz63nfMaSLIKh6Xl5eQIJctZc2GycCIAaxoy3RMUDOoiOQekpevwEPKwXJfZc3pP2fa5NTzDA== X-Google-Smtp-Source: AGHT+IFpbcauGvK4+SJ34i6HAHv1T/mZ2YtxOzQjwrC5Nq8o+SJcsfdSZhASbQqcdxWdM4esDBvI X-Received: by 2002:a05:620a:1649:b0:789:e7a0:7148 with SMTP id c9-20020a05620a164900b00789e7a07148mr8565447qko.7.1711387294815; Mon, 25 Mar 2024 10:21:34 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711387294; cv=pass; d=google.com; s=arc-20160816; b=NMPcYsE5wNwApGYzqCcLJMwfTWifCSUlcJ9V7cu2MYwf04JBuc6usJuuMAHSgfXoxn UpC/K8kZHGBa3LcBwuwwgFYZZqwPkmRqJk6s4rM73u6v7MWiVrvi3TBRv0QYjYzOUdvl s8/OK+CZ3nwsLSWzwefmOo0wNAiyUiWmkfChf6E1xgCUR9Xx60fcu+FgNCvKZgv0NGFs EF9VgrD6kHALlEU4wjagGkSM30jH3j4H3N4H/yRSIRFVA9QxM1W6P1sLuLRU1oEwoXYY uWh3gfsHfHdhr4l863fKefALOEnEXHEVC5pQXIfTOqTJlY0PTwnCgpWyJrVFY2rkrMxa gXww== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=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=H4eTF2zD/yWYDinKajRuKAqo8m341ka4o8pl7nEBr5k=; fh=uESXUw8PMOIq0xV+a80yUO+MV03+HItmnv2Yul/PHAc=; b=MAS8SAe6BHeUdMgq7o8bmDjUnoiTTIDKe8AmBVXor35Z0nlhHra+nJ8O4KLpv6G9XW SCOyGAqIH5b9dIFFwLewR3XZ1l6DZCE9j49orCn82E2ojX6rrgft6GonYJBWQZe1VPKe o0y4NiSEMeDtvPkc0xQ0+Hn31Cb2MQZjPujewelpqMj5bGgA3Q5SszNOjbtUyRVllZeB teIJNGedIsqYaYMNKYKZN/gqW4LrbgKKyRCCnOZBWEfWqbX6vfS8tvIw3Kfzh8mnaEoP LlQJl47DmQZgxVsIRhR2l3fJ+WE8zgSa7AJOCvGe3UgfAszjW2X+zzKdYyLPlJCufKj2 Owqg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=eVfZdiPM; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-117435-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-117435-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id u3-20020a05620a084300b00789f1127180si5850987qku.264.2024.03.25.10.21.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 10:21:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-117435-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=eVfZdiPM; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-117435-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-117435-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 871D71C3C298 for ; Mon, 25 Mar 2024 17:21:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 680085C8FF; Mon, 25 Mar 2024 16:06:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="eVfZdiPM" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 7A90E42058; Mon, 25 Mar 2024 16:06:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711382788; cv=none; b=sJFrT+aXUayJxyHWLd/8iTwF0pm3Mvel61zwZN0ea53WY/7NWmCpZNaXmyA8P022fnIXSoLjHfNLtFcWO8ylD/C+jDJN1Ls4166OkzBNv7xbRdUR6a+axXZn10yr4B3zPg4NZAqwXAShbIyfUR5JsI4w3TpxnMwvpU7YP2UENi8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711382788; c=relaxed/simple; bh=1PB12qwX1m7ibvKTM38Q6edyBz/Zn9xgeMYGi1UalZ8=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=VY3X/tNrP2ktAKfZ2pf9r8szIfTlUGgtVdaRWutr9ANfqwlpFdokT62L+8Aw4ZO+mjikN5BlNAUwQjxKsVepJg1Hjg1s13QO+m0re8RKjUiN78oRuPsPGAYDWIGcVoitVUWJL4EV2Th7PoRsD7okcGA7+qEhy/MitqLuI+ux/Bk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=eVfZdiPM; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id F2E5BC433F1; Mon, 25 Mar 2024 16:06:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711382788; bh=1PB12qwX1m7ibvKTM38Q6edyBz/Zn9xgeMYGi1UalZ8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=eVfZdiPMmiCdovQqrgQl0y4VTUefn0+efhOIEy23YjeklTAIaxz2QyVeYn3xIvQ8V crFQl6aO3LIaA1g91QX7ErXLxDeZBoZZcPpb9ZEz4qXLBsH4u5Q0bHOxb2wV0o/gR5 51aTA9O8xY8yr4CwNZrBczwQ79docEW2zvxtN8R4ZWDfbsA0Q2UPJij3mhKVW/ergS 6WNrdfQARy1iiVkPLXtcdvtSep9r5tzHsjPOr35+S0plnyso7q4bQC62FUtR9G1GB3 3mBjfdh5ZqoPeXbKy7zUkrxG0V4B9HtCwluV8jspZKKNYGAOttiItywQTjLvLoCjuf juf0P4dlpSPKA== Date: Mon, 25 Mar 2024 17:06:22 +0100 From: Christian Brauner To: Roberto Sassu Cc: Al Viro , Steve French , LKML , linux-fsdevel , CIFS , Paulo Alcantara , Christian Brauner , Mimi Zohar , Paul Moore , "linux-integrity@vger.kernel.org" , "linux-security-module@vger.kernel.org" Subject: Re: kernel crash in mknod Message-ID: <20240325-beugen-kraftvoll-1390fd52d59c@brauner> References: <20240324054636.GT538574@ZenIV> <3441a4a1140944f5b418b70f557bca72@huawei.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=utf-8 Content-Disposition: inline In-Reply-To: <3441a4a1140944f5b418b70f557bca72@huawei.com> On Sun, Mar 24, 2024 at 04:50:24PM +0000, Roberto Sassu wrote: > > From: Al Viro [mailto:viro@ftp.linux.org.uk] On Behalf Of Al Viro > > Sent: Sunday, March 24, 2024 6:47 AM > > On Sun, Mar 24, 2024 at 12:00:15AM -0500, Steve French wrote: > > > Anyone else seeing this kernel crash in do_mknodat (I see it with a > > > simple "mkfifo" on smb3 mount). I started seeing this in 6.9-rc (did > > > not see it in 6.8). I did not see it with the 3/12/23 mainline > > > (early in the 6.9-rc merge Window) but I do see it in the 3/22 build > > > so it looks like the regression was introduced by: > > > > FWIW, successful ->mknod() is allowed to return 0 and unhash > > dentry, rather than bothering with lookups. So commit in question > > is bogus - lack of error does *NOT* mean that you have struct inode > > existing, let alone attached to dentry. That kind of behaviour > > used to be common for network filesystems more than just for ->mknod(), > > the theory being "if somebody wants to look at it, they can bloody > > well pay the cost of lookup after dcache miss". > > > > Said that, the language in D/f/vfs.rst is vague as hell and is very easy > > to misread in direction of "you must instantiate". > > > > Thankfully, there's no counterpart with mkdir - *there* it's not just > > possible, it's inevitable in some cases for e.g. nfs. > > > > What the hell is that hook doing in non-S_IFREG cases, anyway? Move it > > up and be done with it... > > Hi Al > > thanks for the patch. Indeed, it was like that before, when instead of > an LSM hook there was an IMA call. Could you please start adding lore links into your commit messages for all messages that are sent to a mailing list? It really makes tracking down the original thread a lot easier. > However, I thought, since we were promoting it as an LSM hook, > we should be as generic possible, and support more usages than > what was needed for IMA. I'm a bit confused now why this is taking a dentry. Nothing in IMA or EVM cares about the dentry for these hooks so it really should have take an inode in the first place? And one minor other question I just realized. Why are some of the new hooks called security_path_post_mknod() when they aren't actually taking a path in contrast to say security_path_{chown,chmod,mknod,chroot,truncate}() that do.