Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp1734136imm; Sat, 13 Oct 2018 02:46:17 -0700 (PDT) X-Google-Smtp-Source: ACcGV60yNNlzXEc3Yo6G7fWJoCLWl99NqAYOJILod/S8sZ98EvLjTzzipm/Chgzw6rBGWvp78f1Z X-Received: by 2002:a17:902:9a45:: with SMTP id x5-v6mr9180116plv.213.1539423977325; Sat, 13 Oct 2018 02:46:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539423977; cv=none; d=google.com; s=arc-20160816; b=aYaghAdqDEO8xNEG+H6QfrPemITY1oJWHbszPlctcjN1GatHGK8wqV9b1OI/xrePjq xubuMrvWWeQbpXRkT7lsTrzDbgtL1WytBxM+02lDfzN8cfpeZb530yPCHp9i/QGAU3Pu x3xcyCWDy/P/0plh+Q3wCpN0MkNJ5KV2UxyZ2GveBqq+69fS8qfHVw6W5AKuk2VDasxw SGN9fdT9xTcElOwhRgkM26SyEbC0UiJpY5Nt3nDdGNI/pl0OwsgLcd6jGksfs6WdIS7a OwgSphFkrpCyaqvfX/KX3Ppp+qyTans9fVNFfMpG7zQ4Sy5m+Ir9+bZ15SvIt72R0RF4 wgtQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:cc:to:subject:from:message-id; bh=HC/DnuEO5YIq5SM8n1wm9P7hqxHl5U/gxDH2N5MJIU0=; b=FKunvRyN1nOZ0RlEUqnFaTBqbI3I1dsCdY12yHDt3cbxXkbU+zrMDvo5jX/hs6UkKb dd6nav5QKQF/f5+B5CkcQ8d8m2K5dYyHvn1iD3KzlvqyZZqhGL6Yy4M3LsKOVrQc3vXH tA3dqhMwBrRSAGJsWKkqBp/i2XHGH0MqjlH3CIuh/YfVje2Kyd/hw/h3ppyll/M23d9O EfUb8z0KiGKXayyvQ8nLdO+dGN+8Wc7hW8ZbYu5CxEs9vVDt62PN9W5eWfwYXmby0Tgd ZWfpE3PauV5W3rWrGhW6aRU2vf37xgoaVEseEx60i0b7GEjfuwzLlLaMKm8T+NCiZmnb NXBQ== 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 t141-v6si4039046pgb.64.2018.10.13.02.46.01; Sat, 13 Oct 2018 02:46:17 -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; 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 S1727035AbeJMRVm (ORCPT + 99 others); Sat, 13 Oct 2018 13:21:42 -0400 Received: from pegase1.c-s.fr ([93.17.236.30]:24529 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726666AbeJMRVl (ORCPT ); Sat, 13 Oct 2018 13:21:41 -0400 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 42XKYv4RqDz9ttFt; Sat, 13 Oct 2018 11:45:07 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at c-s.fr Received: from pegase1.c-s.fr ([192.168.12.234]) by localhost (pegase1.c-s.fr [192.168.12.234]) (amavisd-new, port 10024) with ESMTP id GDSymDLByBox; Sat, 13 Oct 2018 11:45:07 +0200 (CEST) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase1.c-s.fr (Postfix) with ESMTP id 42XKYv3cJsz9ttFr; Sat, 13 Oct 2018 11:45:07 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id C5FD18B782; Sat, 13 Oct 2018 11:45:12 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id IWppLi9istWc; Sat, 13 Oct 2018 11:45:12 +0200 (CEST) Received: from pc13168vm.idsi0.si.c-s.fr (unknown [192.168.232.3]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 936E88B74B; Sat, 13 Oct 2018 11:45:12 +0200 (CEST) Received: by pc13168vm.idsi0.si.c-s.fr (Postfix, from userid 0) id 574C16F433; Sat, 13 Oct 2018 09:45:12 +0000 (UTC) Message-Id: From: Christophe Leroy Subject: [PATCH] powerpc/64: properly initialise the stackprotector canary on SMP. To: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman , abdhalee@linux.vnet.ibm.com Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Date: Sat, 13 Oct 2018 09:45:12 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org commit 06ec27aea9fc ("powerpc/64: add stack protector support") doesn't initialise the stack canary on SMP secondary CPU's paca, leading to the following false positive report from the stack protector. smp: Bringing up secondary CPUs ... Kernel panic - not syncing: stack-protector: Kernel stack is corrupted in: __schedule+0x978/0xa80 CPU: 1 PID: 0 Comm: swapper/1 Not tainted 4.19.0-rc7-next-20181010-autotest-autotest #1 Call Trace: [c000001fed5b3bf0] [c000000000a0ef3c] dump_stack+0xb0/0xf4 (unreliable) [c000001fed5b3c30] [c0000000000f9d68] panic+0x140/0x308 [c000001fed5b3cc0] [c0000000000f9844] __stack_chk_fail+0x24/0x30 [c000001fed5b3d20] [c000000000a2c3a8] __schedule+0x978/0xa80 [c000001fed5b3e00] [c000000000a2c9b4] schedule_idle+0x34/0x60 [c000001fed5b3e30] [c00000000013d344] do_idle+0x224/0x3d0 [c000001fed5b3ec0] [c00000000013d6e0] cpu_startup_entry+0x30/0x50 [c000001fed5b3ef0] [c000000000047f34] start_secondary+0x4d4/0x520 [c000001fed5b3f90] [c00000000000b370] start_secondary_prolog+0x10/0x14 This patch properly initialises the stack_canary of the secondary idle tasks. Reported-by: Abdul Haleem Fixes: 06ec27aea9fc ("powerpc/64: add stack protector support") Signed-off-by: Christophe Leroy --- arch/powerpc/kernel/smp.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c index 61c1fadbc644..e774d3bf3a03 100644 --- a/arch/powerpc/kernel/smp.c +++ b/arch/powerpc/kernel/smp.c @@ -34,6 +34,7 @@ #include #include #include +#include #include #include @@ -810,9 +811,16 @@ static void cpu_idle_thread_init(unsigned int cpu, struct task_struct *idle) { struct thread_info *ti = task_thread_info(idle); +#ifdef CONFIG_STACKPROTECTOR + idle->stack_canary = get_random_canary(); +#endif + #ifdef CONFIG_PPC64 paca_ptrs[cpu]->__current = idle; paca_ptrs[cpu]->kstack = (unsigned long)ti + THREAD_SIZE - STACK_FRAME_OVERHEAD; +#ifdef CONFIG_STACKPROTECTOR + paca_ptrs[cpu]->canary = idle->stack_canary; +#endif #endif ti->cpu = cpu; secondary_ti = current_set[cpu] = ti; -- 2.13.3