Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1402915pxb; Thu, 4 Feb 2021 12:00:42 -0800 (PST) X-Google-Smtp-Source: ABdhPJx0icXHu6viq72iYP8v7fWl0xid6K7/0oILnRoZbeN9pyHJUoTw6HRvLMqQt29MNKObZ1JP X-Received: by 2002:a17:906:3899:: with SMTP id q25mr709809ejd.173.1612468842595; Thu, 04 Feb 2021 12:00:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612468842; cv=none; d=google.com; s=arc-20160816; b=IoCRQMJSwQCoa0MaqF+sGT/ELW7bYzP5DwpdwFKs6e2xGPTdSoV6EzGog+7Rmhpr8W CCxO20S5yLh68BrWRNgoqAZYmnqchD5g6EsKIqHj3C5X3t3Gl+3nLU4EbP9yTtcvdRX/ ICJG6m6Z+wbad48UgJo/VqiUL/F2DTA22grNheA6kxwi5lk3UR/WHVhojqEZ0bWGMBYY plbUVSd+Iv6UelrVTDWSp5D0fv4iZQnJZYWB+XpPf1oBnt7AY8do7KmgaESJ/HhEVskb AI/3m8NuEBJfv/XxXqOeyLaV2katFy9pAMxdPTFOldl7sScQftY81C41J77XXv9vG+IE iyUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=FToFoRW57QEfMw0vp233PBaMzzSywEYZZwEWphiSDG8=; b=iRXnblFPM1cWqKTHod4jB3yUId8gK9WWa/gnVDZeXP7ET1PSFEc6+rO6rr5KTtEjRe 6AKGlDBAFQfuxg26eM93vacpKw7JijZI52Z79GgSSiNKQoShUqT9zDS5IjVZ4HIaMCLh VS8qb8BHRo77K8295IXmtOIJBGJ/6vj5CaFLaI+3eABzcfQloMupQky2nAJvcj62Br3U +ZBBxhzLsqQO0+z+iMcelS8V7t54IrQhStnkTXskvXEAFCpdijkIIL00/khmUT1jUVjS 6BulwNnmHZj6G1HHCDv8gq+KCIJYOz6zYQ9LMyuf0i/JrAneIctnqhFcm7+jujZGOB32 b5zw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cloudflare.com header.s=google header.b=ABi2tO0t; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=cloudflare.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p17si3838381edi.439.2021.02.04.12.00.16; Thu, 04 Feb 2021 12:00:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@cloudflare.com header.s=google header.b=ABi2tO0t; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=cloudflare.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239748AbhBDT6I (ORCPT + 99 others); Thu, 4 Feb 2021 14:58:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39162 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239517AbhBDTw5 (ORCPT ); Thu, 4 Feb 2021 14:52:57 -0500 Received: from mail-lf1-x12c.google.com (mail-lf1-x12c.google.com [IPv6:2a00:1450:4864:20::12c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8BE24C061786 for ; Thu, 4 Feb 2021 11:51:57 -0800 (PST) Received: by mail-lf1-x12c.google.com with SMTP id p21so6340412lfu.11 for ; Thu, 04 Feb 2021 11:51:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloudflare.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=FToFoRW57QEfMw0vp233PBaMzzSywEYZZwEWphiSDG8=; b=ABi2tO0tBxJZnGfCaPaqkq/u8P+eQGwDQnVphpXksukz3TmQZt9E9TiVZy1p7uj66y qQEVgjjAEjFyh66Updzzpfz9STCrXpmifd8ycnk8KZx2pG0geKmzXEC5/BqnRise+H5l xdEH+CYmH0wGBFhNHE+1aDgoEUqbGI2T6aBYQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=FToFoRW57QEfMw0vp233PBaMzzSywEYZZwEWphiSDG8=; b=fVoQrTOQh6t2/IhYU557Dn57WBzCGTFCDacbiSD9a3L0WyziJGqlK/JeOVaVn3rpS2 QO5X7vj+5TnbDwMyuK34pDQAujbGeZT5eh8rLHSFKPVSCz7+sj9CiZUoNTMrV2vW2HCl ZiEugLFS8wBB+3o+hjdjmA+eOYH6N7IvYQmEZsNhABv2M4lrzRVgNvaT1qmcBYwows3G oBhHqcFDcVBO1WDuTnlmfeY6NBB4xe+xiwkFNThI5Gf2Jx8dYI97EwKpq18RRK7bG1Mw HMLibHuFEL/dPBvCEruFEEgdoqIKsOJ+g4J605z5eZOBp4bghWGtjD77S0lmsbijK6eK Yjhg== X-Gm-Message-State: AOAM533ESiscky7INuRSuXtBdjY2gQAzQjTUJfev9f9v5anFPzuMS2Z0 DcyklXml0mmyFiepi7NLxPIzl6KbaVPEtNEYn9RGPQ== X-Received: by 2002:a05:6512:3904:: with SMTP id a4mr526525lfu.340.1612468315961; Thu, 04 Feb 2021 11:51:55 -0800 (PST) MIME-Version: 1.0 References: <20210203190518.nlwghesq75enas6n@treble> <20210203232735.nw73kugja56jp4ls@treble> <20210204001700.ry6dpqvavcswyvy7@treble> In-Reply-To: <20210204001700.ry6dpqvavcswyvy7@treble> From: Ivan Babrou Date: Thu, 4 Feb 2021 11:51:44 -0800 Message-ID: Subject: Re: BUG: KASAN: stack-out-of-bounds in unwind_next_frame+0x1df5/0x2650 To: Josh Poimboeuf Cc: kernel-team , Ignat Korchagin , Hailong liu , Andrey Ryabinin , Alexander Potapenko , Dmitry Vyukov , Andrew Morton , Thomas Gleixner , Ingo Molnar , Borislav Petkov , x86@kernel.org, "H. Peter Anvin" , Miroslav Benes , Julien Thierry , Jiri Slaby , kasan-dev@googlegroups.com, linux-mm@kvack.org, linux-kernel , Alasdair Kergon , Mike Snitzer , dm-devel@redhat.com, "Steven Rostedt (VMware)" , Alexei Starovoitov , Daniel Borkmann , Martin KaFai Lau , Song Liu , Yonghong Song , Andrii Nakryiko , John Fastabend , KP Singh , Robert Richter , "Joel Fernandes (Google)" , Mathieu Desnoyers , Linux Kernel Network Developers , bpf@vger.kernel.org, Alexey Kardashevskiy Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Feb 3, 2021 at 4:17 PM Josh Poimboeuf wrote: > > On Wed, Feb 03, 2021 at 03:30:35PM -0800, Ivan Babrou wrote: > > > > > Can you recreate with this patch, and add "unwind_debug" to the cmdline? > > > > > It will spit out a bunch of stack data. > > > > > > > > Here's the three I'm building: > > > > > > > > * https://github.com/bobrik/linux/tree/ivan/static-call-5.9 > > > > > > > > It contains: > > > > > > > > * v5.9 tag as the base > > > > * static_call-2020-10-12 tag > > > > * dm-crypt patches to reproduce the issue with KASAN > > > > * x86/unwind: Add 'unwind_debug' cmdline option > > > > * tracepoint: Fix race between tracing and removing tracepoint > > > > > > > > The very same issue can be reproduced on 5.10.11 with no patches, > > > > but I'm going with 5.9, since it boils down to static call changes. > > > > > > > > Here's the decoded stack from the kernel with unwind debug enabled: > > > > > > > > * https://gist.github.com/bobrik/ed052ac0ae44c880f3170299ad4af56b > > > > > > > > See my first email for the exact commands that trigger this. > > > > > > Thanks. Do you happen to have the original dmesg, before running it > > > through the post-processing script? > > > > Yes, here it is: > > > > * https://gist.github.com/bobrik/8c13e6a02555fb21cadabb74cdd6f9ab > > It appears the unwinder is getting lost in crypto code. No idea what > this has to do with static calls though. Or maybe you're seeing > multiple issues. > > Does this fix it? > > > diff --git a/arch/x86/crypto/Makefile b/arch/x86/crypto/Makefile > index a31de0c6ccde..36c55341137c 100644 > --- a/arch/x86/crypto/Makefile > +++ b/arch/x86/crypto/Makefile > @@ -2,7 +2,14 @@ > # > # x86 crypto algorithms > > -OBJECT_FILES_NON_STANDARD := y > +OBJECT_FILES_NON_STANDARD_sha256-avx2-asm.o := y > +OBJECT_FILES_NON_STANDARD_sha512-ssse3-asm.o := y > +OBJECT_FILES_NON_STANDARD_sha512-avx-asm.o := y > +OBJECT_FILES_NON_STANDARD_sha512-avx2-asm.o := y > +OBJECT_FILES_NON_STANDARD_crc32c-pcl-intel-asm_64.o := y > +OBJECT_FILES_NON_STANDARD_camellia-aesni-avx2-asm_64.o := y > +OBJECT_FILES_NON_STANDARD_sha1_avx2_x86_64_asm.o := y > +OBJECT_FILES_NON_STANDARD_sha1_ni_asm.o := y > > obj-$(CONFIG_CRYPTO_GLUE_HELPER_X86) += glue_helper.o > > diff --git a/arch/x86/crypto/aesni-intel_avx-x86_64.S b/arch/x86/crypto/aesni-intel_avx-x86_64.S > index 5fee47956f3b..59c36b88954f 100644 > --- a/arch/x86/crypto/aesni-intel_avx-x86_64.S > +++ b/arch/x86/crypto/aesni-intel_avx-x86_64.S > @@ -237,8 +237,8 @@ define_reg j %j > .noaltmacro > .endm > > -# need to push 4 registers into stack to maintain > -STACK_OFFSET = 8*4 > +# need to push 5 registers into stack to maintain > +STACK_OFFSET = 8*5 > > TMP1 = 16*0 # Temporary storage for AAD > TMP2 = 16*1 # Temporary storage for AES State 2 (State 1 is stored in an XMM register) > @@ -257,6 +257,8 @@ VARIABLE_OFFSET = 16*8 > > .macro FUNC_SAVE > #the number of pushes must equal STACK_OFFSET > + push %rbp > + mov %rsp, %rbp > push %r12 > push %r13 > push %r14 > @@ -271,12 +273,14 @@ VARIABLE_OFFSET = 16*8 > .endm > > .macro FUNC_RESTORE > + add $VARIABLE_OFFSET, %rsp > mov %r14, %rsp > > pop %r15 > pop %r14 > pop %r13 > pop %r12 > + pop %rbp > .endm > > # Encryption of a single block > This patch seems to fix the following warning: [ 147.995699][ C0] WARNING: stack going in the wrong direction? at glue_xts_req_128bit+0x21f/0x6f0 [glue_helper] Or at least I cannot see it anymore when combined with your other patch, not sure if it did the trick by itself. This sounds like a good reason to send them both.