Received: by 2002:ab2:3141:0:b0:1ed:23cc:44d1 with SMTP id i1csp283100lqg; Fri, 1 Mar 2024 05:20:34 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVmOCJlXFs/RSCoJJTqgF+PW6C30pDNZ3OG9TppG9PVQyA3qnGn9dXrOMfUZ16JOGE5Gi2wtQk0f4HgB3uO92HnyRwmFV5ICKdeqkH0Ug== X-Google-Smtp-Source: AGHT+IF7y7zUJjjbwUK7Y3orS7M7JQG94y8WrUYzy9rel7J9eIXHutu+JQXV4+nxGPY8nfT7ppcG X-Received: by 2002:a9d:7f97:0:b0:6e4:cfe3:6ce0 with SMTP id t23-20020a9d7f97000000b006e4cfe36ce0mr435685otp.5.1709299234510; Fri, 01 Mar 2024 05:20:34 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709299234; cv=pass; d=google.com; s=arc-20160816; b=B/amZTBR6+17qdkhcZvRSsBkYSBA559jauGxGgGxq6g3M1iyk5AODdbaEbwXO9dXoL Y/UtkKBJ62uxvDxewKTT9INPFiwx9IRumFa3fI2zQvPaMpeAdRtLbNcF+jruWzRz5P3S UOp1LcZy0OeIYqEQMT88zqK3Jbj74zoxknO5c8K3Ig4L1Gl+hZxDpwmH14z/4pGdhgGb JinsKInqXbWxLmRTpUUhQa2SdiYBnTjwDBWynx5hP9mi8PB7dvMBVXLlJ1jaaZ28UemC 42irJ91YMW6Y171UZrouOb+f/1HayAm1PgDQ6+3gS0156H9n0q/QDKOlmXUNH/Klm6Ne JHIQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :user-agent:content-transfer-encoding:references:in-reply-to:date:cc :to:from:subject:message-id; bh=xRLjt2ZtMD2Q1XzlAIEVwSLp295JjvW6H5VxtRoWhCs=; fh=tOqX9ZR5gcKIelh5bmeFwlM9CqhuHojfCT7jRewhquI=; b=zvPVRVTxbO88GjjI7O7BI3UYofXkjXT3KqIq8NDNC7jLqfkC+iej1KKfETpqPh9Fr9 FXcxeu9O80PMG+DLDQDWOzjcWNwmag8FZqAE21n/u79h8m8p9P4idu+cr3kRfojcs0eB 6DoUbwR9oN9OwlJpzfVtepTdWBDf79+L5XC7spJ1xbhnu0UFWXERcfLoOZaoJh+oBe9b yq11ROPyAQ6oWJdckr3WW7yaGdl1nk7sNwabMHqp7BnhFe0rAMIBEG/i4pcPSxaW9F5k kfY6584HgJb101sCWkm7x5BJYmPsaxg775yMGKlTf5HqGC0xx0HBgcU3qMsSTR8AkrPf lpvQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=huaweicloud.com); spf=pass (google.com: domain of linux-kernel+bounces-88459-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88459-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id s18-20020a632152000000b005d8e401b4a2si3481983pgm.801.2024.03.01.05.20.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 05:20:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-88459-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; arc=pass (i=1 spf=pass spfdomain=huaweicloud.com); spf=pass (google.com: domain of linux-kernel+bounces-88459-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88459-linux.lists.archive=gmail.com@vger.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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 06A822843AF for ; Fri, 1 Mar 2024 13:20:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id ED7BD6EB6B; Fri, 1 Mar 2024 13:19:38 +0000 (UTC) Received: from frasgout11.his.huawei.com (frasgout11.his.huawei.com [14.137.139.23]) (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 8867E5F483; Fri, 1 Mar 2024 13:19:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=14.137.139.23 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709299178; cv=none; b=iqx66ydRkqEKhPGhqzq4ObCeQ6MEa++wyLmFu93Bocwgo3q0QAfoX9m1zkAx7ipocwMPYTiBWHpsr10vHQy85vnx2seTTG67QOfsT1wlrUQnCZ7cMEtJbilOcIFUwj2Srfs8yVatPii0u47k2h0VqMvgd4KYHWaMMli1V6AeWG4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709299178; c=relaxed/simple; bh=xRLjt2ZtMD2Q1XzlAIEVwSLp295JjvW6H5VxtRoWhCs=; h=Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References: Content-Type:MIME-Version; b=VVz/xu4/nMnhNsDnOFsMpXaoaixfFY9kG67aroeQ+ZoUsWr3H+wi3V8zcu9fHAaL2IC29akD7I5FKrZUygj8oyjvWqFvAUu8n9iovs2jlUYf6F7R0IFYX307NUpJENygt7bbCk5Xy9wHcJZYx7SPpS/6X4ll8RkfiHFBcqvwrww= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com; spf=pass smtp.mailfrom=huaweicloud.com; arc=none smtp.client-ip=14.137.139.23 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huaweicloud.com Received: from mail.maildlp.com (unknown [172.18.186.51]) by frasgout11.his.huawei.com (SkyGuard) with ESMTP id 4TmSvw53b9z9y0Nw; Fri, 1 Mar 2024 21:03:56 +0800 (CST) Received: from mail02.huawei.com (unknown [7.182.16.27]) by mail.maildlp.com (Postfix) with ESMTP id 279D01400D2; Fri, 1 Mar 2024 21:19:32 +0800 (CST) Received: from [127.0.0.1] (unknown [10.204.63.22]) by APP2 (Coremail) with SMTP id GxC2BwDHACXT1eFlyDx6Aw--.60471S2; Fri, 01 Mar 2024 14:19:31 +0100 (CET) Message-ID: Subject: Re: [PATCH v2 14/25] evm: add support for fscaps security hooks From: Roberto Sassu To: Christian Brauner Cc: "Seth Forshee (DigitalOcean)" , 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 Date: Fri, 01 Mar 2024 14:19:11 +0100 In-Reply-To: <20240301-zucht-umfeld-9a923a7d070a@brauner> References: <20240221-idmap-fscap-refactor-v2-0-3039364623bd@kernel.org> <20240221-idmap-fscap-refactor-v2-14-3039364623bd@kernel.org> <15a69385b49c4f8626f082bc9b957132388414fb.camel@huaweicloud.com> <20240301-zucht-umfeld-9a923a7d070a@brauner> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.44.4-0ubuntu2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-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a73UjIFyTuYvjxUguHqUUUUU X-CM-SenderInfo: purev21wro2thvvxqx5xdzvxpfor3voofrz/1tbiAQAJBF1jj5rgNgACsz On Fri, 2024-03-01 at 13:54 +0100, Christian Brauner wrote: > 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 r= aw > > > xattr data and then handling them the same as other xattrs. > >=20 > > Hi Seth > >=20 > > I started looking at this patch set. > >=20 > > 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. > >=20 > > 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. > >=20 > > Looking at the code, it seems the case (if I understood correctly, > > vfs_getxattr_alloc() is still allowed). > >=20 > > To be sure that everything works, it would be really nice if you could > > also extend our test suite: > >=20 > > https://github.com/mimizohar/ima-evm-utils/blob/next-testing/tests/port= able_signatures.test > >=20 > > and > >=20 > > https://github.com/mimizohar/ima-evm-utils/blob/next-testing/tests/evm_= hmac.test > >=20 > >=20 > > The first test we would need to extend is check_cp_preserve_xattrs, > > which basically does a cp -a. We would need to set fscaps in the > > origin, copy to the destination, and see if the latter is accessible. > >=20 > > I would also extend: > >=20 > > check_tar_extract_xattrs_different_owner > > check_tar_extract_xattrs_same_owner > > check_metadata_change > > check_evm_revalidate > > check_evm_portable_sig_ima_appraisal > > check_evm_portable_sig_ima_measurement_list > >=20 > > It should not be too complicated. The purpose would be to exercise your > > code below. > >=20 > >=20 > > Regarding the second test, we would need to extend just check_evm_hmac. > >=20 > >=20 > > Just realized, before extending the tests, it would be necessary to > > modify also evmctl.c, to retrieve fscaps through the new interfaces, > > and to let users provide custom fscaps the HMAC or portable signature > > is calculated on. >=20 > While request for tests are obviously fine they should be added by the > respective experts for IMA/EVM in this case. I don't think it's > appropriate to expect Seth to do that especially because you seem to > imply that you currently don't have any tests for fscaps at all. We're > always happy to test things and if that'd be adding new IMA/EVM specific > features than it would be something to discuss but really we're > refactoring so the fact that you don't have tests we can run is not the > fault of this patchset and IMA/EVM is just a small portion of it.=20 Hi Christian I have seen this policy of adding tests in other subsystems (eBPF), which in my opinion makes sense, since you want anyway to check that you didn't break existing code. And yes, I agree that we should have better tests, and a better workflow (we are working on improving it). In this particular case, I was not asking to write a test from scratch, that should not be difficult per se, but adding additional commands. If I got it correctly, even if current tests for fscaps would have existed, they would not work anyway, since they would have been based on getting/setting the raw xattrs (as far as I know, at least for tar). Happy to try adding the tests, would appreciate your help to review if the tests are done in the correct way. Thanks Roberto