Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1348057

Re: [PATCH 01/10] selftests/x86: In syscall_nt, test NT|TF as well

From One Thousand Gnomes <gnomes@lxorguk.ukuu.org.uk>
Newsgroups linux.kernel
Subject Re: [PATCH 01/10] selftests/x86: In syscall_nt, test NT|TF as well
Date 2016-03-02 15:10 +0100
Message-ID <r8fDs-gr-33@gated-at.bofh.it> (permalink)
References <r7oz8-6aX-5@gated-at.bofh.it> <r7oz8-6aX-7@gated-at.bofh.it> <r8eHo-80v-3@gated-at.bofh.it>
Organization Intel Corporation

Show all headers | View raw


On Wed, 2 Mar 2016 13:59:52 +0100
Borislav Petkov <bp@alien8.de> wrote:

> On Sun, Feb 28, 2016 at 09:28:46PM -0800, Andy Lutomirski wrote:
> > Setting TF prevents fastpath returns in most cases, which causes the
> > test to fail on 32-bit kernels because 32-bit kernels do not, in
> > fact, handle NT correctly on SYSENTER entries.
> > 
> > The next patch will fix 32-bit kernels.
> > 
> > Signed-off-by: Andy Lutomirski <luto@kernel.org>
> > ---
> >  tools/testing/selftests/x86/syscall_nt.c | 57 +++++++++++++++++++++++++++-----
> >  1 file changed, 49 insertions(+), 8 deletions(-)
> > 
> > diff --git a/tools/testing/selftests/x86/syscall_nt.c b/tools/testing/selftests/x86/syscall_nt.c
> > index 60c06af4646a..a6ceff86c199 100644
> > --- a/tools/testing/selftests/x86/syscall_nt.c
> > +++ b/tools/testing/selftests/x86/syscall_nt.c  
> 
> ...
> 
> > +static void do_it(unsigned long extraflags)
> > +{
> > +	unsigned long flags;
> > +
> > +	set_eflags(get_eflags() | extraflags);
> >  	syscall(SYS_getpid);
> > -	if (get_eflags() & X86_EFLAGS_NT) {
> > -		printf("[OK]\tThe syscall worked and NT is still set\n");
> > -		return 0;
> > +	flags = get_eflags();
> > +	if ((flags & extraflags) == extraflags) {
> > +		printf("[OK]\tThe syscall worked and flags are still set\n");
> >  	} else {
> > -		printf("[FAIL]\tThe syscall worked but NT was cleared\n");
> > -		return 1;
> > +		printf("[FAIL]\tThe syscall worked but flags were cleared (flags = 0x%lx but expected 0x%lx set)\n",
> > +		       flags, extraflags);
> > +		nerrs++;
> >  	}
> >  }
> > +
> > +int main()  
> 
> ERROR: Bad function definition - int main() should probably be int main(void)

int main(void) is wrong as there are passed arguments

int main() is ok (in C89 at least) because it means "there are unknown
arguments"

int main(int argc, char *argv[]) is allowed

int main(void) is not safe on all platforms because some compilers
choose to do the argument cleanup in the return path of the called
function. Having the wrong number of arguments doesn't end well in such
cases. I doubt any Linux platforms do this but we shouldn't be
encouraging bad programming techniques 8)

Alan

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 01/10] selftests/x86: In syscall_nt, test NT|TF as well Andy Lutomirski <luto@kernel.org> - 2016-02-29 06:30 +0100
  Re: [PATCH 01/10] selftests/x86: In syscall_nt, test NT|TF as well Borislav Petkov <bp@alien8.de> - 2016-03-02 14:10 +0100
    Re: [PATCH 01/10] selftests/x86: In syscall_nt, test NT|TF as well One Thousand Gnomes <gnomes@lxorguk.ukuu.org.uk> - 2016-03-02 15:10 +0100
      Re: [PATCH 01/10] selftests/x86: In syscall_nt, test NT|TF as well Borislav Petkov <bp@alien8.de> - 2016-03-02 15:30 +0100
        Re: [PATCH 01/10] selftests/x86: In syscall_nt, test NT|TF as well Andy Lutomirski <luto@amacapital.net> - 2016-03-02 20:10 +0100
          Re: [PATCH 01/10] selftests/x86: In syscall_nt, test NT|TF as well Borislav Petkov <bp@alien8.de> - 2016-03-02 20:40 +0100

csiph-web