From patchwork Tue Sep 14 16:15:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Henrie X-Patchwork-Id: 12494141 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,SPF_PASS, 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 ECE33C433EF for ; Tue, 14 Sep 2021 16:15:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C67D960F70 for ; Tue, 14 Sep 2021 16:15:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232318AbhINQRQ (ORCPT ); Tue, 14 Sep 2021 12:17:16 -0400 Received: from mail-co1nam11on2089.outbound.protection.outlook.com ([40.107.220.89]:59104 "EHLO NAM11-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S230131AbhINQRP (ORCPT ); Tue, 14 Sep 2021 12:17:15 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dTfmtyna3kqPHUNg8TVt7llUYPNXtZtKquQRugRfAVNn2kSqHIxGOSSk5T9D1JTU5GqvovT/fwec5RVqsmUHOBDwfyC2+Y+F8P47aDiOpXw7ZyhZ1ONcR5Xt2g3IiiZF+xVwl5JNZ9lei5A6KdIt+nCkkb3hADXuLhv6xlZRQnYKb8yA6NhAsEx5VtYER/Ut5f0s+8vBF9ANJ2ALnrkiAnwCp/jS7vYFfrZnC2dR8if5uFkwUGDyOOB2RDJyTgj4K3OQbmEffSywwW1PTHqSwnBhkXzFlT92PKeDHtmgHAGS5K/9k0AkXO3W4ENJX8Mmw0lrRZM00P/psAzlonwHqw== 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=zMxu75s0OhBb/Yj7WUME2AQQ2gmO12Nyk27SSpLlHuk=; b=Vrj3fxgOsebhItGPgQho5ZN/J9spqrNa3TR3RFF2rSa7kclpHTCjy/QJo9uZEiZYzjRXsvEd14JizW25muDjNMAoYymvLtKcG9kyC7yXriljW7mc2hTkpbbq5GPRwlePTxG12Dh8jyVtzumEWMcKQn+vyUnFiheoLX6KE0dEOi9d85khOOeaLjCjq/ekUnUAofHsLM0fsxdA2Qs+xvgg8pakOdAbH+u5ApEg4S9kT36Hryn18Ff2c6GTFbMrnwfiXGKHJSje54ddtvsiExJOu9a6nzj8gFqLs6mRvMSfLcQZRkzWYKoci4fS30hiq2Q+UHE8/Om8IX+SnqV/LgEuhw== 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=zMxu75s0OhBb/Yj7WUME2AQQ2gmO12Nyk27SSpLlHuk=; b=c4m+6juiVrsoK/1Bd8kIwsJVqt8uWX/cOKgTxqF7Y7rkQNi4qwB25m1zd2Kc/4FJ3eBSctpwDsPoH+QYv0nJRMlhz5+2zOqrb/3lOSjKPCiFNQ0JTsykTL/Jlav9Ev56MssI+e3kh68tulRdNuAAOryxdKaIoRkSWMiAYWO6bt0= 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 MW2PR07MB4009.namprd07.prod.outlook.com (2603:10b6:907:c::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4500.18; Tue, 14 Sep 2021 16:15:55 +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.4500.018; Tue, 14 Sep 2021 16:15:54 +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 v3 1/2] IMA: Move check_policy_writable to ima_setup.sh and rename it Date: Tue, 14 Sep 2021 10:15:02 -0600 Message-Id: <20210914161503.97495-1-alexh@vpitech.com> X-Mailer: git-send-email 2.33.0 X-ClientProxiedBy: MWHPR11CA0037.namprd11.prod.outlook.com (2603:10b6:300:115::23) 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 MWHPR11CA0037.namprd11.prod.outlook.com (2603:10b6:300:115::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.14 via Frontend Transport; Tue, 14 Sep 2021 16:15:54 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 340b01a4-f32c-4223-019a-08d9779aed91 X-MS-TrafficTypeDiagnostic: MW2PR07MB4009: 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: vEeFyePev5Jf4XgWbjJkQd0ThMrzxOhRJc8fpxCx+OZ6ukhTWLlUi8veWFthnEhPLdJz8azEliVHfLsloshmb5WwVK042mg3gNUMelRwkIn+/am4FZ5bzjXX775k9/NH1lreucacn6WwuTdKT3l3WJ64v93EmFECXsPARpOwPr41F+DM/9QIE/dnkI4rbyilfm1p0ImdXwd2D3p8vQ+G6pVr2ifn9o351hBTayDpxESnDhcas+qeE+worFQY4J9RjHqHPhyFs5Gd1kfnE7zT/pJMG/LxTwXUXiFvitOW1SYZWKfGHa1RVSSHoN2zzyE/mKvIAI9Ehe+bF03cOs/tEDI1sAozXp7wzCXzx8K/nbsvRdQG3+QLyINI3jy071xbKpu+Th6NFJy5U40nkyMYMUagyN/Yet+31PY5jfbpQQCXEfWwI9g2P45rxpcWJ4aiS1SP8S+/ayXcOYmPWiW2V8W1JxgNq/3AMWt9YFQlcNAZkzhtVxw6BRCP0L5spCcqR1P2Eo6Bc8akHNFB0+vdKoDr4UCbOCURW1OeTI38BCLbsEes0+yKLExMGekhQpsux/fUCF1f49SJMGCQKLA/PdYWKqHSqq9tkDwqGaEwMTE6I063M3KXwqnSdVl07aquxl5uZjSbTvlk+C+JfhgvLjdJvlUzbIrmtjMgJyep4Z+Ty7ymV+8OhbjmxuSQsdve 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:(346002)(39830400003)(396003)(376002)(366004)(136003)(66946007)(66556008)(66476007)(186003)(6486002)(1076003)(36756003)(316002)(7696005)(107886003)(83380400001)(26005)(52116002)(478600001)(8676002)(6666004)(8936002)(4326008)(38100700002)(38350700002)(956004)(2616005)(2906002)(5660300002)(86362001);DIR:OUT;SFP:1101; X-MS-Exch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ta+9x/RF2snYXxiiqf9PhwJmJBOlgdcgCXd0A4/GgHkezPpMZiRQ+CxD/HbjH74AUAwuEGr3vBVqeLPDsa+e16eciuBxx1m/eEZJLh5c0r6dxRj2xBwQBAJXdUQDERjNG10Ys5HnE/MzailhCfUTLePL517FOf/OJexcG6ygIc/FTFKD/7jCIU1Q1vHgl6ypFx79TIR99Fev6c5Bn5KjbhE8es1XEkOYJcwMfVF5Bt/I8AEf0kHWZdsD7HK2AmolGxqLqmO/Q+JakdRRvdAs44fn94qb+OwxWBX7xJVY7+PtYFtkDKUfsJB X-OriginatorOrg: vpitech.com X-MS-Exchange-CrossTenant-Network-Message-Id: 340b01a4-f32c-4223-019a-08d9779aed91 X-MS-Exchange-CrossTenant-AuthSource: MW2PR07MB3980.namprd07.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Sep 2021 16:15:54.5737 (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: IK7Wloix5PtXgTnS5BwFDZHCfLTCvAgxor7uzzQyb7LBYtsOFFMF2Kk++L923TspBf3OmnFGmWV1QQw+Cu/PRg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW2PR07MB4009 Precedence: bulk List-ID: X-Mailing-List: linux-integrity@vger.kernel.org Signed-off-by: Alex Henrie --- .../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 Tue Sep 14 16:15:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Henrie X-Patchwork-Id: 12494143 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,SPF_PASS, 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 68D58C433F5 for ; Tue, 14 Sep 2021 16:16:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 495F7610FB for ; Tue, 14 Sep 2021 16:16:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229937AbhINQRR (ORCPT ); Tue, 14 Sep 2021 12:17:17 -0400 Received: from mail-bn7nam10on2086.outbound.protection.outlook.com ([40.107.92.86]:54689 "EHLO NAM10-BN7-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S232267AbhINQRQ (ORCPT ); Tue, 14 Sep 2021 12:17:16 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BLlWRc8v9rVtGCL9Nph2rCo4Nu16fMiydseLkIH89vf+ix8E7VtdpyTpVBja9YuniF1Bf2KqWoNOg4gPV40sI358q5a0WQj/p2Co5P0yXow+ckdcFhgzf9s9/QLImaKc7d3riLDNYjoNpJmAXGFXwOpleH1tPPAbZVTBU9hBhing9JlGdKLekincC/AvoOcZcJhTdb5uOgsxpJrnxbMpj5tIZ2u39lmf5wQelZa70WZdAMQ63bsJgh07jUe1Y7aCbILBkIG6ntjqiXuXXjU+fHOCgcIK52MCx2n5kTbdyb1BDhDQCSCZHlO/Zl+x8xAyn3OHQi9UWVFDOfaMhT5PDw== 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=B75C9ZMjt0z37Rq6pJgKMlHMjmaTLs+HKjNdhcv27NE=; b=ISpoQp4u50d850R4yXGK0X1zxCyr8yMpDsYwcVVsTv4Jqz63DcE9CHf0x6NZHBMb6NQ5lOrCSQzJZi6alGZtCRoy//o9hbsXkPYt4rhLBNcWXxpRKwmJnKqNWu+JKHEO8ciWLyA0Yq0UnX2XSs40tRknK4QvNQDDJHr/AunzLjDXD8NdqX35JOmtQ7/1s7cBAnXElXolMi82TDo4wiGGW0vJgTBhmDysdiInY+37tal5U6SKOv/ThfPtpZvEdpItQfbp4IfzawddScQTdn1DuXEpu1n/ICI3dWOe6aqnnFDDIlBSSB4ANP/aGCKcO3+jSNvtmb4wMLakqj9Ao/Mgkw== 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=B75C9ZMjt0z37Rq6pJgKMlHMjmaTLs+HKjNdhcv27NE=; b=eni2YHOqc+FZuBAJwxIO2/I4St58l/4XuFrDvVRhXZx0DXInz3p/FZep79JZEPweIvCDHOyui9vl+MQ78BKqkafUKbPvGpio2wq9XD0G1dq+2zjCeb0bin9UZC/hR7y3JZZqpfhEbcWUqj6nEEMmHlftMHSxxZrA8KliI+TVsdA= 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 CO2PR07MB2615.namprd07.prod.outlook.com (2603:10b6:102:13::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.14; Tue, 14 Sep 2021 16:15:55 +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.4500.018; Tue, 14 Sep 2021 16:15:55 +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 v3 2/2] IMA: Add tests for uid, gid, fowner, and fgroup options Date: Tue, 14 Sep 2021 10:15:03 -0600 Message-Id: <20210914161503.97495-2-alexh@vpitech.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210914161503.97495-1-alexh@vpitech.com> References: <20210914161503.97495-1-alexh@vpitech.com> X-ClientProxiedBy: MWHPR11CA0037.namprd11.prod.outlook.com (2603:10b6:300:115::23) 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 MWHPR11CA0037.namprd11.prod.outlook.com (2603:10b6:300:115::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4523.14 via Frontend Transport; Tue, 14 Sep 2021 16:15:54 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0de38125-f4be-440b-6fb4-08d9779aedf4 X-MS-TrafficTypeDiagnostic: CO2PR07MB2615: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2150; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: cdZJUz1skFo/DxRLY1xJrBLd2oLHWZuKj0XdTO2GDT3Pi5xZsepZQMInHZPdHYlzhBdjFUGzk4tvonEEtLqeOpVJJQwFwaLucn5h6QbwMcg52m6VPSnInv3BCuDTqfP9f0bTAwU2drtRGxRCGM7n8Kae9bE3YZLhxQM02mFLiMLQ4iX1kfh103JR8gxObh8TLYlAXQa3O8ShX8+s78uPJKlLYtJky0pijeTRHzRB4EzApTyD91cmmcg/hwmDSb9v81Ar9WXlfga5Nc/iAVDUaMH16YLzsNtfHyB/3QYjTE/H2/Jf+Zzg9A2amoE80UmgNCNAA/c4SpgjzB36W41XpiPZlR0jMvU0qaZFhePiJfk4NUJUKR32tBBLtrvsFSlBs8KiKQws++dK/5jkJmXGK2gekyG4aX0F2DgV4eFuP0RusQPEWE4CFNPFOKtA0lCMWYdSJglKhghxOpMmd9cfERZBaG8QKgWnvBOfSxeyv1Y7jUfDuFOE7A1+0/ofIISufG8MFxxJFxcigjPDzlMX/1RVUIsiUCQAALDbEs3vcSDqhz5cbzF2TFChjej2KttTSLfIlGOKIDQf0wfTBGliiHJVpVLWeLt2WHIqVABpOREGd0bAu8e/yeCduPZCjGsg5USFEcJco+Dqp1SaVYfdMBjVVpYEuKHxoFPZlLldIHG4PVx07WnR0GyJ99YO2uzJ1ZtG/jXoU08QO/nOr/dWuQ== 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)(366004)(39830400003)(376002)(346002)(396003)(4326008)(6666004)(6486002)(36756003)(66556008)(52116002)(2616005)(2906002)(66946007)(8936002)(478600001)(956004)(86362001)(38100700002)(107886003)(38350700002)(83380400001)(26005)(1076003)(8676002)(66476007)(7696005)(5660300002)(316002)(186003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: IzVTStWXJXKy5JfhAID1s4CXrQ4uhA6rFy7CSKCE6Vz/clbCZfGyI4zuorMroz8ljMFoUd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odkW42RD4n2LR8F9Ai9uNWqgp9u91+iWzk0fCTFIn+v4GL0fY0y5gWWuhk+JfbAqfxYnJ/jsnRFYx9QX6cOqM3BbX2VOpcS/vq5qvJYKmRkjxqPfkHwJs2rI25w87TlHBp85RiNWIQmpzIIGst7yG5Dawzod/OUuAakRYItu+5vk4CDJ0yYxy57KNTcFMnOj34LdXivOSNK X-OriginatorOrg: vpitech.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0de38125-f4be-440b-6fb4-08d9779aedf4 X-MS-Exchange-CrossTenant-AuthSource: MW2PR07MB3980.namprd07.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Sep 2021 16:15:55.2093 (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: 92OzsKhOHBio8uhNFhUGscAQSPt7BFrpUFHVlgMqbAy70TzhmjVtdattBpnLrK4bUPtLzSJfl9uMF3fl0WNdww== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO2PR07MB2615 Precedence: bulk List-ID: X-Mailing-List: linux-integrity@vger.kernel.org Requires "ima: add gid support". Signed-off-by: Alex Henrie Reviewed-by: Petr Vorel --- v3: - Put new tests in their own function - Don't require sudo or CONFIG_IMA_READ_POLICY=y for all tests - Increase kernel version requirement for new tests to 5.16 - Delete test file and recreate it with correct ownership for each test --- .../integrity/ima/tests/ima_measurements.sh | 49 ++++++++++++++++++- 1 file changed, 47 insertions(+), 2 deletions(-) diff --git a/testcases/kernel/security/integrity/ima/tests/ima_measurements.sh b/testcases/kernel/security/integrity/ima/tests/ima_measurements.sh index 1927e937c..5d22d12d3 100755 --- a/testcases/kernel/security/integrity/ima/tests/ima_measurements.sh +++ b/testcases/kernel/security/integrity/ima/tests/ima_measurements.sh @@ -8,7 +8,7 @@ TST_NEEDS_CMDS="awk cut sed" TST_SETUP="setup" -TST_CNT=3 +TST_CNT=4 TST_NEEDS_DEVICE=1 . ima_setup.sh @@ -103,7 +103,7 @@ test3() local file="$dir/test.txt" # Default policy does not measure user files - tst_res TINFO "verify not measuring user files" + tst_res TINFO "verify not measuring user files by default" tst_check_cmds sudo || return if ! id $user >/dev/null 2>/dev/null; then @@ -121,4 +121,49 @@ test3() EXPECT_FAIL "grep $file $ASCII_MEASUREMENTS" } +test4() +{ + local user="nobody" + + tst_check_cmds chgrp chown sg sudo || return + + # try to write to the policy, then check whether it can be written again + cat $IMA_POLICY > $IMA_POLICY 2> /dev/null + require_policy_writable + + ROD rm -f $TEST_FILE + tst_res TINFO "verify measuring user files when requested via uid" + ROD echo "measure uid=$(id -u $user)" \> $IMA_POLICY + ROD echo "$(date) uid test" \> $TEST_FILE + sudo -n -u $user sh -c "cat $TEST_FILE > /dev/null" + ima_check + + ROD rm -f $TEST_FILE + tst_res TINFO "verify measuring user files when requested via fowner" + ROD echo "measure fowner=$(id -u $user)" \> $IMA_POLICY + ROD echo "$(date) fowner test" \> $TEST_FILE + chown $user $TEST_FILE + cat $TEST_FILE > /dev/null + ima_check + + if tst_kvcmp -lt 5.16; then + tst_brk TCONF "gid and fgroup options require kernel 5.16 or newer" + fi + + ROD rm -f $TEST_FILE + tst_res TINFO "verify measuring user files when requested via gid" + ROD echo "measure gid=$(id -g $user)" \> $IMA_POLICY + ROD echo "$(date) gid test" \> $TEST_FILE + sudo sg $user "sh -c 'cat $TEST_FILE > /dev/null'" + ima_check + + ROD rm -f $TEST_FILE + tst_res TINFO "verify measuring user files when requested via fgroup" + ROD echo "measure fgroup=$(id -g $user)" \> $IMA_POLICY + ROD echo "$(date) fgroup test" \> $TEST_FILE + chgrp $user $TEST_FILE + cat $TEST_FILE > /dev/null + ima_check +} + tst_run