From patchwork Fri Jul 24 07:00:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Vorel X-Patchwork-Id: 1335379 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=2001:1418:10:5::2; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=suse.cz Received: from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4BCg8L46gVz9sRN for ; Fri, 24 Jul 2020 17:00:50 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id D78FD3C4D07 for ; Fri, 24 Jul 2020 09:00:47 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-6.smtp.seeweb.it (in-6.smtp.seeweb.it [IPv6:2001:4b78:1:20::6]) by picard.linux.it (Postfix) with ESMTP id BC69D3C1CB7 for ; Fri, 24 Jul 2020 09:00:45 +0200 (CEST) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by in-6.smtp.seeweb.it (Postfix) with ESMTPS id 377181400441 for ; Fri, 24 Jul 2020 09:00:44 +0200 (CEST) Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id D4785AC20; Fri, 24 Jul 2020 07:00:52 +0000 (UTC) From: Petr Vorel To: ltp@lists.linux.it Date: Fri, 24 Jul 2020 09:00:37 +0200 Message-Id: <20200724070038.29491-1-pvorel@suse.cz> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.99.2 at in-6.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.0 required=7.0 tests=SPF_HELO_NONE,SPF_PASS autolearn=disabled version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on in-6.smtp.seeweb.it Subject: [LTP] [PATCH v4 1/2] IMA: Fix policy readability check X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lakshmi Ramasubramanian , balajib@linux.microsoft.com, Mimi Zohar , linux-integrity@vger.kernel.org Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" Check with cat, because file attributes were fixed in ffb122de9a60 ("ima: Reflect correct permissions for policy") in v4.18. Added into ima_setup.sh as it'll be used next commit in another test. Fixes: d2768c84e ("IMA: Add a test to verify measurement of keys") Signed-off-by: Petr Vorel --- testcases/kernel/security/integrity/ima/tests/ima_keys.sh | 4 +--- .../kernel/security/integrity/ima/tests/ima_setup.sh | 8 ++++++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/testcases/kernel/security/integrity/ima/tests/ima_keys.sh b/testcases/kernel/security/integrity/ima/tests/ima_keys.sh index 904b7515b..26b8eaf84 100755 --- a/testcases/kernel/security/integrity/ima/tests/ima_keys.sh +++ b/testcases/kernel/security/integrity/ima/tests/ima_keys.sh @@ -19,9 +19,7 @@ test1() tst_res TINFO "verifying key measurement for keyrings and templates specified in IMA policy file" - [ -f $IMA_POLICY ] || tst_brk TCONF "missing $IMA_POLICY" - - [ -r $IMA_POLICY ] || tst_brk TCONF "cannot read IMA policy (CONFIG_IMA_READ_POLICY=y required)" + check_policy_readable keycheck_lines=$(grep "func=KEY_CHECK" $IMA_POLICY) if [ -z "$keycheck_lines" ]; then diff --git a/testcases/kernel/security/integrity/ima/tests/ima_setup.sh b/testcases/kernel/security/integrity/ima/tests/ima_setup.sh index 8ae477c1c..458f67c30 100644 --- a/testcases/kernel/security/integrity/ima/tests/ima_setup.sh +++ b/testcases/kernel/security/integrity/ima/tests/ima_setup.sh @@ -111,6 +111,14 @@ print_ima_config() tst_res TINFO "/proc/cmdline: $(cat /proc/cmdline)" } +check_policy_readable() +{ + [ -f $IMA_POLICY ] || tst_brk TCONF "missing $IMA_POLICY" + + cat $IMA_POLICY > /dev/null 2>/dev/null || \ + tst_brk TCONF "cannot read IMA policy (CONFIG_IMA_READ_POLICY=y required)" +} + ima_setup() { SECURITYFS="$(mount_helper securityfs $SYSFS/kernel/security)"