Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1995076imm; Thu, 24 May 2018 04:12:38 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoIqPqc+8QvurnSTMNyMBptPLpaNy79CJcV7SPGI2iNxL0Dq61jss0z8gsDLeC0KzjKOchM X-Received: by 2002:a17:902:56e:: with SMTP id 101-v6mr374878plf.25.1527160358939; Thu, 24 May 2018 04:12:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527160358; cv=none; d=google.com; s=arc-20160816; b=W7O9yx++wK4CSbyHuDAboJnGuoKqjbskyHPixlR5MxCAQ9oiw79pn/bjAdUBupshil hxJIjpoxKhSJ7XxKAun42bf6WLMXwAfTloI2N78ss0wnY6I08cwRddc8h+LnbrIPgXvh +BmsXlC80Unpsw1+jMj1C1dWdfbThfh4ZAT80fIbhpjgQO5ekgf1hzg9ZYWLHwyaGegc PdK34Vt8S8AvXx4nVNJbPQm3XaSQ6Ty9qj0h1SijMH0KveUXMPfnM8iBU9C2kw2b4sVg H1BkNTwWBbNJMl5HH/rU+J74aM6PQlazWu2PlK/CUgGTyZFxIYC6EHX8tGJ4c07Vv3se FudQ== 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=ycgOr+QK8iKYf8PMCkhqmHVHGyGJOnatYvx5L522uZs=; b=BrgecgkVUermNfHXStk+L9Os3hqU3wUprCFiqudS9JENVQQLztAd2nPSI8qoq821b8 lV9FAw6Ugf7yK3abhyzHNU2YUTdGSt0E24XgdhH3+UIrqlN78yXvJmxs8SsEajfRc433 McF1FfXCwLyhA1Lu0tSkD+I6LPFImvnCgI3D4tI9NofYObYQV5YkSDuPjVJhJ1RNE201 KkvRWzeKKgaP/sFpcMP4Uu/IPx9SW1pLrnjSNsrtFr2M3nBL/T+Q+Bujj0xUi9u9roPU cxtlK3ULAzgjoEiD6V4iDYY9GGieeXrIRetu9zMtzMActb0s9B64ecXXSu3/c9UX4r5P tZLQ== 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 u68-v6si3891596pgb.553.2018.05.24.04.12.24; Thu, 24 May 2018 04:12:38 -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 S1033052AbeEXLKk (ORCPT + 99 others); Thu, 24 May 2018 07:10:40 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:52214 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1033029AbeEXLKd (ORCPT ); Thu, 24 May 2018 07:10:33 -0400 Received: from pps.filterd (m0098413.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w4OB08xB114049 for ; Thu, 24 May 2018 07:10:32 -0400 Received: from e06smtp15.uk.ibm.com (e06smtp15.uk.ibm.com [195.75.94.111]) by mx0b-001b2d01.pphosted.com with ESMTP id 2j5s7xr9ja-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 24 May 2018 07:10:32 -0400 Received: from localhost by e06smtp15.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 24 May 2018 12:10:30 +0100 Received: from b06cxnps3075.portsmouth.uk.ibm.com (9.149.109.195) by e06smtp15.uk.ibm.com (192.168.101.145) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 24 May 2018 12:10:27 +0100 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w4OBAREn16122310; Thu, 24 May 2018 11:10:27 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 853BB11C04C; Thu, 24 May 2018 12:01:31 +0100 (BST) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 13A6211C05B; Thu, 24 May 2018 12:01:30 +0100 (BST) Received: from localhost.ibm.com (unknown [9.80.85.225]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 24 May 2018 12:01:29 +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 v3 2/7] kexec: add call to LSM hook in original kexec_load syscall Date: Thu, 24 May 2018 07:09:31 -0400 X-Mailer: git-send-email 2.7.5 In-Reply-To: <1527160176-29269-1-git-send-email-zohar@linux.vnet.ibm.com> References: <1527160176-29269-1-git-send-email-zohar@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18052411-0020-0000-0000-00000420CAD9 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18052411-0021-0000-0000-000042B60DDA Message-Id: <1527160176-29269-3-git-send-email-zohar@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-05-24_03:,, 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-1805240132 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_data() 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 | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/kernel/kexec.c b/kernel/kexec.c index aed8fb2564b3..061ada41c18c 100644 --- a/kernel/kexec.c +++ b/kernel/kexec.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -195,10 +196,17 @@ 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; + /* Permit LSMs and IMA to fail the kexec */ + result = security_kernel_read_data(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