Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1742231pxb; Mon, 11 Oct 2021 12:05:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwbR3GOcCSAgZi04VoCWXUs144UILbm7bC2PwAFmhpnz293fCYXhd72JMTjJDDADIZWVE5S X-Received: by 2002:a50:d984:: with SMTP id w4mr43321189edj.375.1633979121976; Mon, 11 Oct 2021 12:05:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633979121; cv=none; d=google.com; s=arc-20160816; b=JluL1QWw/EEcZEOou9sXutH9XZ1a4K0xH8gntdnhsA0tGzpPfwUAdPS+ZiVHAnVM6q 6Y5y3b+OabEZ9SujmSo978Z7cBzWt48TytWI4fyV5yqVkSBfusjyOaDpCwJCJZ8duENN ShmdsBxLc37J09aAZ6bKg9PvhiZOzJOfBXsa7Dh7qTsX0QHiBn38Szufxsi3x9GLJmiw vkPLSEjloU4cpfKmWGJDyGZewLuouOwmETDEKRKbZjlXdWhYozyCNP6jKaH0DNpGms74 7l9z7lV/ryMtUs95jiq8ZTqYYUyeQHQC3GN/jS7OndmKaH3F+MG1YNAMdVrVB2C3Wcqh FDLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=KsGMVkffvVt+16cAXsVaENt6uIXPZrZp+wTANQtO1rM=; b=0JRJm2AUVq7sslav0+J9MyTjL1bERUyrE+yARoi5ASG2CmGxp2bgfV5HHe2iqTTAfF ohX0MH2NM1jLeHtjWaNhaKqwwe7isQ5TASMkNm0rupnmHjOIsuZOiinIbHNvxh7iSOAu HVuvBDBzZ3acsXT7aXYYEV3VUHb3OgDsqzEQm5nf/IV5Fou5Xxws/vClufQ4eBPpZA+1 /lmCHzmzC6/f9NIHNQYElOpQSPpxxTTdvyMO+kZyLWHqNk7+llXZ6zFX0sKZvIJIVZFx Wdpwolrz4BTC/fNQvIXTLEk0vJy3Uvr9C2efoE2Idnxw31ekVN9qUbxLy892NPUlPM2T V1NQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e11si10865259edm.12.2021.10.11.12.04.44; Mon, 11 Oct 2021 12:05:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234459AbhJKTEU (ORCPT + 99 others); Mon, 11 Oct 2021 15:04:20 -0400 Received: from smtp-out1.suse.de ([195.135.220.28]:40444 "EHLO smtp-out1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233905AbhJKTET (ORCPT ); Mon, 11 Oct 2021 15:04:19 -0400 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 50BE12214A; Mon, 11 Oct 2021 19:02:18 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 7020213BD1; Mon, 11 Oct 2021 19:02:16 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 10RjCziKZGGnMQAAMHmgww (envelope-from ); Mon, 11 Oct 2021 19:02:16 +0000 From: Davidlohr Bueso To: paul@paul-moore.com Cc: stephen.smalley.work@gmail.com, selinux@vger.kernel.org, linux-kernel@vger.kernel.org, dave@stgolabs.net, Davidlohr Bueso Subject: [PATCH] selinux: consilidate comments from inode_doinit_with_dentry wrt !dentry Date: Mon, 11 Oct 2021 12:02:04 -0700 Message-Id: <20211011190204.123934-1-dave@stgolabs.net> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Instead of having the same big comment twice for the same scenario, just have it in out_invalid. Signed-off-by: Davidlohr Bueso --- security/selinux/hooks.c | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c index e7ebd45ca345..0e0013cc7ba8 100644 --- a/security/selinux/hooks.c +++ b/security/selinux/hooks.c @@ -1502,18 +1502,8 @@ static int inode_doinit_with_dentry(struct inode *inode, struct dentry *opt_dent if (!dentry) dentry = d_find_any_alias(inode); } - if (!dentry) { - /* - * this is can be hit on boot when a file is accessed - * before the policy is loaded. When we load policy we - * may find inodes that have no dentry on the - * sbsec->isec_head list. No reason to complain as these - * will get fixed up the next time we go through - * inode_doinit with a dentry, before these inodes could - * be used again by userspace. - */ + if (!dentry) goto out_invalid; - } rc = inode_doinit_use_xattr(inode, dentry, sbsec->def_sid, &sid); @@ -1559,15 +1549,6 @@ static int inode_doinit_with_dentry(struct inode *inode, struct dentry *opt_dent if (!dentry) dentry = d_find_any_alias(inode); } - /* - * This can be hit on boot when a file is accessed - * before the policy is loaded. When we load policy we - * may find inodes that have no dentry on the - * sbsec->isec_head list. No reason to complain as - * these will get fixed up the next time we go through - * inode_doinit() with a dentry, before these inodes - * could be used again by userspace. - */ if (!dentry) goto out_invalid; rc = selinux_genfs_get_sid(dentry, sclass, @@ -1607,6 +1588,15 @@ static int inode_doinit_with_dentry(struct inode *inode, struct dentry *opt_dent return rc; out_invalid: + /* + * This is can be hit on boot when a file is accessed + * before the policy is loaded. When we load policy we + * may find inodes that have no dentry on the + * sbsec->isec_head list. No reason to complain as these + * will get fixed up the next time we go through + * inode_doinit with a dentry, before these inodes could + * be used again by userspace. + */ spin_lock(&isec->lock); if (isec->initialized == LABEL_PENDING) { isec->initialized = LABEL_INVALID; -- 2.26.2