Received: by 10.223.185.116 with SMTP id b49csp1998275wrg; Mon, 12 Feb 2018 02:30:37 -0800 (PST) X-Google-Smtp-Source: AH8x226uqCaC17ps1dLHpsI2ePrWZrSc/Uu8dvZ7cdPAycXgZ8yJ5g7u2cJOkZzTznQIqUm3lm/1 X-Received: by 10.98.59.197 with SMTP id w66mr11190533pfj.7.1518431437424; Mon, 12 Feb 2018 02:30:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518431437; cv=none; d=google.com; s=arc-20160816; b=SG3YIqY9KpeKaXrpZooc2DRRpZdzau5W5E/zalV+bRonk5q4CtuPiRRjwBN2CHtTD6 LVy8LjqwQ9vqPQiDbAl8HiTDqVJzsmnsZuTa1nbkg7e5/BHU5lR5bd6YKoZj/pBCj2DR uYYpIcmx+9X8DyCfYwJMkwS8JWS9qp/uPKZLibGqvX4rtf/u/gSkC6RdKyRx2x15ZUfL spV25Z5QZ45mMwUVRlunbuT0fe+dNCqZMzPwJHRByQhKDB/Fphz4PbRIlv3zoDEXiodI lYjpJw4K+7tlQ993gpqvyR7s0vNuqnM4kZiNbXU0Lew0PHWJToLkxCdbxOaePAumSk9w gvTg== 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=FjaSTnjJsYJOrGgnSMMHpYEMygiQqzsuGLJ07JE9miNhEpFsDR2lCkRzB7YttZJhBb JF1SGGR0Wv4yDETXjP0Al0XQ8R0CdML/BJ6N+/JkAK3Ul+Y0/X/TS9XRMvkIrg+bfxtt 5TtkCnUNhuOQbsLPdj5OPEkXI1e3Z+Zp3aypvqL8h6ZJlH4b+w+cwhA3LOk43uDqQ94t XlmWmSPz2Gn6/WDDQlH64gThUsK/JloNkzlk47isf3uGdz/mx9vW/KbI74xAvUx837ay FRmELmXvBJGTrYRf7KOE5/FWZUTFbPacVSuVDOcp8wYwJtAEsLAzdEbXttcWNS/Tq/3I uHhA== 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 a23si3248071pgd.610.2018.02.12.02.30.22; Mon, 12 Feb 2018 02:30:37 -0800 (PST) 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 S933522AbeBLKIO (ORCPT + 99 others); Mon, 12 Feb 2018 05:08:14 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:60982 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S933150AbeBLKII (ORCPT ); Mon, 12 Feb 2018 05:08:08 -0500 Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w1CA4MTw049278 for ; Mon, 12 Feb 2018 05:08:08 -0500 Received: from e06smtp13.uk.ibm.com (e06smtp13.uk.ibm.com [195.75.94.109]) by mx0a-001b2d01.pphosted.com with ESMTP id 2g31etpr4e-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 12 Feb 2018 05:08:07 -0500 Received: from localhost by e06smtp13.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 12 Feb 2018 10:08:01 -0000 Received: from b06cxnps4075.portsmouth.uk.ibm.com (9.149.109.197) by e06smtp13.uk.ibm.com (192.168.101.143) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 12 Feb 2018 10:07:58 -0000 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 w1CA7vkb44236878; Mon, 12 Feb 2018 10:07:57 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 72DBEAE057; Mon, 12 Feb 2018 09:59:03 +0000 (GMT) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1EBEEAE056; Mon, 12 Feb 2018 09:59:03 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTPS; Mon, 12 Feb 2018 09:59:03 +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 Subject: [PATCH 02/17] kexec_file: Remove checks in kexec_purgatory_load Date: Mon, 12 Feb 2018 11:07:39 +0100 X-Mailer: git-send-email 2.13.5 In-Reply-To: <20180212100754.55121-1-prudo@linux.vnet.ibm.com> References: <20180212100754.55121-1-prudo@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18021210-0012-0000-0000-000005ADCAFC X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18021210-0013-0000-0000-000019298DBC Message-Id: <20180212100754.55121-3-prudo@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2018-02-12_05:,, 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-1802120131 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