Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp2682365pxy; Mon, 3 May 2021 05:52:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy5aiQFuAsx/omU62tiwt8Qq+xWJKbs1LOqDsSl6xcFbYYPcTs/rlFhmXlhARu1Gmu9U7Tf X-Received: by 2002:a17:906:1fd1:: with SMTP id e17mr16923362ejt.419.1620046348000; Mon, 03 May 2021 05:52:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620046347; cv=none; d=google.com; s=arc-20160816; b=BoFw573UX5ndB9oCnnepCYzejeE2e+eHbhR2DuQSWPeCAhK17yxesRRinie9MAjHB0 KyyInf6vAM7bxnj1JhXll+NuLvTN+V1twGCwroGtqa1osu4tRyg2Pwo0mvZkNNiC+OTp HXTsaNokl38utBPaNqACTgrjUs7RAXYhL/Bc468WmnArcpXr0Cqq81JBYclOr57rGfVK Wsh71q+AZ1IgF6Aj5HnK/SvAzg2eiWyMceDBiEHeee8+wN2RkE7m+ipSp2+o2feEJEtm 6NT04Dt+SeBwf1wMAw0FwWc+ZGrxhgbOw82Y24DOjF/3qgU7Pa8JfvFT3dDkrQaOCk4l 2c6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=MU1V7MQihEu+KJpscrtBmUqeHfxQ/TteggSascxCRdE=; b=Fw7+ovQu6/jwFTHtFDXE1M8raHNVCdAeSzxV2sEOYVKFF4FqYt3RQzFIU1uXttXnoG NMwwR0/e92c827UNJ2/X2FIyg1fMoiwTbYsaulvZayaAZTSGFQKTraG2azPJuu/td5yh YhWjNh8I5cRnJFgUexL5t4SU/8tZeg5Bo7yE9Eg08MdRVK7k42z/Cgvhs2Xl75wfqgRF BZgvatMq7N60JOh6NtBhB5qv9hw3++CCgcjXub5gMe3WIFZFRasfxI3IVzIsNHiJeivk LXgHClkJB2OSfP1jjZasQxxHxbmiZ1PYHccPerS1kh0xzH1akiQRPAyAWFV3cV/x4WyA dT7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=YmlOlel2; 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=NONE sp=NONE dis=NONE) header.from=alien8.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i4si1562873ejg.211.2021.05.03.05.52.04; Mon, 03 May 2021 05:52:27 -0700 (PDT) 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=@alien8.de header.s=dkim header.b=YmlOlel2; 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=NONE sp=NONE dis=NONE) header.from=alien8.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233212AbhECLSA (ORCPT + 99 others); Mon, 3 May 2021 07:18:00 -0400 Received: from mail.skyhub.de ([5.9.137.197]:48030 "EHLO mail.skyhub.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232868AbhECLR7 (ORCPT ); Mon, 3 May 2021 07:17:59 -0400 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) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1620040624; 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: content-transfer-encoding:in-reply-to:in-reply-to: references:references; bh=MU1V7MQihEu+KJpscrtBmUqeHfxQ/TteggSascxCRdE=; b=YmlOlel2zQcfWUwcZjhQbd9PplzvrIA4gD0JDrWGUW1EtGky1JiWzVgj4aHSrlmaZdWT+t ZS/HTE3TvYw+RvljJhB+bT0M+WSH117CRt0Pb2v7ixGh6sBoziG6bWrbM2j0aJIgkJZ4Th Ir9iDO951GSCDzHWx2FAc7MdoimdObA= 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> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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