From patchwork Thu Mar 1 02:53:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Huacai Chen X-Patchwork-Id: 10250285 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5754060365 for ; Thu, 1 Mar 2018 02:52:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 47CB928F8D for ; Thu, 1 Mar 2018 02:52:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3C0E028FA5; Thu, 1 Mar 2018 02:52:07 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.6 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SBL, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2E5AD28FAB for ; Thu, 1 Mar 2018 02:51:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965524AbeCACvk (ORCPT ); Wed, 28 Feb 2018 21:51:40 -0500 Received: from mail-pl0-f66.google.com ([209.85.160.66]:37703 "EHLO mail-pl0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965522AbeCACvj (ORCPT ); Wed, 28 Feb 2018 21:51:39 -0500 Received: by mail-pl0-f66.google.com with SMTP id ay8-v6so2811480plb.4; Wed, 28 Feb 2018 18:51:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id; bh=vYRX+SWMym+IbZ6qx4en40mwXw7Da2mzxWfQ6a8kjs4=; b=s1sSJ77CVWvyr3aGEK1xXtvxEK6aD27C3I6uWlCoWaqcF+9j4pkyzbo6R7DiRbTVcL 83j0dKuxBEuNMj2BjUsCVSLJmwSLvzNUfsYenRP+f8fshr8s+BZ5qL9TJW6h18uNVCiq 0QMGb0k6gv/meiZjuGQkAu7eBEPv+lf6lSeBwPxERHS8kp5c3/KzKpJ8aCWrtvDlvNKY l0EvOn+RlLUzTesh5VoOlWqIVC6USliODPxKtOKI92m796Yt/Q6TMx1qaFqpDraoY9oY fU+eK33C7qHGXd55rDEq0fMYmyvTuVafPRMdn43+06TJhKBdc625G8mzA6/e+tp7fmcA gwtw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id; bh=vYRX+SWMym+IbZ6qx4en40mwXw7Da2mzxWfQ6a8kjs4=; b=TrWhXA6sVydt6B/JRIf19bc7RofnZE06jcHavG3y4jSaKCG22QpJjK1HBlhBSbizS2 Wu0lPg+q3Cf+YYD6omcXI3lYucRoZTZnh/78ANN0kdgBaiDWefI4cJGM/VW3rTFjh/wN ZDDScS5KtiJ63klYhknU9zK1bMmULKWdHUcVpxfpyhF56YjNo8/HV0ASmAHK5YzLwIX+ 6QL4ief/F8lxN7bGrk65+yWzHc/ZImFy1C30CiXJ7ZYniPkNWjakooG6Aq9eaZMBMUFV f0gmt6sJHxU9zhZ8fB7tTjtO60XoUdLqjoVYlsK3tIVj075UF9HCsfUTqfGxtRKBl5hi ewqw== X-Gm-Message-State: APf1xPByz2idK+IkVi0cMU0L9eucl8tbZooBNcb6iA24hUQAsUaJ+Gjw idLDqpMO3vyHQ1DkgXPFa40= X-Google-Smtp-Source: AG47ELtoD+GRBf9a4HeyGWRKpRssCHAxzvAszb8cFcGR2MyvtwZNv+SU0u5me6mHjZUoKts3VYOwlA== X-Received: by 2002:a17:902:70cb:: with SMTP id l11-v6mr367207plt.192.1519872699285; Wed, 28 Feb 2018 18:51:39 -0800 (PST) Received: from software.domain.org ([172.247.34.138]) by smtp.gmail.com with ESMTPSA id q67sm6170147pfg.180.2018.02.28.18.51.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 28 Feb 2018 18:51:38 -0800 (PST) From: Huacai Chen To: Ralf Baechle Cc: James Hogan , "Steven J . Hill" , linux-mips@linux-mips.org, Fuxin Zhang , Zhangjin Wu , Russell King , linux-arm-kernel@lists.infradead.org, Yoshinori Sato , Rich Felker , linux-sh@vger.kernel.org, Huacai Chen , stable@vger.kernel.org Subject: [PATCH 01/99] ZBOOT: fix stack protector in compressed boot phase Date: Thu, 1 Mar 2018 10:53:11 +0800 Message-Id: <1519872791-19076-1-git-send-email-chenhc@lemote.com> X-Mailer: git-send-email 2.7.0 Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Call __stack_chk_guard_setup() in decompress_kernel() is too late that stack checking always fails for decompress_kernel() itself. So remove __stack_chk_guard_setup() and initialize __stack_chk_guard at where we define it. Original code comes from ARM but also used for MIPS and SH, so fix them together. Cc: stable@vger.kernel.org Signed-off-by: Huacai Chen --- arch/arm/boot/compressed/misc.c | 9 +-------- arch/mips/boot/compressed/decompress.c | 9 +-------- arch/sh/boot/compressed/misc.c | 9 +-------- 3 files changed, 3 insertions(+), 24 deletions(-) diff --git a/arch/arm/boot/compressed/misc.c b/arch/arm/boot/compressed/misc.c index 16a8a80..43aca75 100644 --- a/arch/arm/boot/compressed/misc.c +++ b/arch/arm/boot/compressed/misc.c @@ -128,12 +128,7 @@ asmlinkage void __div0(void) error("Attempting division by 0!"); } -unsigned long __stack_chk_guard; - -void __stack_chk_guard_setup(void) -{ - __stack_chk_guard = 0x000a0dff; -} +unsigned long __stack_chk_guard = 0x000a0dff; void __stack_chk_fail(void) { @@ -150,8 +145,6 @@ decompress_kernel(unsigned long output_start, unsigned long free_mem_ptr_p, { int ret; - __stack_chk_guard_setup(); - output_data = (unsigned char *)output_start; free_mem_ptr = free_mem_ptr_p; free_mem_end_ptr = free_mem_ptr_end_p; diff --git a/arch/mips/boot/compressed/decompress.c b/arch/mips/boot/compressed/decompress.c index fdf99e9..0694b3f 100644 --- a/arch/mips/boot/compressed/decompress.c +++ b/arch/mips/boot/compressed/decompress.c @@ -76,12 +76,7 @@ void error(char *x) #include "../../../../lib/decompress_unxz.c" #endif -unsigned long __stack_chk_guard; - -void __stack_chk_guard_setup(void) -{ - __stack_chk_guard = 0x000a0dff; -} +unsigned long __stack_chk_guard = 0x000a0dff; void __stack_chk_fail(void) { @@ -92,8 +87,6 @@ void decompress_kernel(unsigned long boot_heap_start) { unsigned long zimage_start, zimage_size; - __stack_chk_guard_setup(); - zimage_start = (unsigned long)(&__image_begin); zimage_size = (unsigned long)(&__image_end) - (unsigned long)(&__image_begin); diff --git a/arch/sh/boot/compressed/misc.c b/arch/sh/boot/compressed/misc.c index 627ce8e..2c564c2 100644 --- a/arch/sh/boot/compressed/misc.c +++ b/arch/sh/boot/compressed/misc.c @@ -104,12 +104,7 @@ static void error(char *x) while(1); /* Halt */ } -unsigned long __stack_chk_guard; - -void __stack_chk_guard_setup(void) -{ - __stack_chk_guard = 0x000a0dff; -} +unsigned long __stack_chk_guard = 0x000a0dff; void __stack_chk_fail(void) { @@ -130,8 +125,6 @@ void decompress_kernel(void) { unsigned long output_addr; - __stack_chk_guard_setup(); - #ifdef CONFIG_SUPERH64 output_addr = (CONFIG_MEMORY_START + 0x2000); #else