Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp17005imb; Thu, 28 Feb 2019 14:33:47 -0800 (PST) X-Google-Smtp-Source: APXvYqwBXF3m4T+A0Jae8hsdYyVj1jB4wxru/DIGc5TUkZFyrmih06tduJjLI9Dqi+XiMkoZPaUm X-Received: by 2002:a63:101c:: with SMTP id f28mr1490290pgl.224.1551393227407; Thu, 28 Feb 2019 14:33:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551393227; cv=none; d=google.com; s=arc-20160816; b=K5IU7ZxJ232PJBJyGFdf1SareT5jepF6Gc+6rENUvXEOJc52QT3SNVhM8Y6SUrBJBh f/C0cVvtWNhQ4HadN0WTX3Jjj04nIyJ7aXnhsRCdMUckqIaoze/yD3D2+RGrjFXfL9M4 dFjoOJy6ZVNom+GuRr062LwcNDZVNDl95mtkFAVLAdOa6sjn8lJAetwVqV6D40tIUL5m iE2TprQUiIiLC2g9T9W8Ev1k0ZKcORAT/GX5PWAhKGfSgtUyGlnoqD4WkdiRwIq1+/8f VV5kDlLAtefGOk6Vc5HO8mCrDeVX/7meTcCokPukFMOSjJP49AhFsowBZ23QSvwJedcq 1zVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:reply-to:message-id :subject:cc:to:from:date; bh=k0bv2CYLhBYaOWhlJUcaKHf451OVguqbQS947Nf20hw=; b=ahmbQumRb+4zWo6Wk/Bt9EUksTy7D5b6gj5AZLmX7UwU00G9eLs+IIYX3eelSoTvol xDVbQu62p4v7zNbqFe2M7qVdKygK3ts2YVXAwVN0eqMWz/pqjXxvuA75t6wY8b9JHAaV wvchteogJIlLhhtXTUa41LHzSlM6iV2+jtOvrEvx8AcvLGbCLG8DdpOls6vSV55iAuDH 67W9FHFebuhRKeepDfv9imfMu0LKzgp86pyLpqYnc7tqjOlPIklYberbci/WT6ZAwoER LjpxZDS/6CzJ7/iHIj9R7SVPvUQIMpHJEsfYH6YAQLwuWVefmApRdgw8YLI1cLpgtRVu yy6A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l187si18946339pge.71.2019.02.28.14.33.24; Thu, 28 Feb 2019 14:33:47 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728183AbfB1Wc7 (ORCPT + 99 others); Thu, 28 Feb 2019 17:32:59 -0500 Received: from mx2.suse.de ([195.135.220.15]:54060 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726088AbfB1Wc6 (ORCPT ); Thu, 28 Feb 2019 17:32:58 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 8B884B618; Thu, 28 Feb 2019 22:32:57 +0000 (UTC) Date: Thu, 28 Feb 2019 23:32:55 +0100 From: Petr Vorel To: Mimi Zohar Cc: linux-kselftest@vger.kernel.org, Shuah Khan , linux-integrity@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 5/5] selftests/ima: loading kernel modules Message-ID: <20190228223255.GE20335@dell5510> Reply-To: Petr Vorel References: <1551223620-11586-1-git-send-email-zohar@linux.ibm.com> <1551223620-11586-6-git-send-email-zohar@linux.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1551223620-11586-6-git-send-email-zohar@linux.ibm.com> User-Agent: Mutt/1.11.3 (2019-02-01) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Mimi, > While the appended kernel module signature can be verified, when loading > a kernel module via either the init_module or the finit_module syscall, > verifying the IMA signature requires access to the file descriptor, > which is only available via the finit_module syscall. As "modprobe" > does not provide a flag allowing the syscall - init_module or > finit_module - to be specified, this patch does not load a kernel > module. > This test simply verifies that on secure boot enabled systems with > "CONFIG_IMA_ARCH_POLICY" configured, that at least an appended kernel > module signature or an IMA signature is required based on the Kconfig > and the runtime IMA policy. > Signed-off-by: Mimi Zohar Reviewed-by: Petr Vorel ... > diff --git a/tools/testing/selftests/ima/test_kernel_module.sh b/tools/testing/selftests/ima/test_kernel_module.sh ... > +# Are appended signatures required? > +if [ -e /sys/module/module/parameters/sig_enforce ]; then > + sig_enforce=$(cat /sys/module/module/parameters/sig_enforce) > + if [ $sig_enforce = "Y" ]; then > + log_pass "appended kernel module signature required" > + fi > +fi Another possible helper [1]: is_enabled() # or sysfs_enabled { [ -f "$1" ] && [ "$(cat $1)" = "Y" -o "$(cat $1)" = "1" ] } is_enabled /sys/module/module/parameters/sig_enforce && \ log_pass "appended kernel module signature required" ... Kind regards, Petr [1] https://github.com/linux-test-project/ltp/blob/master/ver_linux#L30