Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp3659360imm; Tue, 29 May 2018 11:03:29 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoUJSpC2NH3uopVcpA5N4BCyNGU70vawvqGD1QcjoX3bJCnrp6lIMy2QqdwEPt1GJmrMlLe X-Received: by 2002:a63:b107:: with SMTP id r7-v6mr14579015pgf.167.1527617009568; Tue, 29 May 2018 11:03:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527617009; cv=none; d=google.com; s=arc-20160816; b=CdzwpiA0yLH13q4cggySt8PLImT6UFCNvIuspz/EwOWuGbZsdVhfVfzIpU7Z4U8VQt ciQxT0PpA8Kuj2uoeTt4q1VkZLZfU26jFKpvVY4hlypUKHZ2Mw5xeJ213gnhB8knfC68 73MAp6Ttj10Z0rbuNczJyVsOiaaog7qK8KXxYQKrfVeOJUxMgy/QyA+1mLgVrkqT8jaC y2bc8pAmVU0q9vFB4/YwHPQwv9EQdGUtOHSUN82UVqvw6g8+Su+T29OfYWrTF73Ic/1a limcomWso5a96iWiFhMkclIzx/MTZJmGm0/wI/i8A9ieTZhavQoD965460QwjntL29Pq Fhng== 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=hYnFF7N7NfKldEsHxKo32hpo9+4y6EdBLxQpa3etgUc=; b=ueYONK26SbeFdmk3FN7kY/++zPL57YT5P+1ItWhvXrlw3Lqnn0v5Btq18wzFOKVTPG D+hW3lGq7w8s4nFXeHu+J9ZvoDyamie+xh8O3bGn1zhysZnVi/3q0IqUeDvsM+eG7Bdl u2Aeo8aXuhUi3pWrwF/xBXvmR6XXFND8MT3JsdRkaj64WHhzEbzlx4sIEPKqXaKEKcf8 jwEYw79tRkS4xTuprYOWb49eCrH71Gydqb6eoBHaRWf7Ft4U1sB7+YR0A1YPly0jPhfe 6j1TtCYlULwdiEXTjg5SxdRragkpBu/kkZx/ZuHtev7wExk8D/Ur7bCrn0VpW0RJ2mJk rI6Q== 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 e189-v6si2326884pgc.461.2018.05.29.11.03.15; Tue, 29 May 2018 11:03: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 S965840AbeE2SCc (ORCPT + 99 others); Tue, 29 May 2018 14:02:32 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:36956 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S965720AbeE2SCV (ORCPT ); Tue, 29 May 2018 14:02:21 -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 w4THsZ27025218 for ; Tue, 29 May 2018 14:02:20 -0400 Received: from e06smtp12.uk.ibm.com (e06smtp12.uk.ibm.com [195.75.94.108]) by mx0b-001b2d01.pphosted.com with ESMTP id 2j993ryw2p-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 29 May 2018 14:02:19 -0400 Received: from localhost by e06smtp12.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 29 May 2018 19:02:17 +0100 Received: from b06cxnps4075.portsmouth.uk.ibm.com (9.149.109.197) by e06smtp12.uk.ibm.com (192.168.101.142) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Tue, 29 May 2018 19:02:14 +0100 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w4TI2DOL24248538 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 29 May 2018 18:02:13 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BB6D2AE05A; Tue, 29 May 2018 18:51:19 +0100 (BST) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 87F36AE056; Tue, 29 May 2018 18:51:18 +0100 (BST) Received: from dhcp-9-2-54-219.watson.ibm.com (unknown [9.2.54.219]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 29 May 2018 18:51:18 +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 v4 2/8] kexec: add call to LSM hook in original kexec_load syscall Date: Tue, 29 May 2018 14:01:54 -0400 X-Mailer: git-send-email 2.7.5 In-Reply-To: <1527616920-5415-1-git-send-email-zohar@linux.vnet.ibm.com> References: <1527616920-5415-1-git-send-email-zohar@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18052918-0008-0000-0000-000004FC48D1 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18052918-0009-0000-0000-00001E906782 Message-Id: <1527616920-5415-3-git-send-email-zohar@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-05-29_07:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=5 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-1805290195 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 --- 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