Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp497682pxu; Tue, 6 Oct 2020 11:22:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzXmzlE7O5EKCrwhS2o3FNG6GoNZsXUGA2j+WzxdtAcO0Af4bhVwdaM9/mIjBDG6STj8T/W X-Received: by 2002:a17:906:f89:: with SMTP id q9mr818247ejj.337.1602008572015; Tue, 06 Oct 2020 11:22:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602008572; cv=none; d=google.com; s=arc-20160816; b=e5MtbvO+Mf+HZqksP2FOxb98KcG9ea5xpNUGSwjDrgwRnNX2OPACoRMNir/oE4yjbl xS/WayOgBxLkfhNJoXJ0h/Gh1GiKsbKH9j1JsRuwToLg75m9CSGw+jE4DYeomrxU3qkm S/pDeLaYHSSA7ycrU+nLjNFGaQJAbp2lJIn3T/L2f9YaTeMPUZpBjVCp0gENQEKIBrnG PqTDTR56jKu6F5CdWAFPELoSVZsiCu3mWiFn7J1gk08wmFaH3t44S2P0isjIZvy7wN8D h2Slbb1YLhZ3IIQAFU7TxqU5Nju/3uV/zLRsoqlEp5ZB6sCNinA3/Gn+2J8+zBHPVLId f73A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:message-id:in-reply-to :date:references:subject:cc:to:from:dkim-signature; bh=vLEPMopDgwBeHhoD6xTsXdWXnyecjzlObkKeapKxZb8=; b=upCMyXcmSWTRMWTaLB6U0du4wR2UNK0kZlgoJDdCFdBm2JIB3zmlshFZ5AQudjCmlR BttvBzWZis3X+yEd8GrE3oCjtvePvkNR14Wd+oedeRejKv9OGVZt3ofoLeOzHt51UCBd C2KvR/NbvIZiULXmDuzPZ9imZuOflmsMBszK70AEwcAKXvrT9gP/VVGlDv5/kdTVRY0e g79GTNxgTOgm7usGWrvdqllRE/h4QyXP7n0SI0V1B3XX1Kqg+f/4OrBVyxgcuOfon1Tn p52u7KxjyLqeVIegoNgOUznAyOMgR4brAVvXyB+RiDw1T+ScUJn2cicQSiddmZoI6PIY egoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=IJsCv7rV; 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i10si3046612edf.377.2020.10.06.11.22.28; Tue, 06 Oct 2020 11:22:52 -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=@redhat.com header.s=mimecast20190719 header.b=IJsCv7rV; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726775AbgJFSVM (ORCPT + 99 others); Tue, 6 Oct 2020 14:21:12 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:53821 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725906AbgJFSVL (ORCPT ); Tue, 6 Oct 2020 14:21:11 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1602008470; 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=vLEPMopDgwBeHhoD6xTsXdWXnyecjzlObkKeapKxZb8=; b=IJsCv7rVm4ItwWK/UO6AshW+T9xN00MAwWw8GovePUb6F6ppvf9dmmXeW3K/eLkNpPVhsP XOwRx5/Rn7i6Y/thmZMOU9m6SyFSCRf3duKwDAZTUmS8LmYDjRLDv2U5jEZxKcyHaU4j8Z UCZw7jIym68VuJKcFm6QmhIN/zJcJ6w= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-461-alcayjT3P7G1iHsDj3bAkg-1; Tue, 06 Oct 2020 14:21:08 -0400 X-MC-Unique: alcayjT3P7G1iHsDj3bAkg-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 777FF64088; Tue, 6 Oct 2020 18:21:05 +0000 (UTC) Received: from oldenburg2.str.redhat.com (ovpn-113-154.ams2.redhat.com [10.36.113.154]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E2F4F60BFA; Tue, 6 Oct 2020 18:21:01 +0000 (UTC) From: Florian Weimer To: Dave Martin via Libc-alpha Cc: Dave Hansen , Dave Martin , linux-arch , Tony Luck , "Ravi V. Shankar" , Len Brown , "Chang S. Bae" , the arch/x86 maintainers , LKML , Andy Lutomirski , Linux API , Thomas Gleixner , Borislav Petkov , Ingo Molnar Subject: Re: [RFC PATCH 0/4] x86: Improve Minimum Alternate Stack Size References: <20200929205746.6763-1-chang.seok.bae@intel.com> <20201005134534.GT6642@arm.com> <20201006092532.GU6642@arm.com> <20201006152553.GY6642@arm.com> <7663eff0-6c94-f6bf-f3e2-93ede50e75ed@intel.com> <20201006170020.GB6642@arm.com> Date: Tue, 06 Oct 2020 20:21:00 +0200 In-Reply-To: <20201006170020.GB6642@arm.com> (Dave Martin via Libc-alpha's message of "Tue, 6 Oct 2020 18:00:21 +0100") Message-ID: <87362rp65v.fsf@oldenburg2.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org * Dave Martin via Libc-alpha: > On Tue, Oct 06, 2020 at 08:33:47AM -0700, Dave Hansen wrote: >> On 10/6/20 8:25 AM, Dave Martin wrote: >> > Or are people reporting real stack overruns on x86 today? >> >> We have real overruns. We have ~2800 bytes of XSAVE (regisiter) state >> mostly from AVX-512, and a 2048 byte MINSIGSTKSZ. > > Right. Out of interest, do you believe that's a direct consequence of > the larger kernel-generated signal frame, or does the expansion of > userspace stack frames play a role too? I must say that I do not quite understand this question. 32 64-*byte* registers simply need 2048 bytes of storage space worst case, there is really no way around that. > In practice software just assumes SIGSTKSZ and then ignores the problem > until / unless an actual stack overflow is seen. > > There's probably a lot of software out there whose stack is > theoretically too small even without AVX-512 etc. in the mix, especially > when considering the possibility of nested signals... That is certainly true. We have seen problems with ntpd, which requested a 16 KiB stack, at a time when there were various deductions from the stack size, and since the glibc dynamic loader also uses XSAVE, ntpd exceeded the remaining stack space. But in this case, we just fudged the stack size computation in pthread_create and made it less likely that the dynamic loader was activated, which largely worked around this particular problem. For MINSIGSTKSZ, we just don't have this option because it's simply too small in the first place. I don't immediately recall a bug due to SIGSTKSZ being too small. The test cases I wrote for this were all artificial, to raise awareness of this issue (applications treating these as recommended values, rather than minimum value to avoid immediately sigaltstack/phtread_create failures, same issue with PTHREAD_STACK_MIN). Thanks, Florian -- Red Hat GmbH, https://de.redhat.com/ , Registered seat: Grasbrunn, Commercial register: Amtsgericht Muenchen, HRB 153243, Managing Directors: Charles Cachera, Brian Klemm, Laurie Krebs, Michael O'Neill