Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp21359rdb; Wed, 7 Feb 2024 19:27:55 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCV9JuB+Dbs3MfU/W0Iiu3GtHNBFV/cDaQdy5Bq43kngJuX3v6CICJ40sjayhq8L87f5CR1r5Z1Gxp02sTZI71KI2CHMoizcB4n9hsqhxA== X-Google-Smtp-Source: AGHT+IHLDWI41Dg0S/11FiA22CGkScsUcvT1s2BERbVWEZr/9X8mH7dLE9VJOg9XnmhPxjd9C4xJ X-Received: by 2002:a05:6870:be8c:b0:218:9e23:6826 with SMTP id nx12-20020a056870be8c00b002189e236826mr10083847oab.3.1707362875662; Wed, 07 Feb 2024 19:27:55 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707362875; cv=pass; d=google.com; s=arc-20160816; b=VjWpYw7DxKr9tvfI38J8YQ3s8TnBWVsEFxjmDeB3bVWyTHAWB8FPFt6uoi5l+0uXVj qbgbmTqWt8PrrWxhEcMYNByQIfe2DkZogblgbq96SiXtiGXNccXCRbS+p2Ay5+FbFjv1 9psQaIS6bV8IPclOdeS1LDRmUfZ7KP+uun+4CDZx9z7xZSLQY33SHDSP7kOVSnHkB9Wn TRg9pZQ+5wdN4AsgR2VsUX1I6Bx0Dme/ZtAWs8EPvmY37ZNUqL8srqItjMLSmDpXJmOR kDOe08/JYkmr26Ku+ONmddBn9nxU+/0UE1lZe/QAvXHjmDuakhHV3ujHpSb1ucwYxJF3 DRCQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:references:subject:cc:to:from:content-transfer-encoding :content-disposition:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:message-id:date:dkim-signature; bh=8HbV6n5Xe+U9VQs15xw8hF94WBGgVQ6IqJUpf4t2Cj8=; fh=D+8k/+fn12nis9JU609h5h0urSyKP0/clW1ni+ChpF4=; b=gcM6pvMdp7CRB19YGuFuxWZBz/PjxwpRzO6hyPW8eUyUjEcs3O063WkNLp9d6Fptn0 Xn20/BNFYExmum+3UwWJ9g6xlix3BxAKLiCxRHd0TbaM19P3blc/O8THIrZXjC2aNBTF 2Qjw2koxGWHNyQex1TVh4q6KKjAg69J+LShj9VKWqnJFjT/HZelKHoYO1PvYhh6tYlfV EMBtfyfec3BRhjMEB6LcohWJqxIW22tzQDwul7VlE7UqaISPHGI121Yb1eRgKHPvcEil 469IzqLFp+gZcdNHrHM/ugKa5i9YNCm0hDyaTDPKlar75vji5jT45uWqvZn1Se43M8cH 7vPQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@paul-moore.com header.s=google header.b=JtHStRyA; arc=pass (i=1 spf=pass spfdomain=paul-moore.com dkim=pass dkdomain=paul-moore.com dmarc=pass fromdomain=paul-moore.com); spf=pass (google.com: domain of linux-kernel+bounces-57431-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-57431-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=paul-moore.com X-Forwarded-Encrypted: i=2; AJvYcCWIqxYHXgWvBLArVAsW8J5X7JIYHoHe5QvtSuUcTA4gB10e9rLxknh42X++tH4JMSnSaKfatzYEfnhEEScIRZvP9xYm+2DO4I7vjI9LUA== Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id z22-20020a637e16000000b005cd7c92f504si2830435pgc.481.2024.02.07.19.27.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Feb 2024 19:27:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-57431-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@paul-moore.com header.s=google header.b=JtHStRyA; arc=pass (i=1 spf=pass spfdomain=paul-moore.com dkim=pass dkdomain=paul-moore.com dmarc=pass fromdomain=paul-moore.com); spf=pass (google.com: domain of linux-kernel+bounces-57431-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-57431-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=paul-moore.com 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 46699289803 for ; Thu, 8 Feb 2024 03:27:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3691545BF9; Thu, 8 Feb 2024 03:19:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=paul-moore.com header.i=@paul-moore.com header.b="JtHStRyA" Received: from mail-qk1-f182.google.com (mail-qk1-f182.google.com [209.85.222.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B1BC3383B0 for ; Thu, 8 Feb 2024 03:18:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.182 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707362341; cv=none; b=aefGUv3GNt0RHYtbwTt4Poh8WfwKi/f1qsClz6qBAXM6CUxFklAGOeqjePnQTFAE3Ig822Z+2xRtRsrYfTdC4kIWwlhQJrhHmNzYe3YISIhzVKeYK7XP27T6o07AuS0T6krdaB5pmbZBijQpBFYtbmFCa0vgM4b9NkntPKnAoWg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707362341; c=relaxed/simple; bh=KQUeyHRjjjfkXBsIEL6L0ca2YK2iVKA66TMwHDEgJLc=; h=Date:Message-ID:MIME-Version:Content-Type:Content-Disposition: From:To:Cc:Subject:References:In-Reply-To; b=YN8sKbXyydqWWokUmmlCNIQBudhg7eOkV7afPZbZnZOZNFBvh5G21+F6vDrlvr1BTd+KgNqfHV9Im9S2T8gHyizU+5fY/7Sh5TKDgdQw0N9+TE+jNNtotFAG4Fnn4nqwFxjEBRDEoxxBECKV5iF7yJQNSRWGx7IQdZgBfh1q6a8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=paul-moore.com; spf=pass smtp.mailfrom=paul-moore.com; dkim=pass (2048-bit key) header.d=paul-moore.com header.i=@paul-moore.com header.b=JtHStRyA; arc=none smtp.client-ip=209.85.222.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=paul-moore.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=paul-moore.com Received: by mail-qk1-f182.google.com with SMTP id af79cd13be357-785388b3281so59324785a.2 for ; Wed, 07 Feb 2024 19:18:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paul-moore.com; s=google; t=1707362335; x=1707967135; darn=vger.kernel.org; h=in-reply-to:references:subject:cc:to:from:content-transfer-encoding :content-disposition:mime-version:message-id:date:from:to:cc:subject :date:message-id:reply-to; bh=8HbV6n5Xe+U9VQs15xw8hF94WBGgVQ6IqJUpf4t2Cj8=; b=JtHStRyArAV6qXTZYie2SEnksCji8DH/VPNUvL9PJbBrnCY5PT5dBlpudfwIqKPyU0 JSZXEA8+V+Yybsl7AxVJdOxWP/kGIdHaxmxpQRlkL5hDSC290Z2TfN0OkTeIs3MqMm80 tjV4sSRK/Jd/XPIqvN8ea/JmbEyE2iDQZ2HbcRA1whA2a09LnmEO3H1RrSPwgzobnJUE L9fu3EMdTdFzgy0DXJrlCk7+AvWsG6psbyQ1ZwPLZxwi6oN5Sgxpj4wZ1qLkm4t1Fs/l SDjNCq7EY+OmtNwJg72N8v+ULxjvZzpXa+dbEGXfasp2+n7zaF6I+qALktENuqaR63AL BrzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707362335; x=1707967135; h=in-reply-to:references:subject:cc:to:from:content-transfer-encoding :content-disposition:mime-version:message-id:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=8HbV6n5Xe+U9VQs15xw8hF94WBGgVQ6IqJUpf4t2Cj8=; b=VXFRHungoOGtgQHv9KAZmH/amSa1D7X5q5IOlHkWsZ0lCr27DL1/BcBTUG2SUA2rbe P5ow0fdd2cla20u5//N7ua76y4edhuHqyAU7SvcnubbkGoPTMqMMQGyu7+VJIze0Vc+i 288Ins8U9YY2TJt97M+ANbIsSX7shoIx1fTv7FAEwkGBpBujxxka3t7WHW+Ae+J7lpb8 B9/B6FPUIUUZWRJKZL2KK6+hR1KV70al678FaHe5xklf/jCsMoOFvkey5nfm9Kt4Uo3r N7TW8tcbSBKutIK9aku3uu05wdS+PseJaJkiP0YQGQwbUiDNOuueHo8+Qz9ORIttA7pb DOKA== X-Gm-Message-State: AOJu0YxzieiQSGCaMAjCNSJSsBThZy41DlX0kZi2HtAEQH9B1mAHT4xI pYer7hgXcnRfsLgaSma6adBFh6jqzYZQRzRLDki0aL9wcMsJZX0CKCKcDCf4Kg== X-Received: by 2002:ae9:f409:0:b0:785:5f32:740 with SMTP id y9-20020ae9f409000000b007855f320740mr7838921qkl.39.1707362335378; Wed, 07 Feb 2024 19:18:55 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCVtN17sT+I6NFUtc9YVAcwA/4nOIepBd/awHURKOWvyqf2iOPCRYu/xZo61LlW3PhbEnlpAugC7HczUqpDrtk7am8fPE2Qoc5nUQ/6krZlIkRXgGvestiiELaxdSTnxpfY7nBv24MWpdo9LxdvsHoRbn8snPMxGOyo4EzhJs0Ev5wJS8M+DiT8VE351BE0VKs06oc2/yjcqOnsOSLj6KjmoDDeTj8lUpEdr7an/glsFlcSjYyEL/ngVvYhDUNGKR6TUV6IAqV7mw3eDfvEXjHgxYrqHvuKKUAvkJcp/Ojp/bygVXNunH7dJpdbB0YDqnpAMJV/yaOwMtvbJ2bNW4gPy5lOQk9kgFht9tMCzxHQ3t+tzVrUa/25LWHWShk38RB2KhRiH6xgBvVDhiQpBo8fep5YrMciQ7PJpD2xyPvZTVML727aa90umcYe9FqvbFUkT819euC3EJDsTAvLMSol6Y5wbdlHEV71uop/E/lKZ1d0wKYDJWQX7med93AHe46EgaqBdlUjnY+KVJNrXqeCJAvq88LIbQj3Isw2126nGqSvPEizprgpxphO27igaPJIkrb30HQh6o2NpsUjQJkRaC7/0kQ3uWs2iQgvmvO4PU/IcsqmoWquKh5yixMCUMbg5G60hQHVfedFGwQW0T/xAcE5jXAem2FFxcjPydtdiPVMIg3Ej2QZQA8XWwdGCxV/RrgX11tPEtYE9ZvPRl+9o2HzhNz4DqR+aK4ksKhL3uH9B9I8pSDMywMm7ZZDagJnrCwoa5nZaR8rAtjyS6O4FZl7+Ui8h48ysagamh/D4PPjMshNo8+GiKPGTEs3Kws9tsJTyMh1v1rnIy4J8BqmOy1fR6DlauNkcSi7uFhxBZ71752s7HaHMNzB4pm0Xpknb8R0PGYWGzhsbX2KQ44GvfMXWEs6gdD4csl2jHSmhmAc19LlA Received: from localhost ([70.22.175.108]) by smtp.gmail.com with ESMTPSA id l5-20020ae9f005000000b00783d75b2335sm1071913qkg.11.2024.02.07.19.18.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Feb 2024 19:18:54 -0800 (PST) Date: Wed, 07 Feb 2024 22:18:54 -0500 Message-ID: <1c6b3d9d21242d63937668e8cbfb3c75@paul-moore.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 Content-Transfer-Encoding: 8bit From: Paul Moore To: Roberto Sassu , viro@zeniv.linux.org.uk, brauner@kernel.org, chuck.lever@oracle.com, jlayton@kernel.org, neilb@suse.de, kolga@netapp.com, Dai.Ngo@oracle.com, tom@talpey.com, jmorris@namei.org, serge@hallyn.com, zohar@linux.ibm.com, dmitry.kasatkin@gmail.com, eric.snowberg@oracle.com, dhowells@redhat.com, jarkko@kernel.org, stephen.smalley.work@gmail.com, eparis@parisplace.org, casey@schaufler-ca.com, shuah@kernel.org, mic@digikod.net Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, linux-security-module@vger.kernel.org, linux-integrity@vger.kernel.org, keyrings@vger.kernel.org, selinux@vger.kernel.org, linux-kselftest@vger.kernel.org, Roberto Sassu Subject: Re: [PATCH v9 23/25] evm: Make it independent from 'integrity' LSM References: <20240115181809.885385-24-roberto.sassu@huaweicloud.com> In-Reply-To: <20240115181809.885385-24-roberto.sassu@huaweicloud.com> On Jan 15, 2024 Roberto Sassu wrote: > > Define a new structure for EVM-specific metadata, called evm_iint_cache, > and embed it in the inode security blob. Introduce evm_iint_inode() to > retrieve metadata, and register evm_inode_alloc_security() for the > inode_alloc_security LSM hook, to initialize the structure (before > splitting metadata, this task was done by iint_init_always()). > > Keep the non-NULL checks after calling evm_iint_inode() except in > evm_inode_alloc_security(), to take into account inodes for which > security_inode_alloc() was not called. When using shared metadata, > obtaining a NULL pointer from integrity_iint_find() meant that the file > wasn't in the IMA policy. Now, because IMA and EVM use disjoint metadata, > the EVM status has to be stored for every inode regardless of the IMA > policy. > > Given that from now on EVM relies on its own metadata, remove the iint > parameter from evm_verifyxattr(). Also, directly retrieve the iint in > evm_verify_hmac(), called by both evm_verifyxattr() and > evm_verify_current_integrity(), since now there is no performance penalty > in retrieving EVM metadata (constant time). > > Replicate the management of the IMA_NEW_FILE flag, by introducing > evm_post_path_mknod() and evm_file_release() to respectively set and clear > the newly introduced flag EVM_NEW_FILE, at the same time IMA does. Like for > IMA, select CONFIG_SECURITY_PATH when EVM is enabled, to ensure that files > are marked as new. > > Unlike ima_post_path_mknod(), evm_post_path_mknod() cannot check if a file > must be appraised. Thus, it marks all affected files. Also, it does not > clear EVM_NEW_FILE depending on i_version, but that is not a problem > because IMA_NEW_FILE is always cleared when set in ima_check_last_writer(). > > Move the EVM-specific flag EVM_IMMUTABLE_DIGSIG to > security/integrity/evm/evm.h, since that definition is now unnecessary in > the common integrity layer. > > Finally, switch to the LSM reservation mechanism for the EVM xattr, and > consequently decrement by one the number of xattrs to allocate in > security_inode_init_security(). > > Signed-off-by: Roberto Sassu > Reviewed-by: Casey Schaufler > --- > include/linux/evm.h | 8 +-- > security/integrity/evm/Kconfig | 1 + > security/integrity/evm/evm.h | 19 +++++++ > security/integrity/evm/evm_crypto.c | 4 +- > security/integrity/evm/evm_main.c | 76 ++++++++++++++++++++------- > security/integrity/ima/ima_appraise.c | 2 +- > security/integrity/integrity.h | 1 - > security/security.c | 4 +- > 8 files changed, 83 insertions(+), 32 deletions(-) Acked-by: Paul Moore -- paul-moore.com