Received: by 2002:ab2:3141:0:b0:1ed:23cc:44d1 with SMTP id i1csp334768lqg; Fri, 1 Mar 2024 06:40:32 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUiMxnXKYWWh7XaFd/uWLDMj+GsUa3a0nBu1HQszKrIttWWEddeFqH1VHPh96Tv1CIk2MXQFgrRVAZ1QBsn3Fh3aQ+fH6xORBWTkbz5dQ== X-Google-Smtp-Source: AGHT+IGvHxWsxxXASpGZGENXdkxltVCR0l8HN7o8kED5nqC+ZCeRz2oIFadk1jGWZzTUrdGUbnaZ X-Received: by 2002:a17:906:361b:b0:a43:e812:fbcd with SMTP id q27-20020a170906361b00b00a43e812fbcdmr1508588ejb.28.1709304032541; Fri, 01 Mar 2024 06:40:32 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709304032; cv=pass; d=google.com; s=arc-20160816; b=D7bP2TvKgyfsgQxUJL+GxaETrSXGXq2XOvnbQxXePNTWDV4f9+0fKZh/WoDYTMSK38 Sp9qNa5RFB82gkhO0VqI8njwkCfJyiOTVORXUq7virImEKWqfxIkDe76SfWwdEX/QouH 9Z6DoAv+WnJ5S846ODo5KsSQVeci5Ls5CuEK+Owvt65/rvRuNrr2N+wRJYkJ0hQInnVz 3OGVGuCPIV8XN6G2BDNMvvdfwPjOx0/2QW6YqGQbMh/VEkf5Bm7Cclm8OJbqd55afyl1 PKlmQVsUMKDHkOyZBn2H1ch9/Yq7Eh+M65V/a2uwisGnp4x4M3sfxTfn/Ld2zgQjKE7I D1GA== 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=m1DZXV7QUx5nBhG9zX72MaFF3bkcqiIwVhx58jpA5V0=; fh=z/gHPgXJW8ahpE3V7rD2tQdhXeMUdDqE82RXvj69Y3M=; b=OsXkW+ML0LJocUNYoNHyk0ns6UKmakmVhpxzV1syn4ZFhTYxcNDs91SP9Ij1GxhGtD DPmfDYRCYGzSCewweapF2UiefVfA9PLI4hqONNiqhjaIcM+tZ2oyDUh53PXtBJxUwRmO WT4tPLWvHbRodfYnyLr0DQsczz2ZSRd7IDkaqvh/OjZ3Oq4QuC5vyK2Zv3GBPGDWP9DE n5axpwXFDb7iPTBG3yW1KDbytSaDG8786AWlLjxbVncrBq4cGCIACTqM0stUZtSxXRQN Q8p5RJ1g5iLHmIdi5O5jIVVwmAd4eotdrR+M6vjnVlLmooL9/PnNc7FwrqCs6Ta0Aope nunA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=YkTYwZHI; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-88566-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88566-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id va2-20020a17090711c200b00a444f7c377dsi1282301ejb.960.2024.03.01.06.40.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 06:40:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-88566-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=YkTYwZHI; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-88566-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88566-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 35FB21F22735 for ; Fri, 1 Mar 2024 14:40:32 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F359C3A8F8; Fri, 1 Mar 2024 14:39:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="YkTYwZHI" 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 02F3E442A; Fri, 1 Mar 2024 14:39:49 +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=1709303990; cv=none; b=WGw+yuhpsZRQGYbCWNYjZmJe0IVoqJfR8Bk803izm4apQje9HMhyBJBGYf6Nf8sn2a2oZyUBjW0IxIxFjUQPPbDF7nOd/JDXmVdU4SU8MXxQFHCZ9PZOaOMl9zjJT4dnsJXAssRta7GExRjDjBCWsgbr0Pic0wmCTLcvaVS8jTY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709303990; c=relaxed/simple; bh=hxhuvMYF4B3Dog5TINXGHY1tM8RGbN4JK+KayqqRuxo=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=W/Ga5q6nw+Gke7sHTyVYku08FrGEkcg7liixt0wduQIxopoKc0PMSAfCNHYC1BTyFNNRhTt9tV66hCiMUCPIwz6gG/OppHnnKV7XRvcvYfCGrqW0XsQdGqAlNnj/WjhJYD9O0vPX0NAZHJRyviXB0or4ma2hU8nzElg+vOwEhGo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=YkTYwZHI; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 676C9C433C7; Fri, 1 Mar 2024 14:39:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709303989; bh=hxhuvMYF4B3Dog5TINXGHY1tM8RGbN4JK+KayqqRuxo=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=YkTYwZHIPbpwdds7MCHekEZIpXeMkc994OXWtMlhE2HLlHz1HRtOqxs0YJJ4pNWKC PJMC2lMg0K4RYccYFEG5FHLGnOx6ChUfr0h9xGGQ4+cvZfhic8DrWEyFDne1BaV3Rj 3WPvSOBxcctqjKRJqbovZgzTnmPE8Fa7zlPzlx6f0BshJNkd3zjo65vobG/R22s3K7 tdFcaxj31SrPEUz6Eoijz6AedsUpSuXefn86R/846mGnFQ2g4DdyFItnw1hwssRh7O LboBYFH+1vgzL5Bold2ITr4bGuLtkAtJZ17346ntLqf72vpYtgpOS1fUgExwlgywc/ SwpC/1pignJ6g== Date: Fri, 1 Mar 2024 08:39:48 -0600 From: "Seth Forshee (DigitalOcean)" To: Roberto Sassu Cc: Christian Brauner , Serge Hallyn , Paul Moore , Eric Paris , James Morris , Alexander Viro , Jan Kara , Stephen Smalley , Ondrej Mosnacek , Casey Schaufler , Mimi Zohar , Roberto Sassu , Dmitry Kasatkin , Eric Snowberg , "Matthew Wilcox (Oracle)" , Jonathan Corbet , Miklos Szeredi , Amir Goldstein , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-security-module@vger.kernel.org, audit@vger.kernel.org, selinux@vger.kernel.org, linux-integrity@vger.kernel.org, linux-doc@vger.kernel.org, linux-unionfs@vger.kernel.org Subject: Re: [PATCH v2 14/25] evm: add support for fscaps security hooks Message-ID: References: <20240221-idmap-fscap-refactor-v2-0-3039364623bd@kernel.org> <20240221-idmap-fscap-refactor-v2-14-3039364623bd@kernel.org> <15a69385b49c4f8626f082bc9b957132388414fb.camel@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=us-ascii Content-Disposition: inline In-Reply-To: <15a69385b49c4f8626f082bc9b957132388414fb.camel@huaweicloud.com> On Fri, Mar 01, 2024 at 10:19:13AM +0100, Roberto Sassu wrote: > On Wed, 2024-02-21 at 15:24 -0600, Seth Forshee (DigitalOcean) wrote: > > Support the new fscaps security hooks by converting the vfs_caps to raw > > xattr data and then handling them the same as other xattrs. > > Hi Seth > > I started looking at this patch set. > > The first question I have is if you are also going to update libcap > (and also tar, I guess), since both deal with the raw xattr. There are no changes needed for userspace; it will still deal with raw xattrs. As I mentioned in the cover letter, capabilities tests from libcap2, libcap-ng, ltp, and xfstests all pass against this sereies. That's with no modifications to userspace. > From IMA/EVM perspective (Mimi will add on that), I guess it is > important that files with a signature/HMAC continue to be accessible > after applying this patch set. > > Looking at the code, it seems the case (if I understood correctly, > vfs_getxattr_alloc() is still allowed). So this is something that would change based on Christian's request to stop using the xattr handlers entirely for fscaps as was done for acls. I see how this would impact EVM, but we should be able to deal with it. I am a little curious now about this code in evm_calc_hmac_or_hash(): size = vfs_getxattr_alloc(&nop_mnt_idmap, dentry, xattr->name, &xattr_value, xattr_size, GFP_NOFS); if (size == -ENOMEM) { error = -ENOMEM; goto out; } if (size < 0) continue; user_space_size = vfs_getxattr(&nop_mnt_idmap, dentry, xattr->name, NULL, 0); if (user_space_size != size) pr_debug("file %s: xattr %s size mismatch (kernel: %d, user: %d)\n", dentry->d_name.name, xattr->name, size, user_space_size); Because with the current fscaps code you actually could end up getting different sizes from these two interfaces, as vfs_getxattr_alloc() reads the xattr directly from disk but vfs_getxattr() goes through cap_inode_getsecurity(), which may do conversion between v2 and v3 formats which are different sizes. Thanks, Seth