Received: by 2002:ab2:1149:0:b0:1f3:1f8c:d0c6 with SMTP id z9csp2588619lqz; Wed, 3 Apr 2024 02:40:06 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUs/5qCteUB/rTZWxzM4hygFKkLc7/FeVkzNfGVKxE6J5xmr8KnUZa3eQbo7Afn2zjwMvFE/NSy3e0lSLFbJcGZHH7jXglDiTpZ36z6Mg== X-Google-Smtp-Source: AGHT+IHn2WbF3Md7mVXWqO2RS/6QnY+lDqs950qxK99OCXN20Cj+bXWIu1EnPfG9gTpgl2YNsk0O X-Received: by 2002:a05:6a20:d387:b0:1a3:3c5f:2ebd with SMTP id iq7-20020a056a20d38700b001a33c5f2ebdmr18967348pzb.59.1712137206100; Wed, 03 Apr 2024 02:40:06 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712137206; cv=pass; d=google.com; s=arc-20160816; b=Xvy3EzMJK+coavB7rBiUxxGIQjUUbnkbpBjnNYh1ZTCSMz9m+ZtM6hH0ZZpBQVJBCM iassfFAMRWuVMb6PvjE+NXPlUY60uKu9/XuHx1RvuWur/9Qz8QLm9DPfOgcVVXPSPCSD 89LIgjKfKS5jF44XZ1QTbv/aUYOkgdZZDjf9BXYEHPvIKuDlR3Q3jye/iX2zD9qZ24Jh Wmlr7KkAiskjENdBZOI26/xHF71Rgt/CXn6bESibEbKQhSj9MS/tSLYT6YsabN/GKPYW UMORHV0r6a0vO4iSQ4zRddydy3Sas/N7N65QM49P9+JR5tkk1CXyLuxMj2tAJmLsWuZu mqcA== 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=AUjOWrs3x/vJss3ZXibkSraTHKzz61YelNQexrlApJM=; fh=iOBV6Sp6kqyLrITGjPFbdxXY/C2sRO2SCVR0ltALOGk=; b=FOhn6efNU5iQ6OKV5iTnG6e4m4EV+xnP/hwqO6Wz7Baco4ciut7CKa5dhk1nmax/Cj ZsUKb3CEXw9JCqHBMp+YneinPIGYu0BueIS8jzPIjtYiqx1od123EKSyWTjZP2QWZhYI 98OSeb6/PJbz7YNC1duc0J3pmjB+m24fmx8sXs8ZrZ7U8ta95aQ0ZKWrItzztggznk9N AKCBVXQWHYi1IlbdojkREBxdHfikev1LFMrrNdqy3mveLRZXYtUFILbR7FMjxnSSEWt4 JWBd6rLaegckCRgp/D/NJ9Pu34sCfFP2RROZwMK3Xo0Rc6ofBOfRNZIX1TrxqTJpXuSz 9hlA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=neCZ9zKn; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-129400-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-129400-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=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 u1-20020a170902e5c100b001e0be2362fbsi13163351plf.232.2024.04.03.02.40.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Apr 2024 02:40:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-129400-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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=neCZ9zKn; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-129400-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-129400-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id B6AF1B2599E for ; Wed, 3 Apr 2024 09:12:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CF96776EEA; Wed, 3 Apr 2024 09:11:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="neCZ9zKn" 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 E93DA745C3; Wed, 3 Apr 2024 09:11: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=1712135489; cv=none; b=ElVEqhtsZNqHLGNZcJVnsGVMnOUpKRphW8meYrusN98X+A52MA/y1pJyiqH+Zbe3uSt8L4/HsRSJUxhPCKWN6JxKlm9fjNuupCTz69g41Cff5CprhJDfMt+uI0EdzO0PMBMCZwugbrTqlHBrhIqg7vX70xQLUVlUrKOy4x1A4aM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712135489; c=relaxed/simple; bh=a4SU9LeyHasQcuTuvnaPAm2576TUr887qz82fyaiNNw=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=isnBhRbQSNupHqMbm5BeIGXrNa5ajrv2nbleEOV1njF8Yv0U2LdcKZr8BRMnMHCD8V9YIQ2j/q5cc3cqrFKd53bkdMwTqeLnoghswfj7k0jSB+katC4oDCMTEiAXlpIMYSSav8RYHW47xWmOZU5PlYFfINnMd887zAK3bEEdywQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=neCZ9zKn; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 51E06C433F1; Wed, 3 Apr 2024 09:11:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712135488; bh=a4SU9LeyHasQcuTuvnaPAm2576TUr887qz82fyaiNNw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=neCZ9zKndHI2vjnoV80pGunkUnrmdHulqFhGcSD1hX1jINc24Vr+EzvQxtlEhS8n1 8QU8VuWEwBlHzPWbfLIf1tpIOPLk2s8qgoOebsjWa2Xn7zYCcNB83r2QWk10tGRGUa yYOqogWUM7jHLmSg4V/lbbVrSid6qCz/6DlefXcOhUh/GFKX6ze6WoDm3xJPkwJcDA cuzJisg6VdNTd0ujPxjAKAfbTln5l48n1qhTZ3TJdx/UKTa2w4gQl7buVXEqMYoaJ4 0C3S4Vt9VIYBk2Mi2+eunbA73z1AQlcTFM55qCBkxjfMfLdWY/iWS0ONyjqj+7Mj3o x5B4lBGqW+eBw== Date: Wed, 3 Apr 2024 11:11:15 +0200 From: Christian Brauner To: Roberto Sassu Cc: viro@zeniv.linux.org.uk, jack@suse.cz, paul@paul-moore.com, jmorris@namei.org, serge@hallyn.com, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-security-module@vger.kernel.org, linux-cifs@vger.kernel.org, pc@manguebit.com, christian@brauner.io, torvalds@linux-foundation.org, Roberto Sassu , Steve French Subject: Re: [PATCH v3] security: Place security_path_post_mknod() where the original IMA call was Message-ID: <20240403-darmentleerung-wehen-b3a655cc50b8@brauner> References: <20240403075729.2888084-1-roberto.sassu@huaweicloud.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: <20240403075729.2888084-1-roberto.sassu@huaweicloud.com> On Wed, Apr 03, 2024 at 09:57:29AM +0200, Roberto Sassu wrote: > From: Roberto Sassu > > Commit 08abce60d63f ("security: Introduce path_post_mknod hook") > introduced security_path_post_mknod(), to replace the IMA-specific call to > ima_post_path_mknod(). > > For symmetry with security_path_mknod(), security_path_post_mknod() was > called after a successful mknod operation, for any file type, rather than > only for regular files at the time there was the IMA call. > > However, as reported by VFS maintainers, successful mknod operation does > not mean that the dentry always has an inode attached to it (for example, > not for FIFOs on a SAMBA mount). > > If that condition happens, the kernel crashes when > security_path_post_mknod() attempts to verify if the inode associated to > the dentry is private. > > Move security_path_post_mknod() where the ima_post_path_mknod() call was, > which is obviously correct from IMA/EVM perspective. IMA/EVM are the only > in-kernel users, and only need to inspect regular files. > > Reported-by: Steve French > Closes: https://lore.kernel.org/linux-kernel/CAH2r5msAVzxCUHHG8VKrMPUKQHmBpE6K9_vjhgDa1uAvwx4ppw@mail.gmail.com/ > Suggested-by: Al Viro > Fixes: 08abce60d63f ("security: Introduce path_post_mknod hook") > Signed-off-by: Roberto Sassu > --- Reviewed-by: Christian Brauner