Received: by 10.192.165.156 with SMTP id m28csp828741imm; Fri, 13 Apr 2018 08:31:06 -0700 (PDT) X-Google-Smtp-Source: AIpwx48NHHlhyjvJhn9vCW/eBf6b9SG3pba0936/51/CmAkwnXVbnVo5n/N2eMJxSmnly4fTbiee X-Received: by 2002:a17:902:5792:: with SMTP id l18-v6mr3062927pli.355.1523633466386; Fri, 13 Apr 2018 08:31:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523633466; cv=none; d=google.com; s=arc-20160816; b=oiW6blMheKIkJ3zVwmVfeRkbmRnNhzCAx1+Ejakha+vGDgHhr24W5b1rVnRbGpmY+T zYGsOG48jPorcwMiuXwZJ4Xfut69IP9YoieQTNH8mnqUnhrJgxDRjQSgbe9gCoRYokBW XKwuttFSfBCURVwG1jRkSX7EwKAqYyzZ5nm3DSK1MCgAmE1UzOwxEFJdB6PkDmIwNU2t SoViIGLgwYZ0cUZIKLlruQUte/O9DEOKNQtYd3qfLoTy/MxYg++IZHk+NlQhSnzcnyeE ugjwqgK2LQCMFvcigrEiaK9blW1X8yNUqJXnDWJyw7F7K3BtrHRvf2QkUGFxpWhwETkP aGmg== 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:date:cc:to:from:subject:arc-authentication-results; bh=JgKqSXrbvA74i59OEO8ePXwTIDIqbA+frLr+QuJ6bIw=; b=mvBMho2PQctL1rDMckruu4hXZy+4jRhRpAFgZUluffr3dJrBGXki0hYIstQmCJ7Fqq UzkD1Q9U83j8GmogKMr68i0O4aZF3VWSgfvfmtYo1K2NtY9dwSFo3hYdDlR3JuOr9+dq zrreWlsLm2i8hsNgn+Zcdhk2xtRYJZZtGBrH+11gEqJcBFShGSEAe75OTV9rxrZoEG37 3Rg3ZMi8Cy9FGo6DVFeDpr1OaWmQcPyEWHNK0Ps2qslmBdk2Bgt+XNW3oJQpHqcv02F7 6qmnYAOZH5go3ymrnhpyFBu6aKRr7eZjxJMKHpyygwyqkx8bvydrou1Wex//LOxixSh5 sTUA== 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 e6-v6si5707996plt.445.2018.04.13.08.30.51; Fri, 13 Apr 2018 08:31:06 -0700 (PDT) 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 S1751793AbeDMP2D (ORCPT + 99 others); Fri, 13 Apr 2018 11:28:03 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:44844 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750824AbeDMP2B (ORCPT ); Fri, 13 Apr 2018 11:28:01 -0400 Received: from pps.filterd (m0098393.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w3DFQveZ013408 for ; Fri, 13 Apr 2018 11:28:01 -0400 Received: from e06smtp15.uk.ibm.com (e06smtp15.uk.ibm.com [195.75.94.111]) by mx0a-001b2d01.pphosted.com with ESMTP id 2hav5h9tfa-1 (version=TLSv1.2 cipher=AES256-SHA256 bits=256 verify=NOT) for ; Fri, 13 Apr 2018 11:28:00 -0400 Received: from localhost by e06smtp15.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 13 Apr 2018 16:27:57 +0100 Received: from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198) by e06smtp15.uk.ibm.com (192.168.101.145) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 13 Apr 2018 16:27:55 +0100 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w3DFRs3Y56033344; Fri, 13 Apr 2018 15:27:54 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 151AE4C046; Fri, 13 Apr 2018 16:20:31 +0100 (BST) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3C33B4C040; Fri, 13 Apr 2018 16:20:30 +0100 (BST) Received: from localhost.localdomain (unknown [9.80.105.39]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 13 Apr 2018 16:20:30 +0100 (BST) Subject: [PATCH] lockdown: fix coordination of kernel module signature verification From: Mimi Zohar To: David Howells Cc: Luca Boccassi , "Bruno E. O. Meneguele" , linux-integrity , linux-security-module , linux-kernel Date: Fri, 13 Apr 2018 11:27:52 -0400 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: 7bit X-TM-AS-GCONF: 00 x-cbid: 18041315-0020-0000-0000-000004119D54 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18041315-0021-0000-0000-000042A5D0B4 Message-Id: <1523633272.3272.30.camel@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-04-13_08:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1804130142 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If both IMA-appraisal and sig_enforce are enabled, then both signatures are currently required. If the IMA-appraisal signature verification fails, it could rely on the appended signature verification; but with the lockdown patch set, the appended signature verification assumes that if IMA-appraisal is enabled, it has verified the signature. Basically each signature verification method would be relying on the other to verify the kernel module signature. This patch addresses the problem of requiring both kernel module signature verification methods, when both are enabled, by verifying just the appended signature. Signed-off-by: Mimi Zohar --- kernel/module.c | 4 +--- security/integrity/ima/ima_main.c | 7 ++++++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/kernel/module.c b/kernel/module.c index 9c1709a05037..60861eb7bc4d 100644 --- a/kernel/module.c +++ b/kernel/module.c @@ -2803,9 +2803,7 @@ static int module_sig_check(struct load_info *info, int flags, if (sig_enforce) { pr_notice("%s is rejected\n", reason); return -EKEYREJECTED; - } - - if (can_do_ima_check && is_ima_appraise_enabled()) + } else if (can_do_ima_check && is_ima_appraise_enabled()) return 0; if (kernel_is_locked_down(reason)) return -EPERM; diff --git a/security/integrity/ima/ima_main.c b/security/integrity/ima/ima_main.c index 754ece08e1c6..2155b1f316a4 100644 --- a/security/integrity/ima/ima_main.c +++ b/security/integrity/ima/ima_main.c @@ -480,6 +480,7 @@ static int read_idmap[READING_MAX_ID] = { int ima_post_read_file(struct file *file, void *buf, loff_t size, enum kernel_read_file_id read_id) { + bool sig_enforce = is_module_sig_enforced(); enum ima_hooks func; u32 secid; @@ -490,7 +491,11 @@ int ima_post_read_file(struct file *file, void *buf, loff_t size, return 0; } - if (!file && read_id == READING_MODULE) /* MODULE_SIG_FORCE enabled */ + /* + * If both IMA-appraisal and appended signature verification are + * enabled, rely on the appended signature verification. + */ + if (sig_enforce && read_id == READING_MODULE) return 0; /* permit signed certs */ -- 2.7.5