Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp693412ybv; Fri, 7 Feb 2020 06:53:14 -0800 (PST) X-Google-Smtp-Source: APXvYqzHx+qAfMB5WrGS9cIuk6Lw2ACnwbfFXYE6L9WS+zBuIEVjT+MT92mSvY7hgjbId4vzRfW/ X-Received: by 2002:a05:6830:15c5:: with SMTP id j5mr2879608otr.289.1581087194266; Fri, 07 Feb 2020 06:53:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581087194; cv=none; d=google.com; s=arc-20160816; b=UX6zbq65GuMappF1rVNoNfvsDfbYX1F7AwsBAFspEUPOPzHapmL508VLCixOvBxMXR 0uw93ZmwNs/mTly2+TWG/bpf5ZVkWPsRhwzX13VUXL24favP05cKEgWDR3YCwSlMrQAY rMTLIeoTwRxFh0W/7L4PAu66F+0oBzXc7xRnlmKPx49aYH9olqaYR8I3NfC+vvgYXtPG 1LQhqnT5uHNmMDGIOehMP2QJUFlmL2nUrm6+sOqtZJ86h5PGtS0xooq+dDyT4cK6ZT61 tPqkHTdPDnAF0bovqFjaYtFO80GiwirsyEedWwygfx/VUOAl9w5uqou9jNzBxwQo22+N 3TlA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:content-transfer-encoding :mime-version:references:in-reply-to:date:cc:to:from:subject; bh=RrHOhD6zLT3Gr49lkyiDTCyltMqFRiz6MIubnyALOc4=; b=lj+cxwOyZIwGMA7lvNbm5HHA84XtmRs2vwzSAE0wEycQmV84Q72ZbgJJwBaitofIWk kQsBet7qpUZeQHJeQ4uyXrbbgLmYJzbwLcr5YF6dEvw6/BZFWDaXqdkcuFEtYHTPBjAt awooQnjVt72e4/OrTltPxIYuHhUMkYQFU/KYGfmTLdBqiug0WSX4yRkK0bYyil3bJeKE gqyjOcrf/VbGk5UMAhv74bZB5Go0Jkht2O1JYB3zvZKRYbn9u6SDdrN9MNC0Alp8yvvj eT1pd1iLSOMysqIGv30s38Hf+BjaduJWHtF2oCOhTTRZsCmyEnXqlkGaC57IUGbFkr+k 3T6Q== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u12si3876839oiv.13.2020.02.07.06.53.02; Fri, 07 Feb 2020 06:53:14 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727032AbgBGOvs (ORCPT + 99 others); Fri, 7 Feb 2020 09:51:48 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:43830 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726867AbgBGOvs (ORCPT ); Fri, 7 Feb 2020 09:51:48 -0500 Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 017En2ob087647 for ; Fri, 7 Feb 2020 09:51:46 -0500 Received: from e06smtp01.uk.ibm.com (e06smtp01.uk.ibm.com [195.75.94.97]) by mx0b-001b2d01.pphosted.com with ESMTP id 2y0ktsjdx2-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 07 Feb 2020 09:51:46 -0500 Received: from localhost by e06smtp01.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 7 Feb 2020 14:51:44 -0000 Received: from b06avi18626390.portsmouth.uk.ibm.com (9.149.26.192) by e06smtp01.uk.ibm.com (192.168.101.131) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Fri, 7 Feb 2020 14:51:40 -0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06avi18626390.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 017EojeT38863280 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 7 Feb 2020 14:50:45 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9CCC74C044; Fri, 7 Feb 2020 14:51:38 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 015AF4C040; Fri, 7 Feb 2020 14:51:37 +0000 (GMT) Received: from localhost.localdomain (unknown [9.80.201.239]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 7 Feb 2020 14:51:36 +0000 (GMT) Subject: Re: [RFC PATCH 0/2] ima: uncompressed module appraisal support From: Mimi Zohar To: Eric Snowberg , Nayna Cc: dmitry.kasatkin@gmail.com, jmorris@namei.org, serge@hallyn.com, dhowells@redhat.com, geert@linux-m68k.org, gregkh@linuxfoundation.org, nayna@linux.ibm.com, tglx@linutronix.de, bauerman@linux.ibm.com, mpe@ellerman.id.au, linux-integrity@vger.kernel.org, linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org Date: Fri, 07 Feb 2020 09:51:36 -0500 In-Reply-To: <09D68C13-75E2-4BD6-B4E6-F765B175C7FD@oracle.com> References: <20200206164226.24875-1-eric.snowberg@oracle.com> <5c246616-9a3a-3ed2-c1f9-f634cef511c9@linux.vnet.ibm.com> <09D68C13-75E2-4BD6-B4E6-F765B175C7FD@oracle.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.20.5 (3.20.5-1.fc24) Mime-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 x-cbid: 20020714-4275-0000-0000-0000039EF3C5 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 20020714-4276-0000-0000-000038B323FD Message-Id: <1581087096.5585.597.camel@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138,18.0.572 definitions=2020-02-07_01:2020-02-07,2020-02-07 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 mlxlogscore=999 impostorscore=0 malwarescore=0 suspectscore=0 phishscore=0 adultscore=0 lowpriorityscore=0 priorityscore=1501 spamscore=0 clxscore=1015 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2002070114 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 2020-02-06 at 14:40 -0700, Eric Snowberg wrote: > Currently the upstream code will fail if the module is uncompressed. > If you compress the same module it will load with the current > upstream code. > > > Lastly, there is nothing in these patches that indicate that the > kernel modules being compressed/uncompressed is related to the > signature verification. > >  > > Basically if you have the following setup: > > Kernel built with CONFIG_IMA_ARCH_POLICY or kernel booted with > module.sig_enforce=1 along with the following ima policy: > > appraise func=MODULE_CHECK appraise_type=imasig|modsig Enabling CONFIG_IMA_ARCH_POLICY or module.sig_enforce=1 behave totally differently.  CONFIG_IMA_ARCH_POLICY coordinates between the IMA signature verification and the original module_sig_check() verification.  Either one signature verification method is enabled or the other, but not both. The existing IMA x86 arch policy has not been updated to support appended signatures. To understand what is happening, we need to analyze each scenario separately. - If CONFIG_MODULE_SIG is configured or enabled on the boot command line ("module.sig_enforce = 1"), then the IMA arch x86 policy WILL NOT require an IMA signature. - If CONFIG_MODULE_SIG is NOT configured or enabled on the boot command line, then the IMA arch x86 policy WILL require an IMA signature. - If CONFIG_MODULE_SIG is configured or enabled on the boot command line, the IMA arch x86 policy is not configured, and the above policy rule is defined, an appended signature will be verified by both IMA and module_sig_check().    > > If you have a module foo.ko that contains a valid appended signature > but is not ima signed, it will fail to load. That would only happen in the second scenario or in the last scenario if the key is not found. > Now if the end user simply compresses the same foo.ko, making it > foo.ko.xz. The module will load. This implies that CONFIG_MODULE_SIG is configured or enabled on the boot command line, like the first scenario described above, or in the last scenario and the key is found. > > Modules can be loaded thru two different syscalls, finit_module and > init_module. The changes added in [1] work if you use the > init_module syscall. My change adds support when the finit_module > syscall gets used instead. With the IMA arch x86 policy, without CONFIG_MODULE_SIG configured or enabled on the boot command line, IMA will prevent the init_module() syscall.  This is intentional. Your second patch (2/2) changes the arch x86 policy rule to allow appended signatures.  The reason for any other changes needs to be clearer.  I suggest you look at the audit log and kernel messages, as well as the kexec selftests, to better understand what is happening. Mimi