Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp3377512imm; Thu, 17 May 2018 07:52:55 -0700 (PDT) X-Google-Smtp-Source: AB8JxZq3zK6VPVV73KfkudqpMmJX+FMTI/35S0siCt8f4bUZwgMUuL5qCmCjeD1etdVKVzK90zj/ X-Received: by 2002:a65:438b:: with SMTP id m11-v6mr4163168pgp.99.1526568775467; Thu, 17 May 2018 07:52:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526568775; cv=none; d=google.com; s=arc-20160816; b=fIkVw88l1jW3oV41/I2NCXbd/YEfjfd1O8MSLsMSjv57gRB3CGu4JAsnAvMUvmmEKY L0Lh6TfxFI5Jotqim5um6iVk4njoGx/SEX7W4Vvnx2QPCvPQnwqBx/KTjhyeHmD3FHS7 xXns4BnbWIe1diTVdXLx1TteyDboHDE7Itv6xxSEiHtfc684GHK9eDcOAwqL8h9PaOop di60k2sE1ve3PdXJ9YOGUwKlsZIfJPZ35dc1wETcG9hSgBzCDOsWsOClr7wTe4ele8dw BAqh2EhqoHLJTrveVSo1k+PB3xQzpiOpzHYBtCEXnNQW+j4176EHb/A6dKX3UkADTpvc kHTg== 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=l+YV48iPHy6nsCVGaeerYciWVcTSmqr1bMNZ830R4fI=; b=BDncjrnf9Yx8UPCHeLfRdmQ8i2ch2jKvi5gVxLOK3rO9GPdoulms2H1aA6+Y93Tjha H8y3howy0s+e565BrwM8R7/OEXTNR6BRxm950Xvw9CIl76qRbdvpKooN1V9k3tHdY7mW ZV2g2m91mZsIxMiU9OJZQPhTUBO1Lwj/HjkXm6zBJwxYmgeRzIJEeGCgHvhe9UUD7VIG pTcch12VH5cJ6P1gQYCffIZe87US1XhcJIjWaou/6JSlBaUCK6j7xg48Qp7SgPMmkLGY S7Hf/VpHmtqjfggxQfMfk61c+dvAp4ylaJr646lEEKfQL14sPKU48LhkZKhrLSCubAOn ccag== 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 d7-v6si3937044pgq.305.2018.05.17.07.52.40; Thu, 17 May 2018 07:52:55 -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 S1752551AbeEQOtu (ORCPT + 99 others); Thu, 17 May 2018 10:49:50 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:59888 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752501AbeEQOtq (ORCPT ); Thu, 17 May 2018 10:49:46 -0400 Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w4HEjQtT104576 for ; Thu, 17 May 2018 10:49:45 -0400 Received: from e06smtp13.uk.ibm.com (e06smtp13.uk.ibm.com [195.75.94.109]) by mx0a-001b2d01.pphosted.com with ESMTP id 2j18q7s64q-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 17 May 2018 10:49:45 -0400 Received: from localhost by e06smtp13.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 17 May 2018 15:49:42 +0100 Received: from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198) by e06smtp13.uk.ibm.com (192.168.101.143) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Thu, 17 May 2018 15:49:39 +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 w4HEnccr4981198 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 17 May 2018 14:49:38 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B97B14C046; Thu, 17 May 2018 15:41:26 +0100 (BST) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3ABB24C052; Thu, 17 May 2018 15:41:25 +0100 (BST) Received: from localhost.ibm.com (unknown [9.80.108.64]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 17 May 2018 15:41:25 +0100 (BST) From: Mimi Zohar To: linux-integrity@vger.kernel.org Cc: Mimi Zohar , linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org, David Howells , "Luis R . Rodriguez" , Eric Biederman , kexec@lists.infradead.org, Andres Rodriguez , Greg Kroah-Hartman , Ard Biesheuvel , Kees Cook Subject: [PATCH v2 4/9] kexec: add call to LSM hook in original kexec_load syscall Date: Thu, 17 May 2018 10:48:45 -0400 X-Mailer: git-send-email 2.7.5 In-Reply-To: <1526568530-9144-1-git-send-email-zohar@linux.vnet.ibm.com> References: <1526568530-9144-1-git-send-email-zohar@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18051714-0012-0000-0000-000005D7A700 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18051714-0013-0000-0000-00001954D357 Message-Id: <1526568530-9144-5-git-send-email-zohar@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-05-17_08:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 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-1805170137 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In order for LSMs and IMA-appraisal to differentiate between the original and new syscalls, both the original and new syscalls must call an LSM hook. This patch adds a call to security_kernel_read_blob() in the original kexec syscall. Signed-off-by: Mimi Zohar Cc: Eric Biederman Cc: Luis R. Rodriguez Cc: Kees Cook Cc: David Howells --- kernel/kexec.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/kernel/kexec.c b/kernel/kexec.c index aed8fb2564b3..64cebe92a690 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_blob(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