Re: [PATCH v3 01/23] x86/elf: Check in_x32_syscall() in compat_arch_setup_additional_pages()

From: Dmitry Safonov
Date: Mon Jun 21 2021 - 17:00:08 EST


Hi Thomas,

On 6/19/21 9:41 PM, Thomas Gleixner wrote:
> On Fri, Jun 11 2021 at 19:02, Dmitry Safonov wrote:
>> Partly revert commit 3316ec8ccd34 ("x86/elf: Use e_machine to check for
>> x32/ia32 in setup_additional_pages()") and commit 9a29a671902c ("elf:
>> Expose ELF header on arch_setup_additional_pages()".
>> Both patches did a good thing: removed usage of TIF_X32, but with
>> a price of additional macros ARCH_SETUP_ADDITIONAL_PAGES() and ifdeffs.
>>
>> Instead, use in_x32_syscall() - the first thing load_elf_binary() does
>> after parsing and checking new ELF binary. It's done that early after
>> exec() that mmap() code already uses it straight away, which is needed
>> to know which mmap_base to use (see arch_pick_mmap_layout()).
>> Add comments to describe how it works.
>
> I still have no idea what this is trying to solve. All you describe is
> what this does.

Yeah, I still have problems with describing why rather than what sometimes..

How about something like this:

In order to simplify code, new macro ARCH_SETUP_ADDITIONAL_PAGES() can
be dropped as well as a new argument in
compat_arch_setup_additional_pages(). Resulting in partial revert of the
commit 3316ec8ccd34 ("x86/elf: Use e_machine to check for x32/ia32 in
setup_additional_pages()") and the commit 9a29a671902c ("elf: Expose ELF
header on arch_setup_additional_pages()".

Instead of a new macro and an additional function argument, use
in_x32_syscall() which is already valid at the moment of premapping
vDSO. Add comments to describe how it works.

Thanks for reviewing,
Dmitry