Received: by 10.213.65.68 with SMTP id h4csp150088imn; Fri, 23 Mar 2018 01:17:22 -0700 (PDT) X-Google-Smtp-Source: AG47ELuT5aA5ugQZLGJ/RxEhX82t40BYCOkrSSTygGRvJTA20bcS5pGRftrulGrCWIWvnkZhqIwx X-Received: by 2002:a17:902:8d87:: with SMTP id v7-v6mr28355493plo.146.1521793042313; Fri, 23 Mar 2018 01:17:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521793042; cv=none; d=google.com; s=arc-20160816; b=1DGBvf1Wfj4K6xdjEBmyj/a4n28RVoSgvLJB1svCOZZw0NgY0SM8q1Hqf/dzyTPMa2 dgA3TQrSUNvtrDz3Qpg9rr+wVEZRHsgTLxc1SUGKjxOHpRb6q9eYPzlcjFRbXB1mvUdc 6H4bZ6q/YxGMLfhaG+6MwFDWVwbJT9NAUjBuLrxqbi+sZXj+T+RzBtThm6kHFa2lS6K/ +5EP41ujGcul/WJqG75El0eVO/OkN72ENtKcx/2kpBAxAEGjpoDpGAlh3NJCYwA0ix+V FE7s+/qDOwh2bFQ5JMwiZeUjXY3p66JES/Vr0wG94gKstnKe3fl1shctIfbWm24GVXdI SG5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:cms-type:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:cc:to:subject:dkim-signature:dkim-filter :arc-authentication-results; bh=x/GuGYr4YZMcNAvEgVETqk2/LVlscrJ/lg2M6MQX5Qo=; b=bZVWBLPRMbW3AhjwQU3ZKOSXQpBPvhG9+U0F2iprdkZIk/MQyDziYSz4Can10oFz3R NIssPCH1+31PgtmfeQ0hHKGYzxRXY4gS5abx2ORULCl2TW0KEaXwk/4h1g08BJd39A1p 4VAoT2NfpBbFAfr/R7t8gxnSf00LO4XzjRcLi8LY1sYh8C4zG2cUdNmr16zbnRzbMfb9 jOdujKVwnbt8zYQdbk8eltQLIVEPjDJP1edQZrVlalwRZqNOVLkDhhjqun7YbDqcDLIh Di4pbdEbKy5n+xCX7JInKi41R1BB8mYGkP5NMu097cyIWGIfkATZW1nsh1Z16zOqPN/w c6Hg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=Hw/0teYF; 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=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b34-v6si8140065plc.53.2018.03.23.01.17.07; Fri, 23 Mar 2018 01:17:22 -0700 (PDT) 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; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=Hw/0teYF; 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=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751828AbeCWIOg (ORCPT + 99 others); Fri, 23 Mar 2018 04:14:36 -0400 Received: from mailout1.w1.samsung.com ([210.118.77.11]:37228 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751733AbeCWIOc (ORCPT ); Fri, 23 Mar 2018 04:14:32 -0400 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20180323081429euoutp017fd0512af79dfd65f60c5c6e6c82ffe8~efo1QEjbb1535115351euoutp01j; Fri, 23 Mar 2018 08:14:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20180323081429euoutp017fd0512af79dfd65f60c5c6e6c82ffe8~efo1QEjbb1535115351euoutp01j DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1521792869; bh=x/GuGYr4YZMcNAvEgVETqk2/LVlscrJ/lg2M6MQX5Qo=; h=Subject:To:Cc:From:Date:In-reply-to:References:From; b=Hw/0teYFrbonRf6ZO1w43t54JUmnk+NslwNoBZHcgbSd8bZ4n6dAZJl4VKiD5+UYF pTYUV3F/Ci4mQYVbWAlINnnlHDNCbNT3qAX/3hG8fVKKmYp+83StbR/aJ10Q03ww/q cwbuGECquj0ffol/sx4A2bBlRTEHD1XO8alFJSVs= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20180323081428eucas1p256a25b14020f87cffc9611099fd4eac7~efo0FOOfu0426004260eucas1p2X; Fri, 23 Mar 2018 08:14:28 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 50.AA.17380.367B4BA5; Fri, 23 Mar 2018 08:14:27 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20180323081426eucas1p1197a70772d3b4fdfef2ccd63275399d5~efoySK32H2931929319eucas1p1r; Fri, 23 Mar 2018 08:14:26 +0000 (GMT) X-AuditID: cbfec7f4-6f9ff700000043e4-a6-5ab4b763f1ab Received: from eusync4.samsung.com ( [203.254.199.214]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 0D.7E.04183.267B4BA5; Fri, 23 Mar 2018 08:14:26 +0000 (GMT) Received: from [106.116.147.30] by eusync4.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0P6100B5CAW0MF30@eusync4.samsung.com>; Fri, 23 Mar 2018 08:14:26 +0000 (GMT) Subject: Re: [PATCH V3] ZBOOT: fix stack protector in compressed boot phase To: Huacai Chen , Andrew Morton Cc: linux-mips@linux-mips.org, Rich Felker , Russell King , Yoshinori Sato , linux-sh@vger.kernel.org, linux-kernel@vger.kernel.org, Ralf Baechle , linux-mm@kvack.org, stable@vger.kernel.org, James Hogan , linux-arm-kernel@lists.infradead.org, 'Linux Samsung SOC' , Krzysztof Kozlowski From: Marek Szyprowski Message-id: Date: Fri, 23 Mar 2018 09:14:23 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-version: 1.0 In-reply-to: <1521186916-13745-1-git-send-email-chenhc@lemote.com> Content-type: text/plain; charset="utf-8"; format="flowed" Content-transfer-encoding: 7bit Content-language: en-US X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrBKsWRmVeSWpSXmKPExsWy7djPc7rJ27dEGUyYJmYxZ/0aNov5TRvY LBb+/MVqsXXTXjaL8+c3sFtsenyN1eLyrjlsFhOmTmK3uLfmP6vFjPP7mCzm/JnCbHH7Mq/F pT0qFgs2PmK0uD9pL5MDv0dLcw+bx6ZVnUDi0yR2j9nnzrF5nJv9gcXjxIzfLB5HV65l8ti8 pN7j9ZGHLB5Ltt5k9Pi8SS6AO4rLJiU1J7MstUjfLoErY/6J9ywFd/Ur1t4+wdjAOFWti5GT Q0LARGLmlfvsXYxcHEICKxglpn2exAySEBL4zCjx51YqTFH7yx4WiKJljBIPT7xkhXCeM0r0 vb3EClIlLOAtcfbxYhYQW0QgQOLvoolMIEXMAueYJTb0PmEDSbAJGEp0ve0Cs3kF7CTW990G s1kEVCUuTdsJtJqDQ1QgRuL1HzeIEkGJH5Pvgc3kFHCS2LdxGVg5s4CVxLN/rawQtrzE5jVv mSFscYnm1ptgl0oIrGOX+HG0lQXiBReJGY9OsUPYwhKvjm+BsmUkLk/uhqqpl+j7foQJormH UWJvy1QmiIS1xOHjF6G28UlM2jYd7FAJAV6JjjYhiBIPib4XK6HmOEosnf4DGlxTGSW27Ox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1MLUotgskwcnFINjNcDZu3wT7g9yeb/Jxmpr0k3+FzWvt1+dN6G9HN8dd6PlXxe dM5lDuX+qHrT6ndKoXMTz0apc88a279Jflly58r3ReU6X4pr7/wUzr2Rd7Vz78S1sipLZm3m N105Z+XkmWd7xVIP6Ln2cF11y0xle2ev/TfW9uRsZqZHs2Y0LDEpeaW8QJvxuLUSS3FGoqEW c1FxIgA7yZbIvgIAAA== X-CMS-MailID: 20180323081426eucas1p1197a70772d3b4fdfef2ccd63275399d5 X-Msg-Generator: CA CMS-TYPE: 201P X-CMS-RootMailID: 20180316075352epcas5p3d95b13f9382ff7bbce83b8177e8e3ad6 X-RootMTR: 20180316075352epcas5p3d95b13f9382ff7bbce83b8177e8e3ad6 References: <1521186916-13745-1-git-send-email-chenhc@lemote.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Huacai, On 2018-03-16 08:55, Huacai Chen wrote: > 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 before we > call decompress_kernel(). > > Original code comes from ARM but also used for MIPS and SH, so fix them > together. If without this fix, compressed booting of these archs will > fail because stack checking is enabled by default (>=4.16). > > V2: Fix build on ARM. > V3: Fix build on SuperH. > > Cc: stable@vger.kernel.org > Signed-off-by: Huacai Chen This patch breaks booting on ARM Exynos4210 based boards (tested with next-20180323, exynos_defconfig, both Trats and Origen fails to boot). That's a bit strange, because all other Exynos SoC works fine (I've checked 3250, 4412, 5250, 5410 and 542x). I really have no idea what is so specific inc case of Exynos4210, that causes this failure. > --- > arch/arm/boot/compressed/head.S | 4 ++++ > arch/arm/boot/compressed/misc.c | 7 ------- > arch/mips/boot/compressed/decompress.c | 7 ------- > arch/mips/boot/compressed/head.S | 4 ++++ > arch/sh/boot/compressed/head_32.S | 8 ++++++++ > arch/sh/boot/compressed/head_64.S | 4 ++++ > arch/sh/boot/compressed/misc.c | 7 ------- > 7 files changed, 20 insertions(+), 21 deletions(-) > > diff --git a/arch/arm/boot/compressed/head.S b/arch/arm/boot/compressed/head.S > index 45c8823..bae1fc6 100644 > --- a/arch/arm/boot/compressed/head.S > +++ b/arch/arm/boot/compressed/head.S > @@ -547,6 +547,10 @@ not_relocated: mov r0, #0 > bic r4, r4, #1 > blne cache_on > > + ldr r0, =__stack_chk_guard > + ldr r1, =0x000a0dff > + str r1, [r0] > + > /* > * The C runtime environment should now be setup sufficiently. > * Set up some pointers, and start decompressing. > diff --git a/arch/arm/boot/compressed/misc.c b/arch/arm/boot/compressed/misc.c > index 16a8a80..e518ef5 100644 > --- a/arch/arm/boot/compressed/misc.c > +++ b/arch/arm/boot/compressed/misc.c > @@ -130,11 +130,6 @@ asmlinkage void __div0(void) > > unsigned long __stack_chk_guard; > > -void __stack_chk_guard_setup(void) > -{ > - __stack_chk_guard = 0x000a0dff; > -} > - > void __stack_chk_fail(void) > { > error("stack-protector: Kernel stack is corrupted\n"); > @@ -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..5ba431c 100644 > --- a/arch/mips/boot/compressed/decompress.c > +++ b/arch/mips/boot/compressed/decompress.c > @@ -78,11 +78,6 @@ void error(char *x) > > unsigned long __stack_chk_guard; > > -void __stack_chk_guard_setup(void) > -{ > - __stack_chk_guard = 0x000a0dff; > -} > - > void __stack_chk_fail(void) > { > error("stack-protector: Kernel stack is corrupted\n"); > @@ -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/mips/boot/compressed/head.S b/arch/mips/boot/compressed/head.S > index 409cb48..00d0ee0 100644 > --- a/arch/mips/boot/compressed/head.S > +++ b/arch/mips/boot/compressed/head.S > @@ -32,6 +32,10 @@ start: > bne a2, a0, 1b > addiu a0, a0, 4 > > + PTR_LA a0, __stack_chk_guard > + PTR_LI a1, 0x000a0dff > + sw a1, 0(a0) > + > PTR_LA a0, (.heap) /* heap address */ > PTR_LA sp, (.stack + 8192) /* stack address */ > > diff --git a/arch/sh/boot/compressed/head_32.S b/arch/sh/boot/compressed/head_32.S > index 7bb1681..e84237d 100644 > --- a/arch/sh/boot/compressed/head_32.S > +++ b/arch/sh/boot/compressed/head_32.S > @@ -76,6 +76,10 @@ l1: > mov.l init_stack_addr, r0 > mov.l @r0, r15 > > + mov.l __stack_chk_guard_addr, r0 > + mov.l __stack_chk_guard_val, r1 > + mov.l r1, @r0 > + > /* Decompress the kernel */ > mov.l decompress_kernel_addr, r0 > jsr @r0 > @@ -97,6 +101,10 @@ kexec_magic: > .long 0x400000F0 /* magic used by kexec to parse zImage format */ > init_stack_addr: > .long stack_start > +__stack_chk_guard_val: > + .long 0x000A0DFF > +__stack_chk_guard_addr: > + .long __stack_chk_guard > decompress_kernel_addr: > .long decompress_kernel > kernel_start_addr: > diff --git a/arch/sh/boot/compressed/head_64.S b/arch/sh/boot/compressed/head_64.S > index 9993113..8b4d540 100644 > --- a/arch/sh/boot/compressed/head_64.S > +++ b/arch/sh/boot/compressed/head_64.S > @@ -132,6 +132,10 @@ startup: > addi r22, 4, r22 > bne r22, r23, tr1 > > + movi datalabel __stack_chk_guard, r0 > + movi 0x000a0dff, r1 > + st.l r0, 0, r1 > + > /* > * Decompress the kernel. > */ > diff --git a/arch/sh/boot/compressed/misc.c b/arch/sh/boot/compressed/misc.c > index 627ce8e..fe4c079 100644 > --- a/arch/sh/boot/compressed/misc.c > +++ b/arch/sh/boot/compressed/misc.c > @@ -106,11 +106,6 @@ static void error(char *x) > > unsigned long __stack_chk_guard; > > -void __stack_chk_guard_setup(void) > -{ > - __stack_chk_guard = 0x000a0dff; > -} > - > void __stack_chk_fail(void) > { > error("stack-protector: Kernel stack is corrupted\n"); > @@ -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 Best regards -- Marek Szyprowski, PhD Samsung R&D Institute Poland