Re: [RFC 2/3] abi_spec: hooks into syscall to allow pre and post checking

From: alexander . levin
Date: Wed Nov 23 2016 - 10:16:12 EST


On Mon, Nov 21, 2016 at 04:57:02PM +0100, Dmitry Vyukov wrote:
> On Mon, Nov 21, 2016 at 4:54 PM, Steven Rostedt <rostedt@xxxxxxxxxxx> wrote:
> > On Wed, 16 Nov 2016 17:37:01 +0000
> > alexander.levin@xxxxxxxxxxx wrote:
> >> #define __SYSCALL_DEFINEx(x, name, ...) \
> >> + extern const struct syscall_spec syscall_spec##name; \
> >> asmlinkage long sys##name(__MAP(x,__SC_DECL,__VA_ARGS__)) \
> >> __attribute__((alias(__stringify(SyS##name)))); \
> >> static inline long SYSC##name(__MAP(x,__SC_DECL,__VA_ARGS__)); \
> >> asmlinkage long SyS##name(__MAP(x,__SC_LONG,__VA_ARGS__)); \
> >> asmlinkage long SyS##name(__MAP(x,__SC_LONG,__VA_ARGS__)) \
> >> { \
> >> - long ret = SYSC##name(__MAP(x,__SC_CAST,__VA_ARGS__)); \
> >> + long ret; \
> >> + abispec_check_pre(&syscall_spec##name, __MAP(x,__SC_CAST,__VA_ARGS__)); \
> >> + ret = SYSC##name(__MAP(x,__SC_CAST,__VA_ARGS__)); \
> >> + abispec_check_post(&syscall_spec##name, ret, __MAP(x,__SC_CAST,__VA_ARGS__)); \
> >
> > Do you want this for DEFINE0() too? Or does this not care about system
> > calls with no arguments?
>
> This should care about syscalls without args:
> - we still may want to check return values
> - something like debug tracing would like to print them
> - there may also be some side effects (or absence of side effects)
> that we may want to check

Yes, agreed, I just missed that detail in my implementation.

--

Thanks,
Sasha