Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp4699400imu; Tue, 15 Jan 2019 04:37:35 -0800 (PST) X-Google-Smtp-Source: ALg8bN7Z/j5URM8ol+skhX1Q+WhAYOAcYw6jJnMSTFyS6E8/VFre86FJvH81phM4fbHhRCk2CKTw X-Received: by 2002:a17:902:8a91:: with SMTP id p17mr3942459plo.316.1547555855227; Tue, 15 Jan 2019 04:37:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547555855; cv=none; d=google.com; s=arc-20160816; b=V5UzWZVIfISGFfIJIpZlIFelLnGLqXGqmKsLUQvGcodJY+WpqTMscMpjMLE0HiRtGp iKkjuyvEkcuXSw7Pfcx/30sq51fCVClu76TQxAa7y94s9NpWfeQAMacSzmsBNRMH1MoR eAcIegXzhunaCwaTgl+Ytd4ZnitBvSs5w2V9URCWHmVozcj4mF1Ond6b7e0UZiuwoiAW 8LWzzcuGFMxrqTBIhjXQCPvQU4Z+q6+RYU+6Z07m3yeLtuCEEtYJQyHPJ0/D3e3eiYUE zZYU7MrSuzeH8K+Aru6/7YdGKxmmkZf4sbTgqeBcF8LVXxKKgzGoT15CMGDyBHNz2zfD zYLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:mime-version:robot-unsubscribe:robot-id :git-commit-id:subject:to:references:in-reply-to:reply-to:cc :message-id:from:date; bh=H7LrJugI/ivNn8UFaFnFn7b1PhjknkKEwjzYIOFy790=; b=bLxwyxOE7fcWio7B30OFmfM01Qj+fhvv6zAYRcU4C4VD3eqZPEkWIbaiv7davzKMXj mvAro2n1nRt0xETce8ZV3uS9UgSwaLRUYflHVIdcFvctkOtFWmqnNVcDUF5ixuPtIvxB nW2RujT5YNPdyQWa8u6gk+ifHQjUhFtz6cCjlEd+Wjma3gV05wt25p5Qq1w41WwKuRFa n+6ib1JBSuqkZw8ocaOWTmaP7uoORF4AJfPIpefsZvKcLoBfYZFq9PRvNsfCMJOWuYk8 BLTRUTgojRyha/a7NxQpds9OLh4vQ5AYuAMKnfWqun5lB/OfPONIU/KnCcb4Clzf1sGs tsSw== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r14si3313922pgk.75.2019.01.15.04.37.16; Tue, 15 Jan 2019 04:37:35 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729213AbfAOLTb (ORCPT + 99 others); Tue, 15 Jan 2019 06:19:31 -0500 Received: from terminus.zytor.com ([198.137.202.136]:43879 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728194AbfAOLTb (ORCPT ); Tue, 15 Jan 2019 06:19:31 -0500 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTPS id x0FBIwZe2491256 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Tue, 15 Jan 2019 03:18:58 -0800 Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id x0FBItiI2491250; Tue, 15 Jan 2019 03:18:55 -0800 Date: Tue, 15 Jan 2019 03:18:55 -0800 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for Dave Young Message-ID: Cc: tglx@linutronix.de, x86@kernel.org, vgoyal@redhat.com, akpm@linux-foundation.org, hpa@zytor.com, wang.yi59@zte.com.cn, schwidefsky@de.ibm.com, bhe@redhat.com, bp@suse.de, linux-kernel@vger.kernel.org, mingo@redhat.com, ebiederm@xmission.com, mingo@kernel.org, yannik@sembritzki.me, dyoung@redhat.com, prudo@linux.vnet.ibm.com, takahiro.akashi@linaro.org Reply-To: dyoung@redhat.com, yannik@sembritzki.me, prudo@linux.vnet.ibm.com, takahiro.akashi@linaro.org, ebiederm@xmission.com, mingo@kernel.org, bhe@redhat.com, schwidefsky@de.ibm.com, linux-kernel@vger.kernel.org, bp@suse.de, mingo@redhat.com, x86@kernel.org, tglx@linutronix.de, hpa@zytor.com, akpm@linux-foundation.org, vgoyal@redhat.com, wang.yi59@zte.com.cn In-Reply-To: <20181228011247.GA9999@dhcp-128-65.nay.redhat.com> References: <20181228011247.GA9999@dhcp-128-65.nay.redhat.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/urgent] x86/kexec: Fix a kexec_file_load() failure Git-Commit-ID: 993a110319a4a60aadbd02f6defdebe048f7773b X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00, T_DATE_IN_FUTURE_96_Q autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on terminus.zytor.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 993a110319a4a60aadbd02f6defdebe048f7773b Gitweb: https://git.kernel.org/tip/993a110319a4a60aadbd02f6defdebe048f7773b Author: Dave Young AuthorDate: Fri, 28 Dec 2018 09:12:47 +0800 Committer: Borislav Petkov CommitDate: Tue, 15 Jan 2019 12:12:50 +0100 x86/kexec: Fix a kexec_file_load() failure Commit b6664ba42f14 ("s390, kexec_file: drop arch_kexec_mem_walk()") changed the behavior of kexec_locate_mem_hole(): it will try to allocate free memory only when kbuf.mem is initialized to zero. However, x86's kexec_file_load() implementation reuses a struct kexec_buf allocated on the stack and its kbuf.mem member gets set by each kexec_add_buffer() invocation. The second kexec_add_buffer() will reuse the same kbuf but not reinitialize kbuf.mem. Therefore, explictily reset kbuf.mem each time in order for kexec_locate_mem_hole() to locate a free memory region each time. [ bp: massage commit message. ] Fixes: b6664ba42f14 ("s390, kexec_file: drop arch_kexec_mem_walk()") Signed-off-by: Dave Young Signed-off-by: Borislav Petkov Acked-by: Baoquan He Cc: "Eric W. Biederman" Cc: "H. Peter Anvin" Cc: AKASHI Takahiro Cc: Andrew Morton Cc: Ingo Molnar Cc: Martin Schwidefsky Cc: Philipp Rudo Cc: Thomas Gleixner Cc: Vivek Goyal Cc: Yannik Sembritzki Cc: Yi Wang Cc: kexec@lists.infradead.org Cc: x86-ml Link: https://lkml.kernel.org/r/20181228011247.GA9999@dhcp-128-65.nay.redhat.com --- arch/x86/kernel/crash.c | 1 + arch/x86/kernel/kexec-bzimage64.c | 2 ++ 2 files changed, 3 insertions(+) diff --git a/arch/x86/kernel/crash.c b/arch/x86/kernel/crash.c index c8b07d8ea5a2..17ffc869cab8 100644 --- a/arch/x86/kernel/crash.c +++ b/arch/x86/kernel/crash.c @@ -470,6 +470,7 @@ int crash_load_segments(struct kimage *image) kbuf.memsz = kbuf.bufsz; kbuf.buf_align = ELF_CORE_HEADER_ALIGN; + kbuf.mem = KEXEC_BUF_MEM_UNKNOWN; ret = kexec_add_buffer(&kbuf); if (ret) { vfree((void *)image->arch.elf_headers); diff --git a/arch/x86/kernel/kexec-bzimage64.c b/arch/x86/kernel/kexec-bzimage64.c index 278cd07228dd..0d5efa34f359 100644 --- a/arch/x86/kernel/kexec-bzimage64.c +++ b/arch/x86/kernel/kexec-bzimage64.c @@ -434,6 +434,7 @@ static void *bzImage64_load(struct kimage *image, char *kernel, kbuf.memsz = PAGE_ALIGN(header->init_size); kbuf.buf_align = header->kernel_alignment; kbuf.buf_min = MIN_KERNEL_LOAD_ADDR; + kbuf.mem = KEXEC_BUF_MEM_UNKNOWN; ret = kexec_add_buffer(&kbuf); if (ret) goto out_free_params; @@ -448,6 +449,7 @@ static void *bzImage64_load(struct kimage *image, char *kernel, kbuf.bufsz = kbuf.memsz = initrd_len; kbuf.buf_align = PAGE_SIZE; kbuf.buf_min = MIN_INITRD_LOAD_ADDR; + kbuf.mem = KEXEC_BUF_MEM_UNKNOWN; ret = kexec_add_buffer(&kbuf); if (ret) goto out_free_params;