Received: by 10.192.165.156 with SMTP id m28csp104496imm; Thu, 12 Apr 2018 17:36:10 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+hPhUopWwlIWV3C8OMWyp1LBre/3WNVQvzRBui3yPv8mSkhWii7aUIxkiBzVz4eGcyzrve X-Received: by 10.99.115.9 with SMTP id o9mr2349790pgc.332.1523579770434; Thu, 12 Apr 2018 17:36:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523579770; cv=none; d=google.com; s=arc-20160816; b=RAedajzzkyunTiZPi8oHxPif5P7Dxx7N0XfIYxPLfmUctDx0DzPTZn68wVDlyNMpII y4w3UQ/vTU2NjdFUfjj5S+bYoZscVh6eL11J8PIqHWwj8YmSXYpXfnap7Y9JRqctZhru Um1Bfb6ttnRdYV5YB049yBNeZs8ocKCcKw0CVJ+9jqhHt5Xk/rFlkdzsPGTUw2bbytNl TeVeli9KJEzdXPKZcs1sL/E2u0xlY87Fox1E3CzwyZmLm4uX8QeyEqM6kQlKu4NHFQCt tgMS5NvoECiwFShwS+PgtuWVYuZre+enKtMat4hk/dCgUtH58pPEzLBKjXxNI/icbnM4 g5MQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:references:in-reply-to:date :subject:cc:to:from:arc-authentication-results; bh=KOXL2nJVhiEMrhsMEVV5OXwaBDo5DycqL69s7az1vQs=; b=Tlke27vEgYMG/uD2JF7at2rzn/OMjDgKyBwTswWDQQdEF6VIyYy8lODg1de1VqlIWh 3vwDVR56joD0pJ3Am5ri2tLvpBT3NE48vWurY61llEFxgIFjFq//VMbceCZE3GftGtGY NuBgFuksfCjDoOOA2mVFVVabnG9/EVBLgbBD4YqjOJhNuYPjuB9MOK3a1TINwPvicLT5 gtyzXefrez9W5ZT1s4voJ+kmbWUenkVdyoepRNZ3BsuAeCE9usnmSUMeS+yaWv2m/CBM KfSI+xWdRNLGtiA83jZ9GQugxSRzDeY5XVG6mHNM1HTJ/QzbdHptIvZf8d++lAlwlTdn Dsyw== 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 s4-v6si4317159plp.266.2018.04.12.17.35.56; Thu, 12 Apr 2018 17:36:10 -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 S1753597AbeDLWmO (ORCPT + 99 others); Thu, 12 Apr 2018 18:42:14 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:53900 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753478AbeDLWmL (ORCPT ); Thu, 12 Apr 2018 18:42:11 -0400 Received: from pps.filterd (m0098416.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w3CMdETI006240 for ; Thu, 12 Apr 2018 18:42:10 -0400 Received: from e06smtp12.uk.ibm.com (e06smtp12.uk.ibm.com [195.75.94.108]) by mx0b-001b2d01.pphosted.com with ESMTP id 2hae3tdebt-1 (version=TLSv1.2 cipher=AES256-SHA256 bits=256 verify=NOT) for ; Thu, 12 Apr 2018 18:42:10 -0400 Received: from localhost by e06smtp12.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 12 Apr 2018 23:42:08 +0100 Received: from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198) by e06smtp12.uk.ibm.com (192.168.101.142) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 12 Apr 2018 23:42:06 +0100 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w3CMg5o955902378; Thu, 12 Apr 2018 22:42:05 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8CD5AAE056; Thu, 12 Apr 2018 23:32:00 +0100 (BST) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7C34DAE045; Thu, 12 Apr 2018 23:31:59 +0100 (BST) Received: from localhost.ibm.com (unknown [9.80.84.218]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 12 Apr 2018 23:31:59 +0100 (BST) From: Mimi Zohar To: David Howells Cc: Matthew Garrett , Mimi Zohar , linux-integrity@vger.kernel.org, linux-security-module@vger.kernel.org, Eric Biederman , kexec@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/3] kexec: call LSM hook for kexec_load syscall Date: Thu, 12 Apr 2018 18:41:50 -0400 X-Mailer: git-send-email 2.7.5 In-Reply-To: <1523572911-16363-1-git-send-email-zohar@linux.vnet.ibm.com> References: <1523572911-16363-1-git-send-email-zohar@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18041222-0008-0000-0000-000004E9F1DF X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18041222-0009-0000-0000-00001E7DFCF3 Message-Id: <1523572911-16363-3-git-send-email-zohar@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-04-12_13:,, 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=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1804120213 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Allow LSMs and IMA to differentiate between the kexec_load and kexec_file_load syscalls by adding an "unnecessary" call to security_kernel_read_file() in kexec_load. This would be similar to the existing init_module syscall calling security_kernel_read_file(). Signed-off-by: Mimi Zohar --- kernel/kexec.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/kernel/kexec.c b/kernel/kexec.c index aed8fb2564b3..d1386cfc6796 100644 --- a/kernel/kexec.c +++ b/kernel/kexec.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -195,11 +196,21 @@ static int do_kexec_load(unsigned long entry, unsigned long nr_segments, static inline int kexec_load_check(unsigned long nr_segments, unsigned long flags) { + int result; + /* We only trust the superuser with rebooting the system. */ if (!capable(CAP_SYS_BOOT) || kexec_load_disabled) return -EPERM; /* + * Allow LSMs and IMA to differentiate between kexec_load and + * kexec_file_load syscalls. + */ + result = security_kernel_read_file(NULL, READING_KEXEC_IMAGE); + if (result < 0) + return result; + + /* * Verify we have a legal set of flags * This leaves us room for future extensions. */ -- 2.7.5