From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.skyhub.de (mail.skyhub.de [IPv6:2a01:4f8:190:11c2::b:1457]) by sourceware.org (Postfix) with ESMTPS id 3C07D3938C32 for ; Mon, 3 May 2021 11:17:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 3C07D3938C32 Received: from zn.tnic (p200300ec2f268e00596557e7a2777a9d.dip0.t-ipconnect.de [IPv6:2003:ec:2f26:8e00:5965:57e7:a277:7a9d]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id 38F741EC0419; Mon, 3 May 2021 13:17:04 +0200 (CEST) Date: Mon, 3 May 2021 13:17:02 +0200 From: Borislav Petkov To: Florian Weimer Cc: "Bae, Chang Seok" , Andy Lutomirski , "Cooper, Andrew" , Boris Ostrovsky , "Gross, Jurgen" , Stefano Stabellini , Thomas Gleixner , Ingo Molnar , X86 ML , "Brown, Len" , "Hansen, Dave" , "H. J. Lu" , Dave Martin , Jann Horn , Michael Ellerman , Carlos O'Donell , "Luck, Tony" , "Shankar, Ravi V" , libc-alpha , linux-arch , Linux API , LKML Subject: Re: [PATCH v7 5/6] x86/signal: Detect and prevent an alternate signal stack overflow Message-ID: References: <20210316065215.23768-6-chang.seok.bae@intel.com> <20210325185435.GB32296@zn.tnic> <20210326103041.GB25229@zn.tnic> <20210414101250.GD10709@zn.tnic> <87o8eh9k7w.fsf@oldenburg.str.redhat.com> <20210414120608.GE10709@zn.tnic> <877dkg8jv6.fsf@oldenburg.str.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <877dkg8jv6.fsf@oldenburg.str.redhat.com> X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 03 May 2021 11:17:10 -0000 On Mon, May 03, 2021 at 07:30:21AM +0200, Florian Weimer wrote: > Just to be clear, I'm worried about the case where an application > installs a stack overflow handler, but stack overflow does not regularly > happen at run time. GNU m4 is an example. Today, for most m4 scripts, > it's totally fine to have an alternative signal stack which is too > small. If the kernel returned an error for the sigaltstack call, m4 > wouldn't start anymore, independently of the script. Which is worse > than memory corruption with some scripts, I think. Oh lovely. > > > Or is this use case obsolete and this is not what people do at all? > > It's widely used in currently-maintained software. It's the only way to > recover from stack overflows without boundary checks on every function > call. > > Does the alternative signal stack actually have to contain the siginfo_t > data? I don't think it has to be contiguous. Maybe the kernel could > allocate and map something behind the processes back if the sigaltstack > region is too small? So there's an attempt floating around to address this: https://lkml.kernel.org/r/20210422044856.27250-1-chang.seok.bae@intel.com esp patch 3. I'd appreciate having a look and sanity-checking this whether it makes sense and could be useful this way... > And for the stack overflow handler, the kernel could treat SIGSEGV with > a sigaltstack region that is too small like the SIG_DFL handler. This > would make m4 work again. /me searches a bit about SIG_DFL... Do you mean that the default action in this case should be what SIGSEGV does by default - to dump core? Thx. -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette