Re: [PATCH 0/3] syscalls: clean up stub naming convention

From: Ingo Molnar
Date: Mon Apr 09 2018 - 02:39:33 EST


* Dominik Brodowski <linux@xxxxxxxxxxxxxxxxxxxx> wrote:

> > One more fundamental question: why do we have the __do_sys_waitid() and
> > __inline_sys_waitid() distinction - aren't the function call signatures the same
> > with no conversion done?
> >
> > I.e. couldn't we just do a single, static __do_sys_waitid(), where the compiler
> > would decide to what extent inlining is justified? This would allow the compiler
> > to inline all the intermediate code into the stubs themselves.
> >
> > Or is this a side effect of the error injection feature, which needs to add extra
> > logic at this intermediate level? That too should be able to use the
> > __do_sys_waitid() variant though.
>
> Error injection is unrelated. It seems to be for three reasons, if I read
> the code (include/linux/syscalls.h) correctly:
>
> asmlinkage long __do_sys##name(__MAP(x,__SC_LONG,__VA_ARGS__))
>
> 1) This takes arguments of type long (to protect against CVE-2009-0029);
> see https://lwn.net/Articles/604287/ : "Digging into the history of
> this, it turns out that the long version ensures that 32-bit values
> are correctly sign-extended for some 64-bit kernel platforms,
> preventing a historical vulnerability."
>
> {
> long ret = __in_sys##name(__MAP(x,__SC_CAST,__VA_ARGS__));
> __MAP(x,__SC_TEST,__VA_ARGS__);

I see - so it's _not_ the same function call signature, but a wrapper with a
sign-extended version, which is fair and useful. So on architectures where this
matters there's type conversion and active code generated.

Thanks,

Ingo