Received: by 2002:ac2:5a04:0:0:0:0:0 with SMTP id q4csp378632lfn; Wed, 2 Mar 2022 09:11:55 -0800 (PST) X-Google-Smtp-Source: ABdhPJynyMqR6sNlAJuU/+YKDO9lVDt9FZIhrtIaUVjlit4Xy3nidqsBqn4AUSY07YzCNMvP0dUF X-Received: by 2002:a17:90a:ea95:b0:1be:da4a:84de with SMTP id h21-20020a17090aea9500b001beda4a84demr818982pjz.56.1646241115465; Wed, 02 Mar 2022 09:11:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646241115; cv=none; d=google.com; s=arc-20160816; b=b+6y4Kjhj9Rub9Pb7uMyH/8uc9CHb6rGKPEwc8cYuXK2opQV4un9sn+K1ZOubqm0XF 85vRmJs09VbimvlEQgJtunEdTS7XXGWJmYmilIgwFZQ34zLegmJJDQ8LtRmCkrTWpSIo n472FpW553dOmZED8gPgU7XesAceI/qBU4q+chOtPSr9T5Eu5t+cREU1RJR+y2IawrFl 3FBETShRkE7jkOFWFaolwLa6bEzOqKpcXpzHHjAfzOQNKLEjnLjQOPup9IRuRpWGlkSP o5c0vlSnR9zy3K9aOuQwtmWYRbIFAN93HjMTx/MTRFkKGA8VHyvLDBw54xYiq0//0dMt k1Uw== 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=Qc5iWl2xTByHyOfT25EHaAjXzPkYD8oT/2nc2zL14WI=; b=Zj4ZMm7PILVq1CuCRRbCPa7QWbO+uBnTvZW4Ho5NhVVNKEJgzXDeuHWHUjpF/tU09i EqYZHq6xOdIdBizBf7TplQvVaGDSNjjSctMskiESJzQxwcjmT+Gx50smq159qe4xseTL cVCZlg/tCGbFFmmQr7QhPf+aSW3dmaA0JQJ0Fpnwd151r5W/VumGkyWr1rhK/SL9auIY ET10hlPO3dXkEzPFfX5AYQUpOCSP/3cQj0yIXRxWTHMrDZIs+QQRrje+dN2TEv+IU1s8 tFVyYVSteIrK77xpYjkAfbbggXFFqzN4vWP51f1HFEO9o+gkn5A1Bb9DmR2VGCacsOxm A5bQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x22-20020a056a00189600b004cebcdda432si16614347pfh.25.2022.03.02.09.11.38; Wed, 02 Mar 2022 09:11:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241498AbiCBLQR (ORCPT + 99 others); Wed, 2 Mar 2022 06:16:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53172 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241423AbiCBLPw (ORCPT ); Wed, 2 Mar 2022 06:15:52 -0500 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 47304A252A; Wed, 2 Mar 2022 03:14:33 -0800 (PST) Received: from fraeml714-chm.china.huawei.com (unknown [172.18.147.207]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4K7s1H10R8z67bhp; Wed, 2 Mar 2022 19:13:23 +0800 (CST) Received: from roberto-ThinkStation-P620.huawei.com (10.204.63.22) by fraeml714-chm.china.huawei.com (10.206.15.33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.21; Wed, 2 Mar 2022 12:14:30 +0100 From: Roberto Sassu To: , , , , , , , , CC: , , , , , , Roberto Sassu Subject: [PATCH v3 0/9] bpf-lsm: Extend interoperability with IMA Date: Wed, 2 Mar 2022 12:13:55 +0100 Message-ID: <20220302111404.193900-1-roberto.sassu@huawei.com> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.204.63.22] X-ClientProxiedBy: lhreml751-chm.china.huawei.com (10.201.108.201) To fraeml714-chm.china.huawei.com (10.206.15.33) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Extend the interoperability with IMA, to give wider flexibility for the implementation of integrity-focused LSMs based on eBPF. Patch 1 fixes some style issues. Patches 2-6 give the ability to eBPF-based LSMs to take advantage of the measurement capability of IMA without needing to setup a policy in IMA (those LSMs might implement the policy capability themselves). Patches 7-9 allow eBPF-based LSMs to evaluate files read by the kernel. Changelog v2: - Add better description to patch 1 (suggested by Shuah) - Recalculate digest if it is not fresh (when IMA_COLLECTED flag not set) - Move declaration of bpf_ima_file_hash() at the end (suggested by Yonghong) - Add tests to check if the digest has been recalculated - Add deny test for bpf_kernel_read_file() - Add description to tests v1: - Modify ima_file_hash() only and allow the usage of the function with the modified behavior by eBPF-based LSMs through the new function bpf_ima_file_hash() (suggested by Mimi) - Make bpf_lsm_kernel_read_file() sleepable so that bpf_ima_inode_hash() and bpf_ima_file_hash() can be called inside the implementation of eBPF-based LSMs for this hook Roberto Sassu (9): ima: Fix documentation-related warnings in ima_main.c ima: Always return a file measurement in ima_file_hash() bpf-lsm: Introduce new helper bpf_ima_file_hash() selftests/bpf: Move sample generation code to ima_test_common() selftests/bpf: Add test for bpf_ima_file_hash() selftests/bpf: Check if the digest is refreshed after a file write bpf-lsm: Make bpf_lsm_kernel_read_file() as sleepable selftests/bpf: Add test for bpf_lsm_kernel_read_file() selftests/bpf: Check that bpf_kernel_read_file() denies reading IMA policy include/uapi/linux/bpf.h | 11 ++ kernel/bpf/bpf_lsm.c | 21 +++ security/integrity/ima/ima_main.c | 57 ++++--- tools/include/uapi/linux/bpf.h | 11 ++ tools/testing/selftests/bpf/ima_setup.sh | 35 +++- .../selftests/bpf/prog_tests/test_ima.c | 149 +++++++++++++++++- tools/testing/selftests/bpf/progs/ima.c | 66 +++++++- 7 files changed, 321 insertions(+), 29 deletions(-) -- 2.32.0