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: 10250287 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 C8E2560365 for ; Thu, 1 Mar 2018 02:52:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B828328F93 for ; Thu, 1 Mar 2018 02:52:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AC26328F97; Thu, 1 Mar 2018 02:52:08 +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=-1.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_SBL autolearn=no version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 26CDB28F94 for ; Thu, 1 Mar 2018 02:52:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=dj0mhvyI0q3nM2iFlFKyY9rsJfrfAml94z2/SjcyDu0=; b=Rdu fhchtAf1Hz3XdBBkfvmTRZs3pFQ5+5ztWmrCBxMZwhbZwxuzV1XuItYF6yC23Tk1zRh7sU/W6c7s3 T4fv+FBz+glCGUYxSK36kvHEMOLt8Fu5zdkjCnXfUtoaD1RbYK4sYOW+Ay5O4HBE9aaY7vMoYpdMx 69J7oyBtuLUMW2stBgc+EeUEcbA6WjePZGaKyHry7ps95ZCJq2pVMVQ5duDCUUFJb9ZO1UR+Fy2RJ q3eHPkzztd3tLfE4bhBRn8x6VEzvL+myTmk6SWuE55Xsndmqki/FGzN6bBhpdwqwYkHIrNkXvT0xR CNBewlmolUEX7Z00CIeHB6rwmPpAJmw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1erEK4-0001pz-0P; Thu, 01 Mar 2018 02:51:56 +0000 Received: from mail-pl0-x244.google.com ([2607:f8b0:400e:c01::244]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1erEJy-0001oX-E1 for linux-arm-kernel@lists.infradead.org; Thu, 01 Mar 2018 02:51:53 +0000 Received: by mail-pl0-x244.google.com with SMTP id c11-v6so2824076plo.0 for ; 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=C9HKXN2CS3wWgrjYeTdksWyFwksbXw1+rGE/oJL+OA46qOBzSDsMSA5JTts7hJR7+k Ix2YRGisHPwA/3DSBIjbsVj/ROSFBvm5R+qL5FsUYyimJrXY0FgjxrzaLCVK+svIvnis JnvwDNr9vAj5Y+gOn+W/aIeHQxe9wduk5cG4jsONHqp7Hw569fIeNt/yz0ImUWN/QPJg MLjxUb9MH+PmluHSKQme3YLFprUhAn+lUAw1TWOOPwP3O6U+xg+mbaOKfjnBjrLpXlvS xGToxS0Jz3UP/DAtyLgwvKcY+WCeoGSImxSzH0ItZcACeTP94F1LB/AGw4Yp6YdRuN0+ l3jA== X-Gm-Message-State: APf1xPAoVa1Sj86yqw0yRzgv5lvJAy3HA4KjOtmPGOyDm76VHrwx+sef a2tfrRNhchmgFtg3BVZ9HUE= 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 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180228_185150_585423_1D6335C3 X-CRM114-Status: GOOD ( 10.90 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-mips@linux-mips.org, Rich Felker , Russell King , Yoshinori Sato , Zhangjin Wu , linux-sh@vger.kernel.org, stable@vger.kernel.org, "Steven J . Hill" , Fuxin Zhang , Huacai Chen , James Hogan , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.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