From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C454AC433DB for ; Thu, 4 Feb 2021 19:51:59 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 41F1264F38 for ; Thu, 4 Feb 2021 19:51:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 41F1264F38 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=cloudflare.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id B2C636B006E; Thu, 4 Feb 2021 14:51:58 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B0B396B0070; Thu, 4 Feb 2021 14:51:58 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9CB3D6B0071; Thu, 4 Feb 2021 14:51:58 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0066.hostedemail.com [216.40.44.66]) by kanga.kvack.org (Postfix) with ESMTP id 85F0B6B006E for ; Thu, 4 Feb 2021 14:51:58 -0500 (EST) Received: from smtpin05.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 56CC68249980 for ; Thu, 4 Feb 2021 19:51:58 +0000 (UTC) X-FDA: 77781631116.05.wood42_3716c13275de Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin05.hostedemail.com (Postfix) with ESMTP id 3AB2418033D37 for ; Thu, 4 Feb 2021 19:51:58 +0000 (UTC) X-HE-Tag: wood42_3716c13275de X-Filterd-Recvd-Size: 8078 Received: from mail-lf1-f44.google.com (mail-lf1-f44.google.com [209.85.167.44]) by imf26.hostedemail.com (Postfix) with ESMTP for ; Thu, 4 Feb 2021 19:51:57 +0000 (UTC) Received: by mail-lf1-f44.google.com with SMTP id a8so6362182lfi.8 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=MKONB5oZHelCU/30TUQd8+sX7She0/juONUaHCv8mJaI7rzxf0Z/sVN08D09JA1BvI 69ISwtEIYrxK2ENHlzMEJG2vsYnsYGTaXqLObTsIh2m3vI651G/4Dmiq10ds1ehjl4oG mfRK6lVc+2/q6Et6AS34MbXJnQz1KGtWyIG5KeXkKUH7Q9yAB1/nPBPq0yfcT295hrbf OC75sqdZRZY+CP9ubmtcOcJfAT3fPdK5BkQ2TBvSdp/7kj42S5i6MsOwG4Qa5VLKY9Il +1X7ZG4T0WlIkwWs1u5eCA7ANkl+no8jmIBsK1KaFra+2ggrI0h69W2TQWThMLjifTGe fTzQ== X-Gm-Message-State: AOAM533GPxzs7jdCkkh4NRPgLK72lzkeg/M6Iltu+HBW92yrk+SN15IO +Bfr9Ot46nsKBfNpYwsx98igc00XkbZ+MnkQrZJOrA== X-Google-Smtp-Source: ABdhPJw6yc26ixa+BNP3THtxCTWaeQD524mnhSMrIKSYnAhxtWx3VpBmUou9Z3mhYHUs2DgfYkVuuxjVCVG8de8YSi0= 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" X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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.