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=-5.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=no 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 BE451C433ED for ; Wed, 12 May 2021 22:19:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 81C3460FDB for ; Wed, 12 May 2021 22:19:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348641AbhELWJ3 (ORCPT ); Wed, 12 May 2021 18:09:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36240 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1389927AbhELVEB (ORCPT ); Wed, 12 May 2021 17:04:01 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A686DC0611B5; Wed, 12 May 2021 13:55:06 -0700 (PDT) From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1620852905; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=L34T/UenUIuq4jeGVl6/Hdv4Eqp08Y7XCNJ8f0KJUjw=; b=Kg6kVYoIgblFaV2cgbUMCuWDceMtbJKTH7blWXawUSb9swAZzsfkOgzIqfxU5BtUj3AY7f YY55SOAhpRrVy03NlQRTSQeJWiEK6V6ttfRw7nZEqMTL2q9Sc4aq+rtQlEvRuckkyeXk/U x0tNZajCa7SboBoCLmjsoNNzHs9hcZpBsPbYIeq68GhoORMLQPyWQqPzoWMbzOS4gQmTqe Ba/Z7AkzJjEdwsUreBxEx7bEPAy5saURcxpKEBy3rkC1tj8mBcR8H7dMiMMdKanVDx5gW4 rwL2hqIaBrcSMhrGhn3qBF/eBYzDtmqTrty4b4UeOKxvIMLslWdo4Lczwrm8jQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1620852905; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=L34T/UenUIuq4jeGVl6/Hdv4Eqp08Y7XCNJ8f0KJUjw=; b=JvwFIWeD/Oq7qlJnp6Q65ddy634JUD+/dlVZhUnx7W3Ov7Mqdcu0qt/GeIbtd9/FTKxIpc ONMasOCGz62hbLCA== To: "Bae\, Chang Seok" , Borislav Petkov Cc: Andy Lutomirski , "bp\@suse.de" , "mingo\@kernel.org" , "x86\@kernel.org" , "Brown\, Len" , "Hansen\, Dave" , "hjl.tools\@gmail.com" , "Dave.Martin\@arm.com" , "jannh\@google.com" , "mpe\@ellerman.id.au" , "carlos\@redhat.com" , "Luck\, Tony" , "Shankar\, Ravi V" , "libc-alpha\@sourceware.org" , "linux-arch\@vger.kernel.org" , "linux-api\@vger.kernel.org" , "linux-kernel\@vger.kernel.org" Subject: Re: [PATCH v8 5/6] x86/signal: Detect and prevent an alternate signal stack overflow In-Reply-To: References: <20210422044856.27250-1-chang.seok.bae@intel.com> <20210422044856.27250-6-chang.seok.bae@intel.com> Date: Wed, 12 May 2021 22:55:04 +0200 Message-ID: <87pmxv65av.ffs@nanos.tec.linutronix.de> MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, May 12 2021 at 18:48, Chang Seok Bae wrote: > On May 11, 2021, at 11:36, Borislav Petkov wrote: >> >> I clumsily tried to register a SIGSEGV handler with >> >> act.sa_sigaction = my_sigsegv; >> sigaction(SIGSEGV, &act, NULL); >> >> but that doesn't fire - task gets killed. Maybe I'm doing it wrong. > > Since the altstack is already overflowed, perhaps set the flag like this -- not > using it to get the handler: > > act.sa_sigaction = my_sigsegv; > + act.sa_flags = SA_SIGINFO; > sigaction(SIGSEGV, &act, NULL); > > FWIW, I think this is just a workaround for this case; in practice, altstack is > rather a backup for normal stack corruption. That's the intended usage, but it's not limited to that and there exists creative (ab)use of sigaltstack beyond catching the overflow of the regular stack. Thanks, tglx