From patchwork Thu Feb 17 19:02:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Heimes X-Patchwork-Id: 1594468 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=G1TPO/mS; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4K043F309jz9sFr for ; Fri, 18 Feb 2022 06:03:05 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1nKm3Q-0001vU-9P; Thu, 17 Feb 2022 19:03:00 +0000 Received: from smtp-relay-canonical-0.internal ([10.131.114.83] helo=smtp-relay-canonical-0.canonical.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1nKm3J-0001rD-VQ for kernel-team@lists.ubuntu.com; Thu, 17 Feb 2022 19:02:53 +0000 Received: from T570.fritz.box (2.general.fheimes.us.vpn [10.172.66.67]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-canonical-0.canonical.com (Postfix) with ESMTPSA id 41DFF3FFFC for ; Thu, 17 Feb 2022 19:02:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1645124573; bh=s3Tqv6uNacw+5ywPivImEiZGfjHdfwGPRAR1QP+MWa4=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=G1TPO/mSSBDl0l7Yuq7xv6pV6CO2iVfY4lsdc7qncwyMJOZSVDbDGiDk2KOExsDun ckYmg8fhhj0+QGVzXWE+eCUyszPf2oMPiJwejb5C7bXugwH1f/pOnCJbX1dTGu/yau cOfSE4CdpNonmJCNaX+IUbP4eM7NAC/NO9SevVIBANoLe93JenHQ0nqudby2hiwpy4 xnTnAJ8bey2njQVEOhlqtXstOeQaJ/VbD+Rkb/Obx/kNJVZrgL4ZN2OCUcKphZf3Yv OHJ2ABCnwWIUoRiDjTRKornQAUG7MBxYnylfUx/2XqUN/+Rk4Im/kaKw9ktBFoGwd5 6Q1Vr+JfNU8Vg== From: frank.heimes@canonical.com To: kernel-team@lists.ubuntu.com Subject: [J][PATCH v2 1/2] s390/kexec_file: move kernel image size check Date: Thu, 17 Feb 2022 20:02:46 +0100 Message-Id: <20220217190247.1003163-2-frank.heimes@canonical.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220217190247.1003163-1-frank.heimes@canonical.com> References: <20220217190247.1003163-1-frank.heimes@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Sven Schnelle BugLink: https://bugs.launchpad.net/bugs/1960580 In preparation of adding support for command lines with variable sizes on s390, the check whether the new kernel image is at least HEAD_END bytes long isn't correct. Move the check to kexec_file_add_components() so we can get the size of the parm area and check the size there. The '.org HEAD_END' directive can now also be removed from head.S. This was used in the past to reserve space for the early sccb buffer, but with commit 9a5131b87cac1 ("s390/boot: move sclp early buffer from fixed address in asm to C") this is no longer required. Signed-off-by: Sven Schnelle Reviewed-by: Heiko Carstens Signed-off-by: Vasily Gorbik (backported from commit 277c8389386e2ccb8417afe4e36f67fc5dcd735d) Signed-off-by: Frank Heimes --- arch/s390/boot/head.S | 2 -- arch/s390/include/asm/setup.h | 1 - arch/s390/kernel/machine_kexec_file.c | 17 ++--------------- 3 files changed, 2 insertions(+), 18 deletions(-) diff --git a/arch/s390/boot/head.S b/arch/s390/boot/head.S index 40f4cff538b8..f3a8dba7dd5d 100644 --- a/arch/s390/boot/head.S +++ b/arch/s390/boot/head.S @@ -383,5 +383,3 @@ SYM_DATA_START(parmarea) .byte 0 .org PARMAREA+__PARMAREA_SIZE SYM_DATA_END(parmarea) - - .org HEAD_END diff --git a/arch/s390/include/asm/setup.h b/arch/s390/include/asm/setup.h index b6606ffd85d8..121e1a8c41d7 100644 --- a/arch/s390/include/asm/setup.h +++ b/arch/s390/include/asm/setup.h @@ -11,7 +11,6 @@ #include #define PARMAREA 0x10400 -#define HEAD_END 0x11000 /* * Machine features detected in early.c diff --git a/arch/s390/kernel/machine_kexec_file.c b/arch/s390/kernel/machine_kexec_file.c index a81d6c43b9b6..7174954b7fd6 100644 --- a/arch/s390/kernel/machine_kexec_file.c +++ b/arch/s390/kernel/machine_kexec_file.c @@ -235,7 +235,8 @@ void *kexec_file_add_components(struct kimage *image, if (ret) goto out; - if (image->cmdline_buf_len >= ARCH_COMMAND_LINE_SIZE) { + if (image->kernel_buf_len < PARMAREA + sizeof(struct parmarea) || + image->cmdline_buf_len >= ARCH_COMMAND_LINE_SIZE) { ret = -EINVAL; goto out; } @@ -325,20 +326,6 @@ int arch_kexec_apply_relocations_add(struct purgatory_info *pi, return 0; } -int arch_kexec_kernel_image_probe(struct kimage *image, void *buf, - unsigned long buf_len) -{ - /* A kernel must be at least large enough to contain head.S. During - * load memory in head.S will be accessed, e.g. to register the next - * command line. If the next kernel were smaller the current kernel - * will panic at load. - */ - if (buf_len < HEAD_END) - return -ENOEXEC; - - return kexec_image_probe_default(image, buf, buf_len); -} - int arch_kimage_file_post_load_cleanup(struct kimage *image) { vfree(image->arch.ipl_buf);