From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-4.2 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI,NICE_REPLY_A, SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 87EAA1F4B4 for ; Wed, 20 Jan 2021 16:14:33 +0000 (UTC) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B157E396ECA3; Wed, 20 Jan 2021 16:14:32 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B157E396ECA3 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1611159272; bh=Lad1uHPnItt2h30i45RNcf50RD7bS69aVQ4eDKRX1L0=; h=Subject:To:References:Date:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=y6BWdA0DM3KWyhaqY17OnIGjF49aZPQ2FW59peWkokLIXMVyfBNxGXB+12tEcuPh8 SmP9/wCbPF1MgkCdFb91mtH2YhIL0q6fwB2h0s7kON2uhbvzPARHSbDAyqlgDJZP2i YOGc3RUPW4IB4whzrwtfMqyIJGKXoC0z0yqXi+XI= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by sourceware.org (Postfix) with ESMTP id B8938396EC37 for ; Wed, 20 Jan 2021 16:14:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org B8938396EC37 Received: from mail-qv1-f70.google.com (mail-qv1-f70.google.com [209.85.219.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-247-neTMu2zGNqGX-FfUmb-KhA-1; Wed, 20 Jan 2021 11:14:28 -0500 X-MC-Unique: neTMu2zGNqGX-FfUmb-KhA-1 Received: by mail-qv1-f70.google.com with SMTP id t18so23560972qva.6 for ; Wed, 20 Jan 2021 08:14:28 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:organization :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=Lad1uHPnItt2h30i45RNcf50RD7bS69aVQ4eDKRX1L0=; b=n+XZ/jl/xGLHPLbuASqw9fDtzmvIWD+oxEf48ztWwflWBCgfoNWMutEQW1YF1Njufm FmWIthgiXe9FSF3fMP4CPlY8M9GzIYhqNET2gXPnMDjTGbOoUB2sjkH18uELxxryWPhF aooeAGLue9fZrzgNEAM4jnqO/M1gdLd4kVGBuVF8dq1aELZQr8csP7G1gbNhi54fA7HP iypdZkJsECJaiMWC9g6zP9wtm9aS+1NkFUOKpFtb/wRIZvC+phUBV3cvXPa7auCCVLdB gEkmDQtNe2O6iqtefdKp5aZQ1HeE59lxDZ6JIQ2K72kNUsPdOUxBUteIs+GDpG5qIkPY KGKg== X-Gm-Message-State: AOAM533NBdDx2lzXaRbF1ZqJ/0c0UDFIJJ9rWFNYZLdIEkrKDM5+Rjye MktnIZOl9VhS4tyFa9T5KfZXBbSZDxeDvyikEmvn05BuMssHTtOuv8vK389d+iab0w9aVj00aI+ Gqwaq78pH6oPUZOijIERn X-Received: by 2002:a05:620a:16d5:: with SMTP id a21mr10366407qkn.188.1611159268330; Wed, 20 Jan 2021 08:14:28 -0800 (PST) X-Google-Smtp-Source: ABdhPJwa1sWajSI1FTyvSZwFHP82ogRLpD8pcZQV6w7EVxGoRn+kZbogXRcXHCwbvc+otqYOVRd6Zg== X-Received: by 2002:a05:620a:16d5:: with SMTP id a21mr10366381qkn.188.1611159268128; Wed, 20 Jan 2021 08:14:28 -0800 (PST) Received: from [192.168.1.16] (198-84-214-74.cpe.teksavvy.com. [198.84.214.74]) by smtp.gmail.com with ESMTPSA id h1sm1436705qtr.1.2021.01.20.08.14.26 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 20 Jan 2021 08:14:27 -0800 (PST) Subject: Re: [PATCH v4 2/4] x86/elf: Support a new ELF aux vector AT_MINSIGSTKSZ To: "Chang S. Bae" , bp@suse.de, tglx@linutronix.de, mingo@kernel.org, luto@kernel.org, x86@kernel.org References: <20210115211038.2072-1-chang.seok.bae@intel.com> <20210115211038.2072-3-chang.seok.bae@intel.com> Organization: Red Hat Message-ID: <46031a4a-3e4e-3a1d-1188-ed9af2cf95d1@redhat.com> Date: Wed, 20 Jan 2021 11:14:25 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 MIME-Version: 1.0 In-Reply-To: <20210115211038.2072-3-chang.seok.bae@intel.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit 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: , From: Carlos O'Donell via Libc-alpha Reply-To: Carlos O'Donell Cc: linux-arch@vger.kernel.org, len.brown@intel.com, tony.luck@intel.com, libc-alpha@sourceware.org, ravi.v.shankar@intel.com, jannh@google.com, linux-api@vger.kernel.org, linux-kernel@vger.kernel.org, Fenghua Yu , dave.hansen@intel.com, Dave.Martin@arm.com Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" On 1/15/21 4:10 PM, Chang S. Bae via Libc-alpha wrote: > Historically, signal.h defines MINSIGSTKSZ (2KB) and SIGSTKSZ (8KB), for > use by all architectures with sigaltstack(2). Over time, the hardware state > size grew, but these constants did not evolve. Today, literal use of these > constants on several architectures may result in signal stack overflow, and > thus user data corruption. > > A few years ago, the ARM team addressed this issue by establishing > getauxval(AT_MINSIGSTKSZ), such that the kernel can supply at runtime value > that is an appropriate replacement on the current and future hardware. > > Add getauxval(AT_MINSIGSTKSZ) support to x86, analogous to the support > added for ARM in commit 94b07c1f8c39 ("arm64: signal: Report signal frame > size to userspace via auxv"). The value of AT_MINSIGSTKSZ has been generic ABI for all architectures since 2018 when it was added to glibc's generic elf.h because of arm64. Rather than define this just for x86 may we please put this into the generic headers, since it has been there since 2018? Any userspace code that might be inspecting for AT_MINSIGSTKSZ is going to expect a value of 51. No other architecture has a define for value 51. This way we avoid any accidents with the value being different for architectures. > Reported-by: Florian Weimer > Fixes: c2bc11f10a39 ("x86, AVX-512: Enable AVX-512 States Context Switch") > Signed-off-by: Chang S. Bae > Reviewed-by: Len Brown > Cc: H.J. Lu > Cc: Fenghua Yu > Cc: Dave Martin > Cc: Michael Ellerman > Cc: x86@kernel.org > Cc: libc-alpha@sourceware.org > Cc: linux-arch@vger.kernel.org > Cc: linux-api@vger.kernel.org > Cc: linux-kernel@vger.kernel.org > Link: https://bugzilla.kernel.org/show_bug.cgi?id=153531 > --- > arch/x86/include/asm/elf.h | 4 ++++ > arch/x86/include/uapi/asm/auxvec.h | 6 ++++-- > arch/x86/kernel/signal.c | 5 +++++ > 3 files changed, 13 insertions(+), 2 deletions(-) > > diff --git a/arch/x86/include/asm/elf.h b/arch/x86/include/asm/elf.h > index b9a5d488f1a5..044b024abea1 100644 > --- a/arch/x86/include/asm/elf.h > +++ b/arch/x86/include/asm/elf.h > @@ -311,6 +311,7 @@ do { \ > NEW_AUX_ENT(AT_SYSINFO, VDSO_ENTRY); \ > NEW_AUX_ENT(AT_SYSINFO_EHDR, VDSO_CURRENT_BASE); \ > } \ > + NEW_AUX_ENT(AT_MINSIGSTKSZ, get_sigframe_size()); \ > } while (0) > > /* > @@ -327,6 +328,7 @@ extern unsigned long task_size_32bit(void); > extern unsigned long task_size_64bit(int full_addr_space); > extern unsigned long get_mmap_base(int is_legacy); > extern bool mmap_address_hint_valid(unsigned long addr, unsigned long len); > +extern unsigned long get_sigframe_size(void); > > #ifdef CONFIG_X86_32 > > @@ -348,6 +350,7 @@ do { \ > if (vdso64_enabled) \ > NEW_AUX_ENT(AT_SYSINFO_EHDR, \ > (unsigned long __force)current->mm->context.vdso); \ > + NEW_AUX_ENT(AT_MINSIGSTKSZ, get_sigframe_size()); \ > } while (0) > > /* As a historical oddity, the x32 and x86_64 vDSOs are controlled together. */ > @@ -356,6 +359,7 @@ do { \ > if (vdso64_enabled) \ > NEW_AUX_ENT(AT_SYSINFO_EHDR, \ > (unsigned long __force)current->mm->context.vdso); \ > + NEW_AUX_ENT(AT_MINSIGSTKSZ, get_sigframe_size()); \ > } while (0) > > #define AT_SYSINFO 32 > diff --git a/arch/x86/include/uapi/asm/auxvec.h b/arch/x86/include/uapi/asm/auxvec.h > index 580e3c567046..edd7808060e6 100644 > --- a/arch/x86/include/uapi/asm/auxvec.h > +++ b/arch/x86/include/uapi/asm/auxvec.h > @@ -10,11 +10,13 @@ > #endif > #define AT_SYSINFO_EHDR 33 > > +#define AT_MINSIGSTKSZ 51 This definition should go into the generic auxvec.h. We could also remove the arm64 define, but that is orthogonal arch cleanup. > + > /* entries in ARCH_DLINFO: */ > #if defined(CONFIG_IA32_EMULATION) || !defined(CONFIG_X86_64) > -# define AT_VECTOR_SIZE_ARCH 2 > +# define AT_VECTOR_SIZE_ARCH 3 > #else /* else it's non-compat x86-64 */ > -# define AT_VECTOR_SIZE_ARCH 1 > +# define AT_VECTOR_SIZE_ARCH 2 > #endif > > #endif /* _ASM_X86_AUXVEC_H */ > diff --git a/arch/x86/kernel/signal.c b/arch/x86/kernel/signal.c > index 138a9f5b78d8..761d856f8ef7 100644 > --- a/arch/x86/kernel/signal.c > +++ b/arch/x86/kernel/signal.c > @@ -716,6 +716,11 @@ void __init init_sigframe_size(void) > max_frame_size = round_up(max_frame_size, FRAME_ALIGNMENT); > } > > +unsigned long get_sigframe_size(void) > +{ > + return max_frame_size; > +} > + > static inline int is_ia32_compat_frame(struct ksignal *ksig) > { > return IS_ENABLED(CONFIG_IA32_EMULATION) && > -- Cheers, Carlos.