From patchwork Wed Sep 22 18:52:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Henrie X-Patchwork-Id: 12511301 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_NONE,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0574CC43219 for ; Wed, 22 Sep 2021 18:53:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E89876124C for ; Wed, 22 Sep 2021 18:53:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237022AbhIVSzX (ORCPT ); Wed, 22 Sep 2021 14:55:23 -0400 Received: from mail-dm6nam10on2089.outbound.protection.outlook.com ([40.107.93.89]:5863 "EHLO NAM10-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229732AbhIVSzW (ORCPT ); Wed, 22 Sep 2021 14:55:22 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YRj8mKzgQcEOJgRaM/9or9Srz9j1hs3D8srLuA3P0CvC2lsF92UW17ONwtne8O3p4vRtEG2ZuZf6M8W70FNaqPukW3rWpx+FK1gVyiYMNNAhrQD8rzSUNkcqVOkDVUPM4B5HGH4V1wGuRm2HNlMpiho/lVF+UXNYf115yuhaKlsmUwng5Kvg+Uk2B0g5W1cNCMpZD0kiDnhNU8KO9X7MJq17bKAJKVjU2tKolTzs3M2dgrYs/dpB58tUbWjYxs4bGDvWilCmKhf67hCjPPAn7vuzxXmyP+PEbal1ShqwJRRcfVGiSO04TjhNQEjH+U/Wd8WOJQyjESuGkeelcbg+4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=aJx0bn5bjojlOxYp6On5sSFGejd5EZgnUMZmo5Q7nO0=; b=e+Y1c3vxyKTI6Pbz6jlXlbqWh/aVNRc9sM8TelV2aIPg4ntmldoGU/i3rTly4P7xmSMnTJsJ/tjM0uhLgvdOdhtiXFMdkdxFjfHl599lyX2EF0Wikx/gwcuub+gincrGrQCT5Ppce9D+XT0kbXnIJEtH96eYyeukLl1sqAw2Bi8mK3Tjdd9MbHqINHaAPnDgLDuAplL54VnfAxPmKDiyhLoeMjZ3Kjkfl3V1blB2gcHH5oo/cRaf/4w9rcBuqZ60ZfWC6TXJzvFWCUfhj+BCWVypoPSHwMZw4UGlrST4uOhVDqic6719N2xvkGYY9e/qW8CzpAzhy4UapHk5Pp9lsw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=vpitech.com; dmarc=pass action=none header.from=vpitech.com; dkim=pass header.d=vpitech.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vpitech.onmicrosoft.com; s=selector2-vpitech-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=aJx0bn5bjojlOxYp6On5sSFGejd5EZgnUMZmo5Q7nO0=; b=Xx4xARsYim5MC6u2rspx1GuA4u8i9N4XBW52RodHfo/lHpa4oAn50sMD8p6m6Z8QvNFuEVpOeAGZkjHsEzJ8ZwFFC6nDAw5UTYDbhkx4v4xh0MwXKStlqZjIm33THbIzt8nBAXOzTITmqq5QF/ZwEZvNs/FU2n9bz2l1Dmnsl50= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=vpitech.com; Received: from MW2PR07MB3980.namprd07.prod.outlook.com (2603:10b6:907:a::32) by MW4PR07MB8649.namprd07.prod.outlook.com (2603:10b6:303:102::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.16; Wed, 22 Sep 2021 18:53:49 +0000 Received: from MW2PR07MB3980.namprd07.prod.outlook.com ([fe80::cc48:9777:4f07:6014]) by MW2PR07MB3980.namprd07.prod.outlook.com ([fe80::cc48:9777:4f07:6014%4]) with mapi id 15.20.4544.015; Wed, 22 Sep 2021 18:53:49 +0000 From: Alex Henrie To: linux-integrity@vger.kernel.org, ltp@lists.linux.it, zohar@linux.ibm.com, pvorel@suse.cz, alexhenrie24@gmail.com Cc: Alex Henrie Subject: [PATCH ltp v7 1/3] IMA: Move check_policy_writable() to ima_setup.sh and rename it Date: Wed, 22 Sep 2021 12:52:30 -0600 Message-Id: <20210922185232.492879-1-alexh@vpitech.com> X-Mailer: git-send-email 2.33.0 X-ClientProxiedBy: MWHPR11CA0003.namprd11.prod.outlook.com (2603:10b6:301:1::13) To MW2PR07MB3980.namprd07.prod.outlook.com (2603:10b6:907:a::32) MIME-Version: 1.0 Received: from demeter.ad.vpitech.com (66.60.105.30) by MWHPR11CA0003.namprd11.prod.outlook.com (2603:10b6:301:1::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4544.15 via Frontend Transport; Wed, 22 Sep 2021 18:53:48 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 16af8fc4-7199-4144-6ef7-08d97dfa5013 X-MS-TrafficTypeDiagnostic: MW4PR07MB8649: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:962; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6KnvqjnvgApau6QENced1+L+6BIjK6U3+tsdSgo9htVBY/wiCEeBDbSPNw+IbkB5cUGcWNZBeXbErefqNs6fw2cQCjCiSnheIUDIGsBKfy3bQbyWcMtrtNQLczi/4aOZANfhON5+mr8jclIptwrlSmnpngw6CfNATlqJurdJeGMx/x4sfY5AsSPRU/GUue5Gmc0v0WYAZ54rnz8S3HaUCf6aF46z6aoZPz4g9/of4VvMd5E/BsuHRsU8HEl6+tl/CNietCbyYZbm6ztOuK5bi7yV58jJuQLyHJcrj2jVoLVZqWovTUkm+n/zjg1EDuMv0Zg6Qe98qw+nrGnmUySB9mJyy2ce4xGAiw6S3xmhmW5xRidExusxIageKFiJE0Q0fWqnwSMp9BGnz629vP589bTDwXRZQ5+JCfzUpr1rplxpv3ORHj3nNkui4oyuKk/6Q6K548+6ZI6BoCrmrShiCl6KcJsHig7mjnwy/XEH2NEARg319XTRQEISi/QZsci1VnKaZp4oKftmflVZhdLwYZc3wrabBrHiqpnw5odB9r+nnVUj5jP4/LZ98+EyItCq1Mk+uUs9c2JQezEve788PCyLdsexlBDNSBL71k32nC5CCEyTQ89fnX53JQmFSKcYekXLiykDwvR4tBC3UXZR9BllxwMua2mZfdzdrq10+5aFzSD1iaglIHKN4N1GDobAefhG7tn3drqKo/C44fs0rw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MW2PR07MB3980.namprd07.prod.outlook.com;PTR:;CAT:NONE;SFS:(136003)(346002)(396003)(366004)(39840400004)(376002)(1076003)(186003)(8936002)(38100700002)(86362001)(6486002)(6666004)(2906002)(4326008)(7696005)(107886003)(38350700002)(26005)(316002)(52116002)(8676002)(83380400001)(5660300002)(66476007)(956004)(2616005)(508600001)(66556008)(36756003)(66946007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: YdIYobZXH9YZEm8rjhLMWyae/t+Z6gqM9RQBrz1EYG2SMSrqHz9VC1lQfnIB5dMhkx+fEoGQ8srYnXlkM/LQoFs0JUbiKIVX870Kxv2qGM7s+hoEH/t2Aa/084VwvR1sBCIdXyesQJ3R3HttcfnTmCDd/5br2VXtnSkjYOuaC3sStDUz1eBt8jhzP0rxytqNFp1fwsJ4xAkPy4aQhHELY9htqDx0kC+wmJ/x7ESkr3e7GMxfC0ylPJ1tf+pe21cC1dbqCpsFpwXDrL31Ixl7S2IXwbFB+Pv7xDW7XZ0NESblQrNB/fJizpB2pl8khmY6nfZWweiSCo3Jn6zK0oP4gIxhslUIVn2BOubGgboZ8IUGav5miStq1JeN+Q1jVlc+vrzV7fhqmRKkKaLOzTYvQVXad4L1BbCJIgrJTwYmiTvS7F5a+2QEM2crWYjUxyPtDIfa17xr28fjV5yhm7s536HCvjfulgQ0IkbU4RmWf0ochntgzmxc6+OWq0hDpQFp2Wu73P4E/AwpYTMVZs/jnJtpC78Mum3HKK255CTCO/vzksYCs6rOa2iA+YOLlxg81Jynbc8RBzaFkZHWoGTusfTjW2t1F/APr6GY4tSnYpDKYezQg3mMC1e+vScCoEHbOUoguHhdS0nEoVXj69myy91pbgDUIyGyNl2gQeXJ0YLK3LCQ6+MP1FlpGouIrs65mx4Uey7od6JWWD5o5HxfMzITcKy7TwvDBLRmkXVaGbHzkXqPYkU2kiIr6O/xjAlHEv9T103KsJYgrJaEVUpMDP3VmtWLVvi6iz7vudqr3cAht4HXWDR3sdOaIB+HES1MD6AtRSXnvMUTVgMcxJFmPiUUi0wsLt3WORtWzGDIpvqvKgv1G/r5y1o8sM+/B5p+GJIdDhK4y5PA+C2MIT7ri3Nw1Wp0joY1q2GBbdAwYHaMpSHxQivjsLHoj3MzOXw/q/JZZT2dMBkLr1aNN+dRzxYbDAGLtdIDon4VxnLJIB66UR5Ab7SuAFZZtdBXCzWHE+DzN6SVXoO4LHX6uLvxmSYwfkVMhXYNJLOE2ju/dRdoil8A9qx9u/7c57qmfLJe7b58dqn8K4K1kHA+N7Y6GbxGCGxFAHR/reKarAjf8W56qyG9dC00ofPk2I/Ta0usXFURHq7Eiv/NnQksZC9vaHw0icDBMt5fl3wNG5ES7kqsN5GgSKs+iYc/FllzOBFLEML/ZBNh5nx4UW8AmF8MEc9Z6uLXKDWqrtBFyPwrmGNCSzisOYkhOig9PzEosRnxC0RDoODiGlsfhcW85obeuxSbARpbRTIMOtMzuV4pIR19q1+mPf4PAnNbjlrDTXX5 X-OriginatorOrg: vpitech.com X-MS-Exchange-CrossTenant-Network-Message-Id: 16af8fc4-7199-4144-6ef7-08d97dfa5013 X-MS-Exchange-CrossTenant-AuthSource: MW2PR07MB3980.namprd07.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Sep 2021 18:53:49.0051 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 130d6264-38b7-4474-a9bf-511ff1224fac X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 59q2Seoz3NaPNstytB+rdLl45RksKwbWG9MwAY0iyQuDGKpiwEYjHmat+la9cecLU1ZXl+2U49N+Wfck+fwqHw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR07MB8649 Precedence: bulk List-ID: X-Mailing-List: linux-integrity@vger.kernel.org Suggested-by: Petr Vorel Reviewed-by: Petr Vorel Signed-off-by: Alex Henrie Signed-off-by: Petr Vorel --- .../security/integrity/ima/tests/ima_policy.sh | 16 +++------------- .../security/integrity/ima/tests/ima_setup.sh | 10 ++++++++++ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/testcases/kernel/security/integrity/ima/tests/ima_policy.sh b/testcases/kernel/security/integrity/ima/tests/ima_policy.sh index 244cf081d..8924549df 100755 --- a/testcases/kernel/security/integrity/ima/tests/ima_policy.sh +++ b/testcases/kernel/security/integrity/ima/tests/ima_policy.sh @@ -11,19 +11,9 @@ TST_CNT=2 . ima_setup.sh -check_policy_writable() -{ - local err="IMA policy already loaded and kernel not configured to enable multiple writes to it (need CONFIG_IMA_WRITE_POLICY=y)" - - [ -f $IMA_POLICY ] || tst_brk TCONF "$err" - # CONFIG_IMA_READ_POLICY - echo "" 2> log > $IMA_POLICY - grep -q "Device or resource busy" log && tst_brk TCONF "$err" -} - setup() { - check_policy_writable + require_policy_writable VALID_POLICY="$TST_DATAROOT/measure.policy" [ -f $VALID_POLICY ] || tst_brk TCONF "missing $VALID_POLICY" @@ -55,7 +45,7 @@ test1() local p1 - check_policy_writable + require_policy_writable load_policy $INVALID_POLICY & p1=$! wait "$p1" if [ $? -ne 0 ]; then @@ -71,7 +61,7 @@ test2() local p1 p2 rc1 rc2 - check_policy_writable + require_policy_writable load_policy $VALID_POLICY & p1=$! load_policy $VALID_POLICY & p2=$! wait "$p1"; rc1=$? diff --git a/testcases/kernel/security/integrity/ima/tests/ima_setup.sh b/testcases/kernel/security/integrity/ima/tests/ima_setup.sh index 565f0bc3e..9c25d634d 100644 --- a/testcases/kernel/security/integrity/ima/tests/ima_setup.sh +++ b/testcases/kernel/security/integrity/ima/tests/ima_setup.sh @@ -73,6 +73,16 @@ require_policy_readable() fi } +require_policy_writable() +{ + local err="IMA policy already loaded and kernel not configured to enable multiple writes to it (need CONFIG_IMA_WRITE_POLICY=y)" + + [ -f $IMA_POLICY ] || tst_brk TCONF "$err" + # CONFIG_IMA_READ_POLICY + echo "" 2> log > $IMA_POLICY + grep -q "Device or resource busy" log && tst_brk TCONF "$err" +} + check_ima_policy_content() { local pattern="$1" From patchwork Wed Sep 22 18:52:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Henrie X-Patchwork-Id: 12511299 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 56927C4332F for ; Wed, 22 Sep 2021 18:53:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 33D9C611CA for ; Wed, 22 Sep 2021 18:53:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237093AbhIVSzV (ORCPT ); Wed, 22 Sep 2021 14:55:21 -0400 Received: from mail-bn8nam12on2059.outbound.protection.outlook.com ([40.107.237.59]:18849 "EHLO NAM12-BN8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229732AbhIVSzV (ORCPT ); Wed, 22 Sep 2021 14:55:21 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FSdoCzWKilIGI8szUboG53nCE8S81VUkLTSc8roWja1Fj49dRjlNm33EHBQoaCea9BqsvObv96cd2FJxtOMEZUJUEfKgWBe1p67FZ0gC4Ref1irQkh5yOhcnfRk46VobvTx4mErYAIz2eV3V3wI5cY5yYi9Dy628QYD7DNkOAnUjCVXQcHOIU11WcEtlT7p877k3ajAjtLmB/DGKcNqILLhon6CjIdbwY5WxJPZ2d9OaYJyp/MaRW77BDeI7r8C44roVxcLlBhS9xBcIjsOloA4SnUTZWAs0hoIqhpAddWNKtS8QGeYFKMeeDuTsuEkwvR59rrPgpT9SHcz5pl+XdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=FFVn1DKOblYdEdj04d4Cm2PlRNS0ICkUe5wxDKXg0Pw=; b=VyuG5U6Ec9Y9HZTS1uE9I7byk3yOk9Y/eAJzDPv5oSb+BsVf2MddhHPWK7RjTdSmDQ/9UlH7XBjzuA+/x/zlE9PDT0O8n+p7QQSiC+La5x/2YEJ/BSNjKWfYmZCHW+q6ARRdmuWtmdWbV56sGmCcrE3ZSNe1MRkL9x0fDGgQuo+qDlTVSuikBBiOY/eocFfkv+iOaGrvIe3dPg6mkf+QRKHKXVav1FqkC8y3/atG2yGnWeLRsukrky1S6Ctww4jCpoFWmAaxk74VtLBGYydomj8zOEN5Tx36wClWkMdBSG1qfqpZpRH6g8t1Dtlv/aAwcaFQWM2Ud06arVYcBeNUXg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=vpitech.com; dmarc=pass action=none header.from=vpitech.com; dkim=pass header.d=vpitech.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vpitech.onmicrosoft.com; s=selector2-vpitech-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=FFVn1DKOblYdEdj04d4Cm2PlRNS0ICkUe5wxDKXg0Pw=; b=W8rnFp985Cv09zC8vNZQ8B/gWPz3tWbWi+OOFseIhFUlKE+Rhuv2FYAlRtnR8ajNf/pyjZfz127v3Op9wqpJuugOB5nVWQ86tYaCcVraO7KP8C+W266GdXNSS3Eh6Ve1izb01swCC/zRQOVKnoKPiTp5wfpxGdUep9XW4VVrKNA= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=vpitech.com; Received: from MW2PR07MB3980.namprd07.prod.outlook.com (2603:10b6:907:a::32) by CO2PR07MB2583.namprd07.prod.outlook.com (2603:10b6:102:a::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4544.13; Wed, 22 Sep 2021 18:53:49 +0000 Received: from MW2PR07MB3980.namprd07.prod.outlook.com ([fe80::cc48:9777:4f07:6014]) by MW2PR07MB3980.namprd07.prod.outlook.com ([fe80::cc48:9777:4f07:6014%4]) with mapi id 15.20.4544.015; Wed, 22 Sep 2021 18:53:49 +0000 From: Alex Henrie To: linux-integrity@vger.kernel.org, ltp@lists.linux.it, zohar@linux.ibm.com, pvorel@suse.cz, alexhenrie24@gmail.com Cc: Alex Henrie Subject: [PATCH ltp v7 2/3] IMA: Move ima_check to ima_setup.sh Date: Wed, 22 Sep 2021 12:52:31 -0600 Message-Id: <20210922185232.492879-2-alexh@vpitech.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210922185232.492879-1-alexh@vpitech.com> References: <20210922185232.492879-1-alexh@vpitech.com> X-ClientProxiedBy: MWHPR11CA0003.namprd11.prod.outlook.com (2603:10b6:301:1::13) To MW2PR07MB3980.namprd07.prod.outlook.com (2603:10b6:907:a::32) MIME-Version: 1.0 Received: from demeter.ad.vpitech.com (66.60.105.30) by MWHPR11CA0003.namprd11.prod.outlook.com (2603:10b6:301:1::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4544.15 via Frontend Transport; Wed, 22 Sep 2021 18:53:49 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: cd74e3b9-b01d-45d3-2f04-08d97dfa507e X-MS-TrafficTypeDiagnostic: CO2PR07MB2583: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6430; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: tfS1skhjd+cJL6KzAnUIe5xM13q75Y50JLqDzv8f7n6r/xE462gpklml6eXJizoDrMzxMhRb7RGfC9TFqWLgdbN+cjmDjvmvwn9voZDp6BpArpjt3i+z8nZV7mTBMhsFvelgeiTTvMaMemNSCellQfIlRzuqlsauXc8gE2U3+7Fe0469IH+JcXZffjR/GFKf+9OCWT4Y/OQV51yMb+3oVLCHij5RqzRzvL9LnvqtnjseVFZIflkUOewkumY3zj1RFxRaxZEqM6EXmFVi8ZA+Nd4cPvnKy59tvTs3yxlRsJ1Px00YNip3DFs/9NJafDDAJj8WONGZKpdJpwvhRD1lLsysg3twQARR6hjQQ5cFc1VYBOSB+rGtz9ZTx75lxwVCswuLvYRkbF+ood++cLn2hCkBmXbvV/mrVb+bi91uoqcz6R24OeEO2F3sHPvKJAhENpPvT/VDrg3Al3JclbYwtZ/Y6xm6N6Qeqj+cxPaCzcnsRkQIjPxc2BlBKjOcny2dLlkHghGqgsg2xcVF8u2ePU5cRE5ZyNv5Lr2gTwBXZFgb2mEl0EslqnESvSDzJt1o1pxreYbgYZQUYSL34yLW+QLMrcFHDWtce/Uyabw5X6Z+rmSjH5OhPI5MEi8H3RfFz/hREOhNZscS2oCbgKhcXS5w9G0vXjCysbzxJa9DfY2P36jhnKqOWk+fslBPYPc5hY32fFwnt2GBMbHDkma7DA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MW2PR07MB3980.namprd07.prod.outlook.com;PTR:;CAT:NONE;SFS:(39840400004)(346002)(396003)(376002)(136003)(366004)(66556008)(66946007)(66476007)(38100700002)(316002)(956004)(2616005)(6486002)(36756003)(8676002)(107886003)(26005)(8936002)(508600001)(86362001)(2906002)(7696005)(6666004)(52116002)(4326008)(1076003)(83380400001)(38350700002)(186003)(5660300002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: QUE7OrTGC3HDRxpCw/7shjbyJZztanE2Vhrb80/uDNzBTS1wOpKl7ib7UyH5YiMA33wUsAvdqhYIxYZtTIHKzkHikWa4sjCqz3mabeP9Kfj3GPlw237Q8+oWNvS2//4oxB6Hx9dT8RjmxJvKjs4bCyhoWaix9/9taTSXDBewdgmAiTZE1G9aU7g7WDmz1VGVBw+f2ijp2NBX3oc9/t6rKnCjwux1AUiU/7tz8oWizn9pZpocJiSxnbbvsFY42XgaEeOSuJphRyRxFFabR0HNy9PcC9fEeQ2PoMli5/ALMvkaX51phcC2sibi0wvwkR7lWkYWkM3ueq+QRTFsbHImIpsWUJy/gD/A5FO/QTDu44zZ89CRZTpiA6g8xdOFKlwGO368MCTXAk21gLWBPMN6v3VtaggZ4DcfTHGrqvhQYPVWyCp5mX3hi1fZS3YNuHRqUSoLptbTxUwCaKFPA8l2IIZVaRS1gepeysLuR4tGd14LCe4PI/gkewFtV84/lhK2ikFKJ4CwmpSGML9Y7GTztvn77YtxCOOCnYerYoEJo2a80JkRKiNybidGkGNGa5vtjkN/H7G0ITmV/ZUgP4aKRNm61WbUKQyjB8P4q6VJ9IY7bgIuwtrMDCqbq8BtyPtnQUoZZu4PyweJT9KLWtyOdyZvHrZwzNgNW34a2Y8EnvOQ7b6Yrw3fRl32qaH9y0/o+Rr3WI7o9OHQDmTsOCDDH7FPYgkXiBMimXB4k30dOkNh77NO3rwasune+IGIBat3mbIxgNyWSqz+ri4Z/amIjEFhzAClz2ScPDrG7pK1QkNXXBOJwScHNqCpqh6j8NvIxNyBOrz+bIv4vwJGy15wTxs0buwDNpMCHy9ib6ooJrtfMTsMuH8vYPw9sZWbY8Maz8lcQdouU0Acf4DTuciXYzYn90bt6cahkc9C10Tesrs3VVht3czIz5xyLIKNt4AP1gyrifZ5k0bchKartRt28HDnIyru6F+mVu9VMeiXfBCxfn2O2irUC8ROkPVTrfLDUKgWA4ccXPfbcTsdB6KqW/VENjNymoEhof8WtCBETEZIFaKwUi8+tsyL8ohpvdrY3soVSeBBikQmB7b/t8+wL7HNVuNyDTSzGsvbRm1ffDJmqbTxXd0ATWVnIS+jE7XaZprZf3uYNWfz0ytk8VV+DplRgx1bWh1sctdMnmrBigQXZQtEAI94J21MgLIe3qaT4s5OaAjOnihRdf9zVH66gfbpb4Jf1fSWU6j1H0yiHNCdvBU36Vq/5i1OIGXreKB2VOBxs7psWGGsmloICT7UR+5cn7ElfloEihcmqZDMwESMe0y8+47/LCBNlmxjor7X X-OriginatorOrg: vpitech.com X-MS-Exchange-CrossTenant-Network-Message-Id: cd74e3b9-b01d-45d3-2f04-08d97dfa507e X-MS-Exchange-CrossTenant-AuthSource: MW2PR07MB3980.namprd07.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Sep 2021 18:53:49.6458 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 130d6264-38b7-4474-a9bf-511ff1224fac X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: TKvVz3uA0QsFgwpsJBVIcutlB/Mm+fJnw7pOQ0dmsbQUH1XYp3fQp9iDsu/qgPfVghPQO/m5fyZgUnGp2rFeIQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO2PR07MB2583 Precedence: bulk List-ID: X-Mailing-List: linux-integrity@vger.kernel.org Reviewed-by: Petr Vorel Signed-off-by: Alex Henrie [ pvorel: add test_file parameter to ima_check(), keep $TEST_FILE in ima_measurements.sh ] Signed-off-by: Petr Vorel --- .../integrity/ima/tests/ima_measurements.sh | 31 ++----------------- .../security/integrity/ima/tests/ima_setup.sh | 28 +++++++++++++++++ 2 files changed, 30 insertions(+), 29 deletions(-) diff --git a/testcases/kernel/security/integrity/ima/tests/ima_measurements.sh b/testcases/kernel/security/integrity/ima/tests/ima_measurements.sh index ef8577d30..a83c416de 100755 --- a/testcases/kernel/security/integrity/ima/tests/ima_measurements.sh +++ b/testcases/kernel/security/integrity/ima/tests/ima_measurements.sh @@ -21,33 +21,6 @@ setup() [ -f "$IMA_POLICY" ] || tst_res TINFO "not using default policy" } -ima_check() -{ - local algorithm digest expected_digest line tmp - - # need to read file to get updated $ASCII_MEASUREMENTS - cat $TEST_FILE > /dev/null - - line="$(grep $TEST_FILE $ASCII_MEASUREMENTS | tail -1)" - - if tmp=$(get_algorithm_digest "$line"); then - algorithm=$(echo "$tmp" | cut -d'|' -f1) - digest=$(echo "$tmp" | cut -d'|' -f2) - else - tst_res TBROK "failed to get algorithm/digest for '$TEST_FILE': $tmp" - fi - - tst_res TINFO "computing digest for $algorithm algorithm" - expected_digest="$(compute_digest $algorithm $TEST_FILE)" || \ - tst_brk TCONF "cannot compute digest for $algorithm algorithm" - - if [ "$digest" = "$expected_digest" ]; then - tst_res TPASS "correct digest found" - else - tst_res TFAIL "digest not found" - fi -} - check_iversion_support() { local device mount fs @@ -83,7 +56,7 @@ test1() { tst_res TINFO "verify adding record to the IMA measurement list" ROD echo "$(date) this is a test file" \> $TEST_FILE - ima_check + ima_check $TEST_FILE } test2() @@ -92,7 +65,7 @@ test2() tst_res TINFO "verify updating record in the IMA measurement list" check_iversion_support || return ROD echo "$(date) modified file" \> $TEST_FILE - ima_check + ima_check $TEST_FILE } test3() diff --git a/testcases/kernel/security/integrity/ima/tests/ima_setup.sh b/testcases/kernel/security/integrity/ima/tests/ima_setup.sh index 9c25d634d..af7f3a5f5 100644 --- a/testcases/kernel/security/integrity/ima/tests/ima_setup.sh +++ b/testcases/kernel/security/integrity/ima/tests/ima_setup.sh @@ -279,6 +279,34 @@ get_algorithm_digest() echo "$algorithm|$digest" } +ima_check() +{ + local test_file="$1" + local algorithm digest expected_digest line tmp + + # need to read file to get updated $ASCII_MEASUREMENTS + cat $test_file > /dev/null + + line="$(grep $test_file $ASCII_MEASUREMENTS | tail -1)" + + if tmp=$(get_algorithm_digest "$line"); then + algorithm=$(echo "$tmp" | cut -d'|' -f1) + digest=$(echo "$tmp" | cut -d'|' -f2) + else + tst_res TBROK "failed to get algorithm/digest for '$test_file': $tmp" + fi + + tst_res TINFO "computing digest for $algorithm algorithm" + expected_digest="$(compute_digest $algorithm $test_file)" || \ + tst_brk TCONF "cannot compute digest for $algorithm algorithm" + + if [ "$digest" = "$expected_digest" ]; then + tst_res TPASS "correct digest found" + else + tst_res TFAIL "digest not found" + fi +} + # check_evmctl REQUIRED_TPM_VERSION # return: 0: evmctl is new enough, 1: version older than required (or version < v0.9) check_evmctl() From patchwork Wed Sep 22 18:52:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Henrie X-Patchwork-Id: 12511297 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 54693C433EF for ; Wed, 22 Sep 2021 18:53:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0CE3D61107 for ; Wed, 22 Sep 2021 18:53:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237116AbhIVSzW (ORCPT ); Wed, 22 Sep 2021 14:55:22 -0400 Received: from mail-bn8nam12on2059.outbound.protection.outlook.com ([40.107.237.59]:18849 "EHLO NAM12-BN8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S237022AbhIVSzW (ORCPT ); Wed, 22 Sep 2021 14:55:22 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=diDgG5w+rQrp3NF4c/ac7huU4NvhnAS7FItDPxIkDYmbG0FvnTG04PqQZssgVTUL8UD0vzDPMZ++cBkzpKlVYvZS+NotN+NPNLWtqNOpM4BQHVjxzSi7SAfUJMLWu+My5v/tA6vVKI39PK3K0CLGueSoF5YAosb470J0EjNeyZp1nPddFX13smUPxHKlDhiRWq4FDHPx/f+8LKgAPUrFvzIsTxFCre8aRUWKag91v1hQ6skS21uql7DtZKeNsDFQBLjNELsDliw8yZGzDN4SxixQqSe7Hn+IV7bcEaD6rdEC41CVW0scCyuZHgk7aLGdxYkXEf/GBHScKtvxFQT32g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=oh8oFmUd3CL+XgW5TtKLjwn2JsiE9huahvp1HFni/BM=; b=H5ug2t5bZOnKTypisCcZrloUL1lwA3PsQQVPd2TI4FUnCFV59x1LAIptTbrbiy/PHWOH0lkqe41exZlP0v4GagpBKe+NnBjJX46dJ70wp14OAawJZ3zoqu9Ej3g59Q2DqRPG6ROceyB8jfnRVRL8JbjARLz8X9KqJiaDck+N1fHwx1ipCyCEsATnXc1yt3nTt69NNrYSJioBALX2QITHKEe7CQDVk+4L5ADyG9Qz++c1/hOYKdpHwsVLXOY5xiAISgChTaqJe0rFdW/fKaV1b+tknmLd2xrYlVmOMO0hKcL0QXqyUBNZ9K9vhHprHPdz9MFAkSE7WfYyfUG4VJgYUQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=vpitech.com; dmarc=pass action=none header.from=vpitech.com; dkim=pass header.d=vpitech.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vpitech.onmicrosoft.com; s=selector2-vpitech-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=oh8oFmUd3CL+XgW5TtKLjwn2JsiE9huahvp1HFni/BM=; b=NQXqj3NSiytMKAzluV8MMKMspsOzurJ7E3y2+6JpeqinFGIFQ5KZcGn8GaLH2w84z7KHzjLfIwX6kcDJQnWXYr43k5ZZFDVLUUCwmle/clt6qPE0+f3txjRwLpbSlL6WyvixY+BF3hOAAkqrdY5T552T7Bj0U0emcQAX1FB11tI= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=vpitech.com; Received: from MW2PR07MB3980.namprd07.prod.outlook.com (2603:10b6:907:a::32) by CO2PR07MB2583.namprd07.prod.outlook.com (2603:10b6:102:a::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4544.13; Wed, 22 Sep 2021 18:53:50 +0000 Received: from MW2PR07MB3980.namprd07.prod.outlook.com ([fe80::cc48:9777:4f07:6014]) by MW2PR07MB3980.namprd07.prod.outlook.com ([fe80::cc48:9777:4f07:6014%4]) with mapi id 15.20.4544.015; Wed, 22 Sep 2021 18:53:50 +0000 From: Alex Henrie To: linux-integrity@vger.kernel.org, ltp@lists.linux.it, zohar@linux.ibm.com, pvorel@suse.cz, alexhenrie24@gmail.com Cc: Alex Henrie Subject: [PATCH ltp v7 3/3] IMA: Add tests for uid, gid, fowner, and fgroup options Date: Wed, 22 Sep 2021 12:52:32 -0600 Message-Id: <20210922185232.492879-3-alexh@vpitech.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210922185232.492879-1-alexh@vpitech.com> References: <20210922185232.492879-1-alexh@vpitech.com> X-ClientProxiedBy: MWHPR11CA0003.namprd11.prod.outlook.com (2603:10b6:301:1::13) To MW2PR07MB3980.namprd07.prod.outlook.com (2603:10b6:907:a::32) MIME-Version: 1.0 Received: from demeter.ad.vpitech.com (66.60.105.30) by MWHPR11CA0003.namprd11.prod.outlook.com (2603:10b6:301:1::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4544.15 via Frontend Transport; Wed, 22 Sep 2021 18:53:49 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7d8d91ff-1b63-4df7-fd18-08d97dfa50d9 X-MS-TrafficTypeDiagnostic: CO2PR07MB2583: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:407; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 1GjR5QfPwH8jryZmh5a7oo467AluvD2KrZE1SJXR/0+DR4VJzaN5/wu07ZdPDqJwkP+LRFFqvb/S9euF9jZDV0e2+54w7ZbgNUP96IOXeGPLGnLD4OU9OdGMZgTfl754YlQRLpNn1cxFtZ9b4U9bsoHR1sSrBTS5ZG8WL0+qU/n/rWXMdvds08AdC5bOxaeOesd5ybLlmS6zMCls4oUAbMDmf41SpHIVD0L1wqypvZHjbyALi1TycnLjMftMVITQBsxm9AkmGPRnKMwvFRhfXYueW7Y0y8Dhm4fIBRjQwLYYjXrN86kWDy+m/Qx44c5Op/oWSmsqVf6WF0htt4r0b0iDnpaTyrshHkaNZKllG7KUKBQAyR0uOjTnaLqzy2MGS35tb58rzz+3O/5/m6O6yCtNMX4MLETYms8mI2sNGjbouKcPnNrX0Jaxdf4wNO7hDtkddt6f1rvJRt/rpOYah4ofnLRYg3y0tCBp/V73kgznnpHvhId9qnnt2pN+RdFGDuguiJwNykR4Z+27y2LQbHYQ8wHk8sVbaJx+OXijYQ+LrnMPby9g5dmpPK1RQ0/Ai0k2fCzNtbKWmBZz/PM+ZGfTs5Gy9W8KQCMZfppAepNUPwZZz+rfHn16gFDzd2s3AUGtk4wcBgacn4kKFXqvlI4oudUnTqtWsn+zxbCMEj8amkD6Yre4O6kWNfHKlNwyR9bGycPfIg63W9Kt6Kw6lA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MW2PR07MB3980.namprd07.prod.outlook.com;PTR:;CAT:NONE;SFS:(39840400004)(346002)(396003)(376002)(136003)(366004)(66556008)(66946007)(66476007)(38100700002)(316002)(956004)(2616005)(6486002)(36756003)(8676002)(107886003)(26005)(8936002)(508600001)(86362001)(2906002)(7696005)(6666004)(52116002)(4326008)(1076003)(83380400001)(38350700002)(186003)(5660300002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: OpiHUth3sI0SsadPJ9NgZA7uGZLaPmz87tedD8tzQ7jur6Os916ws9I5uiGkwcmZJPddkqRqsxzgNSc2VmpTkuOY6+z1/8JrJOo7uGn1r1Bn+JI+FPOFEB+d6QuiCW++u2eAB/RoI5BXPocj4xSamuy1nifp2IXNF6/QdwbAlo8tfppH1ZhvaeOzOu85ePCtVpllu7L3FjQER0dsJSJRI485MNWTZwW34tn0rN3JSa/2DnJp3tV8SnVfJM32f8vzzeu8abKgEWh7BoEXHChhVIQu7FZSeAwstGV1mmqppyHqWnUPtdDtsyTZopoWRMxTRLGI0UsjLt59N4/lBFC/n1LbJWCTkcE1kov6ejTe0mW7E9K8/9MIOY0mho5jaC9iVHEd9DUafZdQnGWAOncURm2kcGkD+WtafPYNeBG6oRJjmBnIv0cdgHX9oYYwvL6OWAuEyArnkmgSRhV96QlVAHsbn2Cyq1Kzz9JZHydLl66kzy+0x0QU/p4v4VQ65XpWE9C93RadbWQmAFwYIXWh3QxTmbRrBEhMU3jCGDE4F/mniJ7kZK/zoLMC6xm7wvKt9q1J7ISXtRrZDvEf+jluez0D7A3rkDBOfRp65zxQ40M/qFGXKISAPbOlQxF/Tl99hb6q9sK8Ncg8dSbs5JAUTyQ5FSAaUa9IBX1AaBkwhvniyIyIOVBuf4iWZoTKF7RTQ4k94PyhXpV5qJjrPEp00wnsAAI8mzISQTriYEc74MNVw9xu+LasAMds8naXsD5LzTAioNIx38iS0IQQyaKXS8AOkkltNVaBZR1amIZI7PU46oUTY9I2lw/JLyBlDNXS12VLgJSfnTrpE7iNmG4P9vXjNX6K4yBaaJIUer6NrlfcQHjjYOFsYR3/QvrmfU7FyCjWhmdf5b8hU7tpFSMELp53aNGhRnjyOIfCfqNtanYs846QXv0nLb6IQyp5va8i9mamwgF3C+ywEKePaFNNcN7McUZr1rNMm5KRJFbuT2LYOpD06Qbmys2GBkcxh3hRF/zGVty//l332+nsnqIs6CinAefFgK+SC+5ewegHGTH7wnv56vhDxk4+tKUc4UbZbTc6+xV3D7iCZZGO85aOxyVBOtTdJyBNJgYzxJi3N3Kv6E80KezhZJKDWs/9UmuvG/ZivBLtvUdPZGpGNPm7yUMQqUE4PwhBCE6/B9u5sJP2lo0yI9HNM8dZCxTMRQ28AZ1JqAE86YKk983t0XAOFAOPsjTcwqsCXUWyGeKfWy0qYP4hkt43OoiMgVz0tnDDt1Qza/K7LvStPr1bsThIort7uv/maxTuKQlabUdtooGZ4ZIsK1DS5pfgkIKsq85S X-OriginatorOrg: vpitech.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7d8d91ff-1b63-4df7-fd18-08d97dfa50d9 X-MS-Exchange-CrossTenant-AuthSource: MW2PR07MB3980.namprd07.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Sep 2021 18:53:50.2504 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 130d6264-38b7-4474-a9bf-511ff1224fac X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: hR/foyA6mOisOO5voDt0XQLz0/i76VtHA+nMWM3jz7HmoM2NBSzMk2hBz8WniwO36oqvSrQDIqbn3PB3DhlKCA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO2PR07MB2583 Precedence: bulk List-ID: X-Mailing-List: linux-integrity@vger.kernel.org Requires "ima: add gid support". Reviewed-by: Petr Vorel Signed-off-by: Alex Henrie [ pvorel: add test_file parameter to ima_check(), add verify_measurement() (DRY) ] Signed-off-by: Petr Vorel --- v7: Change "Copyright (c) 2021 VPI Technology" to "Copyright (c) 2021 VPI Engineering" per internal feedback from VPI --- runtest/ima | 1 + .../integrity/ima/tests/ima_conditionals.sh | 62 +++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100755 testcases/kernel/security/integrity/ima/tests/ima_conditionals.sh diff --git a/runtest/ima b/runtest/ima index 29caa034a..01942eefa 100644 --- a/runtest/ima +++ b/runtest/ima @@ -6,4 +6,5 @@ ima_violations ima_violations.sh ima_keys ima_keys.sh ima_kexec ima_kexec.sh ima_selinux ima_selinux.sh +ima_conditionals ima_conditionals.sh evm_overlay evm_overlay.sh diff --git a/testcases/kernel/security/integrity/ima/tests/ima_conditionals.sh b/testcases/kernel/security/integrity/ima/tests/ima_conditionals.sh new file mode 100755 index 000000000..b76f7cb5a --- /dev/null +++ b/testcases/kernel/security/integrity/ima/tests/ima_conditionals.sh @@ -0,0 +1,62 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (c) 2021 VPI Engineering +# Copyright (c) 2021 Petr Vorel +# Author: Alex Henrie +# +# Verify that conditional rules work. + +TST_NEEDS_CMDS="chgrp chown id sg sudo" +TST_CNT=1 +TST_NEEDS_DEVICE=1 + +. ima_setup.sh + +verify_measurement() +{ + local request="$1" + local user="nobody" + local test_file="$PWD/test.txt" + local cmd="cat $test_file > /dev/null" + + local value="$(id -u $user)" + [ "$request" = 'gid' -o "$request" = 'fgroup' ] && value="$(id -g $user)" + + require_policy_writable + + ROD rm -f $test_file + + tst_res TINFO "verify measuring user files when requested via $request" + ROD echo "measure $request=$value" \> $IMA_POLICY + ROD echo "$(date) $request test" \> $test_file + + case "$request" in + fgroup) + chgrp $user $test_file + $cmd + fowner) + chown $user $test_file + $cmd + ;; + gid) sudo sg $user "sh -c '$cmd'";; + uid) sudo -n -u $user sh -c "$cmd";; + *) tst_brk TBROK "Invalid res type '$1'";; + esac + + ima_check $test_file +} + +test1() +{ + verify_measurement uid + verify_measurement fowner + + if tst_kvcmp -lt 5.16; then + tst_brk TCONF "gid and fgroup options require kernel 5.16 or newer" + fi + + verify_measurement gid + verify_measurement fgroup +} + +tst_run