Received: by 10.213.65.68 with SMTP id h4csp1170460imn; Wed, 21 Mar 2018 04:33:30 -0700 (PDT) X-Google-Smtp-Source: AG47ELtVtVpTVSMXgPMToi92wosA5LiOxha7lJlDz1sbb9zJLLAePoLo9rzl56dzzZ8IutK1P/da X-Received: by 2002:a17:902:161:: with SMTP id 88-v6mr20131656plb.212.1521632010516; Wed, 21 Mar 2018 04:33:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521632010; cv=none; d=google.com; s=arc-20160816; b=Go6AnXdz1M1Z7Tv5mbsTRMPKSTf0CXtO6YDrU1nxQCpyWM5HGgJflQ1Dinsg7W8PIB Q45vWX4OmwMlZaXR/FnLvIJvgOqx07+bQoL3R59vbeglGj/TpX/hvT7geWecirSbf0vW HTEyUK47B7JszoBbPKMmGiPr84awSMsVBt7O9BqHcaQZRDCZ17PAjfkSWa2IugmKBDm6 C3+Q+gA0kinfVnTyvUc11IF3ZGpo2T0JkwQG1nO+ZAXDGyvFcvO9c3ddJW+nLt/YetDQ kOqVZtWquBCSUtuDFXncmkx/lGhyicomls6VNIZz75P9hpWsde5WgK7LxhkHKEeocivI Fa0A== 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=iG5XXA4luHPh/JBSKw/0EY9nUpD9CRsGIlJIUCapprs=; b=UvOzN5Rotjiz1WhZpEFzUDLWsjmY7wUccvuXFAuCaX8RBXIKZCISQdIvajwmrvYKdD d9ShTToWOdJEPJFHYcRHn3P6jdTiVy++DJUQGhroFROAkANDKmAwD8TQTTpv0FMyEcxs e0JCTDt0/NEDM3Vxctb1SNsNqlDw1S9Xq+aHRJY/8fkkWmkLNVjVvNCux5Xulx66YaLr T8BNH4rvX/Es4BVBoPXN8H5UtDDLt3Qsf7mwAh9lCC02SDMKZkKMaYaYNCd1ApVCvGxG wUNPh/Ibr6QtIpE1Gj54B462oNRTdjSSx9vDf/TwXkjAtuKuMaHuYGfRrwpZ3rVSfAx2 GB6A== 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 b10-v6si3892353pla.260.2018.03.21.04.33.16; Wed, 21 Mar 2018 04:33:30 -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 S1752021AbeCULab (ORCPT + 99 others); Wed, 21 Mar 2018 07:30:31 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:53524 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751797AbeCUL2D (ORCPT ); Wed, 21 Mar 2018 07:28:03 -0400 Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w2LBNVw7107151 for ; Wed, 21 Mar 2018 07:28:03 -0400 Received: from e06smtp12.uk.ibm.com (e06smtp12.uk.ibm.com [195.75.94.108]) by mx0a-001b2d01.pphosted.com with ESMTP id 2gup6ch0xc-1 (version=TLSv1.2 cipher=AES256-SHA256 bits=256 verify=NOT) for ; Wed, 21 Mar 2018 07:28:02 -0400 Received: from localhost by e06smtp12.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 21 Mar 2018 11:28:00 -0000 Received: from b06cxnps3075.portsmouth.uk.ibm.com (9.149.109.195) by e06smtp12.uk.ibm.com (192.168.101.142) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 21 Mar 2018 11:27:55 -0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w2LBRtoK50397390; Wed, 21 Mar 2018 11:27:55 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A667E4C040; Wed, 21 Mar 2018 11:21:02 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 41DF74C044; Wed, 21 Mar 2018 11:21:02 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Wed, 21 Mar 2018 11:21:02 +0000 (GMT) From: Philipp Rudo To: kexec@lists.infradead.org, linux-s390@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Eric Biederman , Vivek Goyal , Michael Ellerman , Thiago Jung Bauermann , Martin Schwidefsky , Heiko Carstens , Andrew Morton , x86@kernel.org, Dave Young , AKASHI Takahiro , Ingo Molnar Subject: [PATCH v2 02/11] kexec_file: Remove checks in kexec_purgatory_load Date: Wed, 21 Mar 2018 12:27:42 +0100 X-Mailer: git-send-email 2.13.5 In-Reply-To: <20180321112751.22196-1-prudo@linux.vnet.ibm.com> References: <20180321112751.22196-1-prudo@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18032111-0008-0000-0000-000004E0B595 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18032111-0009-0000-0000-00001E73D75D Message-Id: <20180321112751.22196-3-prudo@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2018-03-21_04:,, 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=1 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1803210139 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Before the purgatory is loaded several checks are done whether the ELF file in kexec_purgatory is valid or not. These checks are incomplete. For example they don't check for the total size of the sections defined in the section header table or if the entry point actually points into the purgatory. On the other hand the purgatory, although an ELF file on its own, is part of the kernel. Thus not trusting the purgatory means not trusting the kernel build itself. So remove all validity checks on the purgatory and just trust the kernel build. Signed-off-by: Philipp Rudo --- kernel/kexec_file.c | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/kernel/kexec_file.c b/kernel/kexec_file.c index e5bcd94c1efb..0f044457b40c 100644 --- a/kernel/kexec_file.c +++ b/kernel/kexec_file.c @@ -880,22 +880,8 @@ int kexec_load_purgatory(struct kimage *image, unsigned long min, if (kexec_purgatory_size <= 0) return -EINVAL; - if (kexec_purgatory_size < sizeof(Elf_Ehdr)) - return -ENOEXEC; - pi->ehdr = (Elf_Ehdr *)kexec_purgatory; - if (memcmp(pi->ehdr->e_ident, ELFMAG, SELFMAG) != 0 - || pi->ehdr->e_type != ET_REL - || !elf_check_arch(pi->ehdr) - || pi->ehdr->e_shentsize != sizeof(Elf_Shdr)) - return -ENOEXEC; - - if (pi->ehdr->e_shoff >= kexec_purgatory_size - || (pi->ehdr->e_shnum * sizeof(Elf_Shdr) > - kexec_purgatory_size - pi->ehdr->e_shoff)) - return -ENOEXEC; - ret = __kexec_load_purgatory(image, min, max, top_down); if (ret) return ret; -- 2.13.5