Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp63814imm; Mon, 2 Jul 2018 07:44:29 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLZkeYtSb2K3XRD0QB2ov4Wngl5JcVdo4+47jd/QCplQPE9UEqRJQnvkhp8Ao4gXg4XV7bm X-Received: by 2002:a65:64c6:: with SMTP id t6-v6mr22171916pgv.223.1530542669873; Mon, 02 Jul 2018 07:44:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530542669; cv=none; d=google.com; s=arc-20160816; b=Re2tkQ5mDTXUfyd6Z5Ou1gii9MfOv4twppcWMfix2mlqXGxKimJoFt5JggDnYO1j7w XDlNipIQAQwWEbJuXCLI5Lz1keJLCndxrtHvvhzGacrrVatLH3pFWr6VNc+0QBwhgtjW QRgyZq1i4usNhqqAH3cmb8P8NykJNkIVw6oCqIvI5c7gKlBC+104R58PGnua+6brCR8V WDC5JpeLIjxlAVmMknr+McsCMny4sgKSfqfNVE5wNhmAieBUfGQXIZ9DVAEA+KThW0la s5cVBiwCwEDZ+hp9OxPrMIhYvXERnSZQZ8+M7GxG7QMln7pB5848daUTa2ej8H4SWoiJ xTXQ== 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=cJBBF0su3QzXVIXjNz8K0FId7S41KEOcNpcw4yGFKIU=; b=Z5NDCF0w3shWU6Mrl+YI4AYN3eNMISUlmV5aL2O+Ms00RZXj8sbghgynx0dlzLVhDz Odln8zkKPcK/a/eOeA4wg/CQn4zoSH0Qo4tL+YsmxvbIjSM2sNVG3W/tLgzFHGrOnJfP akHqrX87t3f+e1aYvwXvvXNYTB67oYgmaGd+olYAQrhLoHJgm/54P6gXmFYQRCw68tOM 56X5p1tFSj1hc5K6USNQuFdJMrFe1c6kE98udiw2uqGIMi+w2Bv8MU+zOURYzleZJDI3 ZaoMkJ4y0QQ8D56qm9eOvSoKuHBsgPv5oV7V3FqSUkzEmsjoJYpW4GvEX/D9YuOqWpdd yEqg== 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 f90-v6si17151112plf.390.2018.07.02.07.44.15; Mon, 02 Jul 2018 07:44:29 -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 S1752399AbeGBOlQ (ORCPT + 99 others); Mon, 2 Jul 2018 10:41:16 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:60096 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752369AbeGBOiz (ORCPT ); Mon, 2 Jul 2018 10:38:55 -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 w62EcYs3020903 for ; Mon, 2 Jul 2018 10:38:55 -0400 Received: from e06smtp05.uk.ibm.com (e06smtp05.uk.ibm.com [195.75.94.101]) by mx0a-001b2d01.pphosted.com with ESMTP id 2jyksdnu4j-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 02 Jul 2018 10:38:55 -0400 Received: from localhost by e06smtp05.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 2 Jul 2018 15:38:52 +0100 Received: from b06cxnps4075.portsmouth.uk.ibm.com (9.149.109.197) by e06smtp05.uk.ibm.com (192.168.101.135) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Mon, 2 Jul 2018 15:38:49 +0100 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w62EcnU942926094 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 2 Jul 2018 14:38:49 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3288E11C069; Mon, 2 Jul 2018 15:38:32 +0100 (BST) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B532A11C050; Mon, 2 Jul 2018 15:38:30 +0100 (BST) Received: from localhost.ibm.com (unknown [9.80.97.108]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP; Mon, 2 Jul 2018 15:38:30 +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 v5 2/8] kexec: add call to LSM hook in original kexec_load syscall Date: Mon, 2 Jul 2018 10:37:57 -0400 X-Mailer: git-send-email 2.7.5 In-Reply-To: <1530542283-26145-1-git-send-email-zohar@linux.vnet.ibm.com> References: <1530542283-26145-1-git-send-email-zohar@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18070214-0020-0000-0000-000002A23942 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18070214-0021-0000-0000-000020EE4B0B Message-Id: <1530542283-26145-3-git-send-email-zohar@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-07-02_04:,, 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 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1806210000 definitions=main-1807020168 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 kexec_load and kexec_file_load syscalls, both the original and new syscalls must call an LSM hook. This patch adds a call to security_kernel_load_data() in the original kexec_load syscall. Signed-off-by: Mimi Zohar Cc: Eric Biederman Cc: Luis R. Rodriguez Cc: Kees Cook Cc: David Howells Acked-by: Serge Hallyn --- kernel/kexec.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/kernel/kexec.c b/kernel/kexec.c index aed8fb2564b3..68559808fdfa 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_load_data(LOADING_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