Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp904485ybk; Wed, 13 May 2020 16:40:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJylVD3YkEzyuFg9qN6L3vlo4d5eTdh0qGlbrRgtuxhVQDgM4vhhg8TcW5Y3Pa1kXvngOjU7 X-Received: by 2002:a50:c358:: with SMTP id q24mr1022431edb.313.1589413215248; Wed, 13 May 2020 16:40:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589413215; cv=none; d=google.com; s=arc-20160816; b=IrMkrTghi35KcicMuBdSgmo/u+a/Fpk7wUsp+Norx2UodIlmrNbuDjqY8ZZH8BJC2Q qTACCYRb3/tY+l/0Ytx/NztKZAaBYc0Zh/6QbrfA3nJo5P0SAEIo64dYKrD108aa6NyA Npu7JNwZLYmOjV/rorjeY5JS1aqbmp8gdmJ8S1RtkYfNYFHKra/KR1LlRUssMRmFlOEJ t7jctpz2phQe9XHGSLgLbw3SaA/po/KOr5VAZTSIHCbPkch48rxtDM8sQFLKy8j7WPpE iWrYJtnKy2FD32gm5j1IaYo6Up/AW+SRUQnNCMirXi6e8DDtfF5heAiStfqQRduA2OaA uTWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=gHOtYNQyFzCcRXNwDMVVJ2Dt352H9/gjoC/ZZ28NukY=; b=VFjIL0128lZDqlnTz6X/o8nIFCoiPYkDfNROw+bx34l3d9xtrAfUs93hXS63IvmMBk CnIaquIfTvGzzF/luaOjbFLM9diQPonki9ai8bnxPTr5e/ZPfQAw2IWwFv72L8uC3Ki3 VS0jsGOnSB+eoG0ck5qw+Ufs2Ho5aLFpxAC7xu3CO3W+OyKtNRt92YANtcKztizstiqb llSfFdWWprTMd8V2LSx8KibUkNXs2W4zXuVvVlfzeK77dSOkIPFjf+LJb2BdIiCVLmMe YZEooun1tQB+40+A+dww3iT7gEAkxDULG7I1yGYPgvihslT9VPBo42844fYq8ud0mJ78 FUvQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dx17si714584ejb.467.2020.05.13.16.39.39; Wed, 13 May 2020 16:40:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732696AbgEMXgd (ORCPT + 99 others); Wed, 13 May 2020 19:36:33 -0400 Received: from mx2.suse.de ([195.135.220.15]:36108 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732638AbgEMXgc (ORCPT ); Wed, 13 May 2020 19:36:32 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 1BD01AB64; Wed, 13 May 2020 23:36:32 +0000 (UTC) Date: Thu, 14 May 2020 01:36:16 +0200 From: Borislav Petkov To: Linus Torvalds Cc: Arnd Bergmann , Arvind Sankar , Kalle Valo , linux-wireless , "linux-kernel@vger.kernel.org" , the arch/x86 maintainers , Nick Desaulniers , Kees Cook , Thomas Gleixner Subject: Re: gcc-10: kernel stack is corrupted and fails to boot Message-ID: <20200513233616.GD6733@zn.tnic> References: <20200509120707.188595-2-arnd@arndb.de> <87v9l24qz6.fsf@kamboji.qca.qualcomm.com> <87r1vq4qev.fsf@kamboji.qca.qualcomm.com> <87d078tjl0.fsf_-_@kamboji.qca.qualcomm.com> <20200513154847.GA158356@rani.riverdale.lan> <20200513214128.GB6733@zn.tnic> <20200513222038.GC6733@zn.tnic> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org On Wed, May 13, 2020 at 04:13:53PM -0700, Linus Torvalds wrote: > The check itself doesn't seem worth it. If your worry is that an empty > asm() can be optimized away, then don't use an empty asm! gcc guys said we should use that since the first attempt using __attribute__((optimize("-fno-stack-protector"))) didn't work because, well, that attribute turned out to be "not suitable in production code". :) Full thread here: https://lore.kernel.org/lkml/20200314164451.346497-1-slyfox@gentoo.org/ > In other words, the only reason for that check seems to be a worry > that simply isn't worth having. Yes, that was me asking for a way to check whether any future gccs would violate that. But if they'd do that, they would break a lot of code depending on it. > In fact, I think the check is wrong anyway, since the main thing I can > see that would do a tailcall despite the empty asm is link-time > optimizations that that check doesn't even check for! > > So everything I see there just screams "the check is bogus" to me. The > check doesn't work, and if it were to work it only means that the > prevent_tail_call_optimization() thing is too fragile. So I did test it trivially by removing the asm("") and then it would tailcall optimize. But we didn't think about LTO so hm, that would probably break it. > Just put a full memory barrier in there, with an actual "mfence" > instruction or whatever, so that you know that the check is pointless, > and so that you know that a link-time optimizer can't turn the > call+return into a tailcall. Right, the intention here was to have it arch-agnostic in include/linux/compiler.h because powerpc might need it too soon: arch/powerpc/kernel/smp.c:1296: boot_init_stack_canary(); Looking at them, they do have an mb() too so how about this then instead? #define prevent_tail_call_optimization() mb() Thx. -- Regards/Gruss, Boris. SUSE Software Solutions Germany GmbH, GF: Felix Imendörffer, HRB 36809, AG Nürnberg