lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Tue, 25 Aug 2009 15:04:15 -0400
From:	Mathieu Desnoyers <mathieu.desnoyers@...ymtl.ca>
To:	Jason Baron <jbaron@...hat.com>
Cc:	Steven Rostedt <rostedt@...dmis.org>,
	Frederic Weisbecker <fweisbec@...il.com>,
	linux-kernel@...r.kernel.org, x86@...nel.org, lethal@...ux-sh.org,
	mingo@...e.hu, laijs@...fujitsu.com, peterz@...radead.org,
	jiayingz@...gle.com, mbligh@...gle.com, lizf@...fujitsu.com,
	jistone@...hat.com, tglx@...utronix.de, hpa@...or.com
Subject: Re: [PATCH 2/4] Add NR_syscalls for x86_64

* Jason Baron (jbaron@...hat.com) wrote:
> On Tue, Aug 25, 2009 at 09:40:05AM -0400, Jason Baron wrote:
> > > > On Mon, Aug 24, 2009 at 05:40:18PM -0400, Jason Baron wrote:
> > > > > Add a dynamic definition of NR_syscalls for x86_64. This is used in the 
> > > > > syscall events tracing code.
> > > > > 
> > > > > Signed-off-by: Jason Baron <jbaron@...hat.com>
> > > > > 
> > > > > ---
> > > > >  include/linux/ftrace.h |    5 +++++
> > > > >  1 files changed, 5 insertions(+), 0 deletions(-)
> > > > > 
> > > > > diff --git a/include/linux/ftrace.h b/include/linux/ftrace.h
> > > > > index dc3b132..3bd94ee 100644
> > > > > --- a/include/linux/ftrace.h
> > > > > +++ b/include/linux/ftrace.h
> > > > > @@ -14,6 +14,11 @@
> > > > >  
> > > > >  #include <asm/ftrace.h>
> > > > >  
> > > > > +#ifdef CONFIG_X86_64
> > > > > +#include <asm/asm-offsets.h>
> > > > > +#define NR_syscalls (__NR_syscall_max + 1)
> > > > > +#endif
> > > > > +
> > > > 
> > > > 
> > > > I'd rather see this in arch/x86/include/unistd_64.h, since
> > > > NR_syscalls seems to be the defined in unistd.h in all archs.
> > > > 
> > > > That also makes a unified way to retrieve this number for
> > > > other users.
> > > > 
> > > 
> > > Yes, NR_syscalls should be included there.
> > > 
> > > -- Steve
> > 
> > right, for x86_64, unistd.h is included to generate __NR_syscall_max
> > which is then used for NR_syscalls. So I did initially try it there, but
> > there were dependency problems. I'll see what I can come up with...
> > 
> > thanks,
> > 
> > -Jason
> 
> ok, since unistd_64.h is used to generate offsets.c, which eventually
> generates, asm/asm-offsets.h, which defines, __NR_syscall_max, we can't
> just put #define of NR_syscalls in unistd_64.h. However, it seems the
> only point in time that unistd_64.h can not depend upon __NR_syscall_max,
> is before asm/asm-offsets.h is defined. Thus, the patch below passes in
> a '-DCREATE_OFFSETS' during the creation of asm/asm-offsets.h, so that
> we do not include it before it exists. The patch is hacky but works.
> thoughts?

Ugh! My eyes hurt!

What you are doing here is to basically put back the hardcoded
NR_syscalls rather that using the build infrastructure already in place.

If my memory serves me well, unistd_64.h generates __NR_syscall_max
automatically by being included multiples times. Can we generalize this
and make the information generated available in an automaticaly
generated header instead ? It is saved in ams-offsets.h currently as
"__NR_syscall_max". We could also save it somewhere else meant to be
included by C code.

Mathieu

> 
> Signed-off-by: Jason Baron <jbaron@...hat.com>
> 
> ---
> 
>  Kbuild                           |    2 +-
>  arch/x86/include/asm/unistd_64.h |    6 ++++++
>  scripts/Makefile.build           |    4 ++++
>  3 files changed, 11 insertions(+), 1 deletions(-)
> 
> 
> diff --git a/Kbuild b/Kbuild
> index f056b4f..5f43d4d 100644
> --- a/Kbuild
> +++ b/Kbuild
> @@ -78,7 +78,7 @@ endef
>  arch/$(SRCARCH)/kernel/asm-offsets.s: arch/$(SRCARCH)/kernel/asm-offsets.c \
>                                        $(obj)/$(bounds-file) FORCE
>  	$(Q)mkdir -p $(dir $@)
> -	$(call if_changed_dep,cc_s_c)
> +	$(call if_changed_dep,cc_s_c_define_offset)
>  
>  $(obj)/$(offsets-file): arch/$(SRCARCH)/kernel/asm-offsets.s Kbuild
>  	$(call cmd,offsets)
> diff --git a/arch/x86/include/asm/unistd_64.h b/arch/x86/include/asm/unistd_64.h
> index 900e161..70c0c3d 100644
> --- a/arch/x86/include/asm/unistd_64.h
> +++ b/arch/x86/include/asm/unistd_64.h
> @@ -688,6 +688,12 @@ __SYSCALL(__NR_perf_counter_open, sys_perf_counter_open)
>  #endif	/* __NO_STUBS */
>  
>  #ifdef __KERNEL__
> +
> +#ifndef CREATE_OFFSETS
> +#include <asm/asm-offsets.h>
> +#define NR_syscalls (__NR_syscall_max + 1)
> +#endif
> +
>  /*
>   * "Conditional" syscalls
>   *
> diff --git a/scripts/Makefile.build b/scripts/Makefile.build
> index 5c4b7a4..4177858 100644
> --- a/scripts/Makefile.build
> +++ b/scripts/Makefile.build
> @@ -145,6 +145,10 @@ $(multi-objs-y:.o=.lst) : modname = $(modname-multi)
>  quiet_cmd_cc_s_c = CC $(quiet_modtag)  $@
>  cmd_cc_s_c       = $(CC) $(c_flags) -fverbose-asm -S -o $@ $<
>  
> +quiet_cmd_cc_s_c_define_offset = CC $(quiet_modtag)  $@
> +cmd_cc_s_c_define_offset       = $(CC) $(c_flags) -DCREATE_OFFSETS \
> +					-fverbose-asm -S -o $@ $<
> +
>  $(obj)/%.s: $(src)/%.c FORCE
>  	$(call if_changed_dep,cc_s_c)
>  
> 
> 
> 
> 

-- 
Mathieu Desnoyers
OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F  BA06 3F25 A8FE 3BAE 9A68
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ