diff mbox series

[1/4] x86: add __X32_COND_SYSCALL() macro

Message ID 20200918132439.1475479-2-arnd@arndb.de (mailing list archive)
State New, archived
Headers show
Series syscalls: remove compat_alloc_user_space callers | expand

Commit Message

Arnd Bergmann Sept. 18, 2020, 1:24 p.m. UTC
sys_move_pages() is an optional syscall, and once we remove
the compat version of it in favor of the native one with an
in_compat_syscall() check, the x32 syscall table refers to
a __x32_sys_move_pages symbol that may not exist when the
syscall is disabled.

Change the COND_SYSCALL() definition on x86 to also include
the redirection for x32.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 arch/x86/include/asm/syscall_wrapper.h | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Christoph Hellwig Sept. 19, 2020, 5:35 a.m. UTC | #1
On Fri, Sep 18, 2020 at 03:24:36PM +0200, Arnd Bergmann wrote:
> sys_move_pages() is an optional syscall, and once we remove
> the compat version of it in favor of the native one with an
> in_compat_syscall() check, the x32 syscall table refers to
> a __x32_sys_move_pages symbol that may not exist when the
> syscall is disabled.
> 
> Change the COND_SYSCALL() definition on x86 to also include
> the redirection for x32.
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Adding the x86 maintainers and Brian Gerst.  Brian proposed another
problem to the mess that most of the compat syscall handlers used by
x32 here:

   https://lkml.org/lkml/2020/6/16/664

hpa didn't particularly like it, but with your and my pending series
we'll soon use more native than compat syscalls for x32, so something
will need to change..

> ---
>  arch/x86/include/asm/syscall_wrapper.h | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/arch/x86/include/asm/syscall_wrapper.h b/arch/x86/include/asm/syscall_wrapper.h
> index a84333adeef2..5eacd35a7f97 100644
> --- a/arch/x86/include/asm/syscall_wrapper.h
> +++ b/arch/x86/include/asm/syscall_wrapper.h
> @@ -171,12 +171,16 @@ extern long __ia32_sys_ni_syscall(const struct pt_regs *regs);
>  	__SYS_STUBx(x32, compat_sys##name,				\
>  		    SC_X86_64_REGS_TO_ARGS(x, __VA_ARGS__))
>  
> +#define __X32_COND_SYSCALL(name)					\
> +	__COND_SYSCALL(x32, sys_##name)
> +
>  #define __X32_COMPAT_COND_SYSCALL(name)					\
>  	__COND_SYSCALL(x32, compat_sys_##name)
>  
>  #define __X32_COMPAT_SYS_NI(name)					\
>  	__SYS_NI(x32, compat_sys_##name)
>  #else /* CONFIG_X86_X32 */
> +#define __X32_COND_SYSCALL(name)
>  #define __X32_COMPAT_SYS_STUB0(name)
>  #define __X32_COMPAT_SYS_STUBx(x, name, ...)
>  #define __X32_COMPAT_COND_SYSCALL(name)
> @@ -253,6 +257,7 @@ extern long __ia32_sys_ni_syscall(const struct pt_regs *regs);
>  	static long __do_sys_##sname(const struct pt_regs *__unused)
>  
>  #define COND_SYSCALL(name)						\
> +	__X32_COND_SYSCALL(name)					\
>  	__X64_COND_SYSCALL(name)					\
>  	__IA32_COND_SYSCALL(name)
>  
> -- 
> 2.27.0
> 
---end quoted text---
Andy Lutomirski Sept. 19, 2020, 4:23 p.m. UTC | #2
On Fri, Sep 18, 2020 at 10:35 PM Christoph Hellwig <hch@infradead.org> wrote:
>
> On Fri, Sep 18, 2020 at 03:24:36PM +0200, Arnd Bergmann wrote:
> > sys_move_pages() is an optional syscall, and once we remove
> > the compat version of it in favor of the native one with an
> > in_compat_syscall() check, the x32 syscall table refers to
> > a __x32_sys_move_pages symbol that may not exist when the
> > syscall is disabled.
> >
> > Change the COND_SYSCALL() definition on x86 to also include
> > the redirection for x32.
> >
> > Signed-off-by: Arnd Bergmann <arnd@arndb.de>
>
> Adding the x86 maintainers and Brian Gerst.  Brian proposed another
> problem to the mess that most of the compat syscall handlers used by
> x32 here:
>
>    https://lkml.org/lkml/2020/6/16/664
>
> hpa didn't particularly like it, but with your and my pending series
> we'll soon use more native than compat syscalls for x32, so something
> will need to change..

I'm fine with either solution.
H. Peter Anvin Sept. 19, 2020, 5:14 p.m. UTC | #3
On September 19, 2020 9:23:22 AM PDT, Andy Lutomirski <luto@kernel.org> wrote:
>On Fri, Sep 18, 2020 at 10:35 PM Christoph Hellwig <hch@infradead.org>
>wrote:
>>
>> On Fri, Sep 18, 2020 at 03:24:36PM +0200, Arnd Bergmann wrote:
>> > sys_move_pages() is an optional syscall, and once we remove
>> > the compat version of it in favor of the native one with an
>> > in_compat_syscall() check, the x32 syscall table refers to
>> > a __x32_sys_move_pages symbol that may not exist when the
>> > syscall is disabled.
>> >
>> > Change the COND_SYSCALL() definition on x86 to also include
>> > the redirection for x32.
>> >
>> > Signed-off-by: Arnd Bergmann <arnd@arndb.de>
>>
>> Adding the x86 maintainers and Brian Gerst.  Brian proposed another
>> problem to the mess that most of the compat syscall handlers used by
>> x32 here:
>>
>>    https://lkml.org/lkml/2020/6/16/664
>>
>> hpa didn't particularly like it, but with your and my pending series
>> we'll soon use more native than compat syscalls for x32, so something
>> will need to change..
>
>I'm fine with either solution.

My main objection was naming. x64 is a widely used synonym for x86-64, and so that is confusing.
Andy Lutomirski Sept. 19, 2020, 5:39 p.m. UTC | #4
> On Sep 19, 2020, at 10:14 AM, hpa@zytor.com wrote:
> 
> On September 19, 2020 9:23:22 AM PDT, Andy Lutomirski <luto@kernel.org> wrote:
>>> On Fri, Sep 18, 2020 at 10:35 PM Christoph Hellwig <hch@infradead.org>
>>> wrote:
>>> 
>>> On Fri, Sep 18, 2020 at 03:24:36PM +0200, Arnd Bergmann wrote:
>>>> sys_move_pages() is an optional syscall, and once we remove
>>>> the compat version of it in favor of the native one with an
>>>> in_compat_syscall() check, the x32 syscall table refers to
>>>> a __x32_sys_move_pages symbol that may not exist when the
>>>> syscall is disabled.
>>>> 
>>>> Change the COND_SYSCALL() definition on x86 to also include
>>>> the redirection for x32.
>>>> 
>>>> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
>>> 
>>> Adding the x86 maintainers and Brian Gerst.  Brian proposed another
>>> problem to the mess that most of the compat syscall handlers used by
>>> x32 here:
>>> 
>>>   https://lkml.org/lkml/2020/6/16/664
>>> 
>>> hpa didn't particularly like it, but with your and my pending series
>>> we'll soon use more native than compat syscalls for x32, so something
>>> will need to change..
>> 
>> I'm fine with either solution.
> 
> My main objection was naming. x64 is a widely used synonym for x86-64, and so that is confusing.
> 
> 

The way I deal with the syscall wrappers is that I assume the naming makes no sense whatsoever, and I go from there. With this perspective, the patches are neither an improvement nor a worsening of the current situation.

(Similarly, the last column of the tables is useless garbage.  My last attempt to fix that stalled.)
Brian Gerst Sept. 19, 2020, 5:45 p.m. UTC | #5
An alternative to the patch I proposed earlier would be to use aliases
with the __x32_ prefix for the common syscalls.

--
Brian Gerst

On Sat, Sep 19, 2020 at 1:14 PM <hpa@zytor.com> wrote:
>
> On September 19, 2020 9:23:22 AM PDT, Andy Lutomirski <luto@kernel.org> wrote:
> >On Fri, Sep 18, 2020 at 10:35 PM Christoph Hellwig <hch@infradead.org>
> >wrote:
> >>
> >> On Fri, Sep 18, 2020 at 03:24:36PM +0200, Arnd Bergmann wrote:
> >> > sys_move_pages() is an optional syscall, and once we remove
> >> > the compat version of it in favor of the native one with an
> >> > in_compat_syscall() check, the x32 syscall table refers to
> >> > a __x32_sys_move_pages symbol that may not exist when the
> >> > syscall is disabled.
> >> >
> >> > Change the COND_SYSCALL() definition on x86 to also include
> >> > the redirection for x32.
> >> >
> >> > Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> >>
> >> Adding the x86 maintainers and Brian Gerst.  Brian proposed another
> >> problem to the mess that most of the compat syscall handlers used by
> >> x32 here:
> >>
> >>    https://lkml.org/lkml/2020/6/16/664
> >>
> >> hpa didn't particularly like it, but with your and my pending series
> >> we'll soon use more native than compat syscalls for x32, so something
> >> will need to change..
> >
> >I'm fine with either solution.
>
> My main objection was naming. x64 is a widely used synonym for x86-64, and so that is confusing.
>
> --
> Sent from my Android device with K-9 Mail. Please excuse my brevity.
diff mbox series

Patch

diff --git a/arch/x86/include/asm/syscall_wrapper.h b/arch/x86/include/asm/syscall_wrapper.h
index a84333adeef2..5eacd35a7f97 100644
--- a/arch/x86/include/asm/syscall_wrapper.h
+++ b/arch/x86/include/asm/syscall_wrapper.h
@@ -171,12 +171,16 @@  extern long __ia32_sys_ni_syscall(const struct pt_regs *regs);
 	__SYS_STUBx(x32, compat_sys##name,				\
 		    SC_X86_64_REGS_TO_ARGS(x, __VA_ARGS__))
 
+#define __X32_COND_SYSCALL(name)					\
+	__COND_SYSCALL(x32, sys_##name)
+
 #define __X32_COMPAT_COND_SYSCALL(name)					\
 	__COND_SYSCALL(x32, compat_sys_##name)
 
 #define __X32_COMPAT_SYS_NI(name)					\
 	__SYS_NI(x32, compat_sys_##name)
 #else /* CONFIG_X86_X32 */
+#define __X32_COND_SYSCALL(name)
 #define __X32_COMPAT_SYS_STUB0(name)
 #define __X32_COMPAT_SYS_STUBx(x, name, ...)
 #define __X32_COMPAT_COND_SYSCALL(name)
@@ -253,6 +257,7 @@  extern long __ia32_sys_ni_syscall(const struct pt_regs *regs);
 	static long __do_sys_##sname(const struct pt_regs *__unused)
 
 #define COND_SYSCALL(name)						\
+	__X32_COND_SYSCALL(name)					\
 	__X64_COND_SYSCALL(name)					\
 	__IA32_COND_SYSCALL(name)