From: "Bae, Chang Seok" <chang.seok.bae@intel.com>
To: Borislav Petkov <bp@alien8.de>
Cc: Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@kernel.org>, Andy Lutomirski <luto@kernel.org>,
"x86@kernel.org" <x86@kernel.org>,
"Brown, Len" <len.brown@intel.com>,
"Hansen, Dave" <dave.hansen@intel.com>,
"hjl.tools@gmail.com" <hjl.tools@gmail.com>,
"Dave.Martin@arm.com" <Dave.Martin@arm.com>,
"mpe@ellerman.id.au" <mpe@ellerman.id.au>,
"Luck, Tony" <tony.luck@intel.com>,
"Shankar, Ravi V" <ravi.v.shankar@intel.com>,
"libc-alpha@sourceware.org" <libc-alpha@sourceware.org>,
"linux-arch@vger.kernel.org" <linux-arch@vger.kernel.org>,
"linux-api@vger.kernel.org" <linux-api@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2 1/4] x86/signal: Introduce helpers to get the maximum signal frame size
Date: Mon, 30 Nov 2020 20:40:32 +0000 [thread overview]
Message-ID: <FFC7041A-2CCA-4C7E-A9C9-6C2C30CE7D28@intel.com> (raw)
In-Reply-To: <20201125111630.GA10378@zn.tnic>
> On Nov 25, 2020, at 20:17, Borislav Petkov <bp@alien8.de> wrote:
>
> On Thu, Nov 19, 2020 at 11:02:34AM -0800, Chang S. Bae wrote:
>> diff --git a/arch/x86/include/asm/sigframe.h b/arch/x86/include/asm/sigframe.h
>> index 84eab2724875..ac77f3f90bc9 100644
>> --- a/arch/x86/include/asm/sigframe.h
>> +++ b/arch/x86/include/asm/sigframe.h
>> @@ -52,6 +52,15 @@ struct rt_sigframe_ia32 {
>> char retcode[8];
>> /* fp state follows here */
>> };
>> +
>> +#define SIZEOF_sigframe_ia32 sizeof(struct sigframe_ia32)
>> +#define SIZEOF_rt_sigframe_ia32 sizeof(struct rt_sigframe_ia32)
>> +
>> +#else
>> +
>> +#define SIZEOF_sigframe_ia32 0
>> +#define SIZEOF_rt_sigframe_ia32 0
>> +
>> #endif /* defined(CONFIG_X86_32) || defined(CONFIG_IA32_EMULATION) */
>>
>> #ifdef CONFIG_X86_64
>> @@ -81,8 +90,22 @@ struct rt_sigframe_x32 {
>> /* fp state follows here */
>> };
>>
>> +#define SIZEOF_rt_sigframe_x32 sizeof(struct rt_sigframe_x32)
>> +
>> #endif /* CONFIG_X86_X32_ABI */
>>
>> +#define SIZEOF_rt_sigframe sizeof(struct rt_sigframe)
>> +
>> +#else
>> +
>> +#define SIZEOF_rt_sigframe 0
>> +
>> #endif /* CONFIG_X86_64 */
>>
>> +#ifndef SIZEOF_rt_sigframe_x32
>> +#define SIZEOF_rt_sigframe_x32 0
>> +#endif
>
> Those are defined here to be used in only one place -
> init_sigframe_size() - where there already is ifdeffery. Just use the
> normal sizeof() operator there instead of adding more gunk here.
[ Just want to clarify your comment. ]
Admittedly, this is an (ugly) workaround to avoid compile errors.
E.g. when code is written like this in the function:
if (IS_ENABLED(CONFIG_X86_X32_ABI))
size = max(size, sizeof(struct rt_sigframe_x32));
and compile with CONFIG_X86_X32_ABI=n, got such a message:
"invalid application of 'sizeof' to incomplete type 'struct
sigframe_ia32’"
While the coding-style doc [1] seems to mention this:
"However, this approach still allows the C compiler to see the
code inside the block, and check it for correctness (syntax,
types, symbol references, etc). Thus, you still have to use an
#ifdef if the code inside the block references symbols that
will not exist if the condition is not met.”
In general, putting #ifdef in a C file is advised to avoid. I wonder
whether it is okay to include #ifdef in the C file in this case.
Thanks,
Chang
[1] https://www.kernel.org/doc/html/v5.9/process/coding-style.html
next prev parent reply other threads:[~2020-11-30 20:41 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-19 19:02 [PATCH v2 0/4] x86: Improve Minimum Alternate Stack Size Chang S. Bae
2020-11-19 19:02 ` [PATCH v2 1/4] x86/signal: Introduce helpers to get the maximum signal frame size Chang S. Bae
2020-11-25 11:17 ` Borislav Petkov
2020-11-30 20:40 ` Bae, Chang Seok [this message]
2020-12-01 14:27 ` Borislav Petkov
2020-11-19 19:02 ` [PATCH v2 2/4] x86/elf: Support a new ELF aux vector AT_MINSIGSTKSZ Chang S. Bae
2020-11-26 17:44 ` Borislav Petkov
2020-11-27 9:30 ` Michael Kerrisk (man-pages)
2020-11-19 19:02 ` [PATCH v2 3/4] x86/signal: Prevent an alternate stack overflow before a signal delivery Chang S. Bae
2020-11-20 23:04 ` Jann Horn
2020-11-24 18:22 ` Bae, Chang Seok
2020-11-24 18:41 ` Jann Horn
2020-11-24 20:43 ` Bae, Chang Seok
2020-11-24 20:47 ` Jann Horn
2020-11-24 20:55 ` Bae, Chang Seok
2021-02-08 20:29 ` Bae, Chang Seok
2020-11-19 19:02 ` [PATCH v2 4/4] selftest/x86/signal: Include test cases for validating sigaltstack Chang S. Bae
2020-11-27 17:32 ` Borislav Petkov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=FFC7041A-2CCA-4C7E-A9C9-6C2C30CE7D28@intel.com \
--to=chang.seok.bae@intel.com \
--cc=Dave.Martin@arm.com \
--cc=bp@alien8.de \
--cc=dave.hansen@intel.com \
--cc=hjl.tools@gmail.com \
--cc=len.brown@intel.com \
--cc=libc-alpha@sourceware.org \
--cc=linux-api@vger.kernel.org \
--cc=linux-arch@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@kernel.org \
--cc=mingo@kernel.org \
--cc=mpe@ellerman.id.au \
--cc=ravi.v.shankar@intel.com \
--cc=tglx@linutronix.de \
--cc=tony.luck@intel.com \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®