Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp173118rdb; Thu, 1 Feb 2024 05:36:06 -0800 (PST) X-Google-Smtp-Source: AGHT+IG9/z2T8Uz84benvZdu4nk5DoJNvovXu8qmxvKnaZ6/iZNN1l4L0G+2sheTeACzTOodCize X-Received: by 2002:ac8:57ce:0:b0:42b:f6b9:5c7b with SMTP id w14-20020ac857ce000000b0042bf6b95c7bmr1383035qta.25.1706794566450; Thu, 01 Feb 2024 05:36:06 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706794566; cv=pass; d=google.com; s=arc-20160816; b=gn/tiCSWB+8GudlOrwv6VzVHcRmyHSf2gXPukkt/wpFs2PXpJqW6Kmb8fnzpTKR8Rf o0XC9wW/YqinPJ3fdreCR1Ah1q/H+knkTWjAHMBR2WsFC5BgjMIjQehetBcPXRusfdcf dNf+D1+fhYsjwZRF4DDOgMGgT4bqmQIGm6VHVWw2h0NkPjEb9eyELas2SlCtUMOkA3p6 HtdsbSUnfs5NpyFW56KD2SRfpVRXIxh05KXKkH3zddS1CYeJv6HCxYplWznqXcs5xLob jPUMFbYQa8qoVbzPcT/Nyhtg5wAyfewvX/gCE1aVzeIhuJ5ZAmBUxLOXhPIGnSVZfO2C BIiw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=GthPnMCi8NmwEMm+mXjBY7dhtrZLw4vl23GSyrZOttw=; fh=8hxaqEOQuUO+croRdsQp8+wa9wU+IMrAEBpKu6ZvLEI=; b=CcTMSHL1HCwE4zJr051q1riMKR+Rfi54QXtt10yQ9IuLz7J3tFM6Kug8V3GsxPbUl2 0B0uJtIiC0VWxQHKFwt0XpolKhrI/DuEzjkpfkhnqgTp9XALTvg8bULqQOfyxrE7U69n Z1O7NwF9q7WzRl3RIxjqeUBvLldjQfJ5Xt8PtCGKv0VHXwVJoZzc7zPqab2fAtfgxfrX /pTBTO5ix8sXr2KyfFa3syYleA7Q2OMe5cPCfImtORY2zGktXKvTogVzr6KZYUfo5FQY yliFjB3i+c5iuOdz0NEqUnNSfo3I6sggLl1WOKgfUpz22vYabAWYqz5iG/ChDargO0Rx Ollw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=l5F2NmDG; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-48243-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-48243-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=1; AJvYcCVIBqOI6YyjANslVKosAJc2DzjOzk1kavitM4oZel4IHtf7gJpubuGfmxLoJZ9p56A8fXpBWKU+ZwyPtSOnAW+7yvE/1dne+PPcpqt3jQ== Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id u20-20020a05622a199400b0042ab7b2e65bsi5391102qtc.7.2024.02.01.05.36.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 05:36:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-48243-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=l5F2NmDG; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-48243-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-48243-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 CC2F31C22DA2 for ; Thu, 1 Feb 2024 13:35:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4E8A45CDD6; Thu, 1 Feb 2024 13:35:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="l5F2NmDG" 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 65CF053385; Thu, 1 Feb 2024 13:35:45 +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=1706794545; cv=none; b=Lyk0uM+Hc2dQP9LkSS75tQp+NCI7nzBMiqbT30Qn6xyj9IvD6DcDyheeMmUI++FBZcGT2LLqc65t+0nmbaoM49aCxsy+J3WpANygV9ZmQiCr4OT5QAeL8fHF7LdozCFJYp06hN6fsGVELTiuKNctxCCPGbP6yNFjrqICEmTeQWc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706794545; c=relaxed/simple; bh=FrMa1KXy4wo5v3lpglu0QSvWx8klxylH4PN3PwoE658=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=O4605oyuCn89LKgWxpp+dkptOaPqXPr9XOj/tIrT7dZQFdfhoDTFSBgrPwpkdZ7HZGsrutLo9o72+pXTH+E7+1Hb+/mhz3xKI2GUnnFQzvVYdmihU9QF/mSmqkwiv423Pkh0vu0yLfF9zYf0MqWKPRcj6GCCiNJoGjUA7B6Zqoc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=l5F2NmDG; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id E302FC43394; Thu, 1 Feb 2024 13:35:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706794545; bh=FrMa1KXy4wo5v3lpglu0QSvWx8klxylH4PN3PwoE658=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=l5F2NmDGkqnzwc8+ZOKOrK2ssRGf/YI+ir4DFbAVNSlthTkXWps8PJ9btyZVHeKuL WfvsuTelS4MNleFEj2U3qRWeJlYvuyyGEcKWMyOSsw22QanTdoKOdkA6PFyfJgeAHi BlaFruhJSsqpdyxPKsBAHRGev1MK6ioM6JYgl0bbqC6UcMRBf/UFxPAtLjtJCkq2a/ iO27nD6ncG17QodBAMVrZeQw+UNIpHnCnvNJf/8PJGISb0ZgPXtWlKBDHxjoq6UdV+ L0lgWVPcoiC9BYKTGK9aS6dcSZbwtTgk90VwiLpOZrk03uKJfuhsNmK4ouDz70Y0aP 5s8+8pASmcANg== Date: Thu, 1 Feb 2024 14:35:39 +0100 From: Christian Brauner To: Stefan Berger Cc: Amir Goldstein , linux-integrity@vger.kernel.org, linux-security-module@vger.kernel.org, linux-unionfs@vger.kernel.org, linux-kernel@vger.kernel.org, paul@paul-moore.com, jmorris@namei.org, serge@hallyn.com, zohar@linux.ibm.com, roberto.sassu@huawei.com, miklos@szeredi.hu Subject: Re: [PATCH 1/5] security: allow finer granularity in permitting copy-up of security xattrs Message-ID: <20240201-zierpflanzen-allgegenwart-5eb1fa243a61@brauner> References: <20240130214620.3155380-1-stefanb@linux.ibm.com> <20240130214620.3155380-2-stefanb@linux.ibm.com> <20240131-lacht-elend-536d94682370@brauner> <05fe58a1-9b2c-4c1f-80a6-4cb5094a2126@linux.ibm.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 In-Reply-To: <05fe58a1-9b2c-4c1f-80a6-4cb5094a2126@linux.ibm.com> On Wed, Jan 31, 2024 at 09:56:25AM -0500, Stefan Berger wrote: > > > On 1/31/24 09:25, Christian Brauner wrote: > > On Wed, Jan 31, 2024 at 03:25:29PM +0200, Amir Goldstein wrote: > > > On Tue, Jan 30, 2024 at 11:46 PM Stefan Berger wrote: > > > > > > > > Copying up xattrs is solely based on the security xattr name. For finer > > > > granularity add a dentry parameter to the security_inode_copy_up_xattr > > > > hook definition, allowing decisions to be based on the xattr content as > > > > well. > > > > > > > > Signed-off-by: Stefan Berger > > > > --- > > > > fs/overlayfs/copy_up.c | 2 +- > > > > include/linux/evm.h | 2 +- > > > > include/linux/lsm_hook_defs.h | 3 ++- > > > > include/linux/security.h | 4 ++-- > > > > security/integrity/evm/evm_main.c | 2 +- > > > > security/security.c | 7 ++++--- > > > > security/selinux/hooks.c | 2 +- > > > > security/smack/smack_lsm.c | 2 +- > > > > 8 files changed, 13 insertions(+), 11 deletions(-) > > > > > > > > diff --git a/fs/overlayfs/copy_up.c b/fs/overlayfs/copy_up.c > > > > index b8e25ca51016..bd9ddcefb7a7 100644 > > > > --- a/fs/overlayfs/copy_up.c > > > > +++ b/fs/overlayfs/copy_up.c > > > > @@ -114,7 +114,7 @@ int ovl_copy_xattr(struct super_block *sb, const struct path *oldpath, struct de > > > > if (ovl_is_private_xattr(sb, name)) > > > > continue; > > > > > > > > - error = security_inode_copy_up_xattr(name); > > > > + error = security_inode_copy_up_xattr(old, name); > > > > > > What do you think about: > > > > > > error = security_inode_copy_up_xattr(name, NULL, 0); > > > > > > and then later... > > > > > > error = security_inode_copy_up_xattr(name, value, size); > > > > > > I am asking because overlayfs uses mnt_idmap(path->mnt) and you > > > have used nop_mnt_idmap inside evm hook. > > > this does not look right to me? > > > > So it's relevant if they interact with xattrs that care about the > > idmapping and that's POSIX ACLs and fscaps. And only if they perform > > permission checks such as posix_acl_update_mode() or something. IOW, it > > depends on what exactly EVM is doing. > > In 2/5 we are reading the value of security.evm to look at its contents. I'm not sure what this is supposed to be telling me in relation to the original question though. :) security.evm doesn't store any {g,u}id information afaict. IOW, it shouldn't matter?