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]
Message-Id: <20120214151312.92afd44a.akpm@linux-foundation.org>
Date:	Tue, 14 Feb 2012 15:13:12 -0800
From:	Andrew Morton <akpm@...ux-foundation.org>
To:	Cyrill Gorcunov <gorcunov@...nvz.org>
Cc:	linux-kernel@...r.kernel.org,
	"Eric W. Biederman" <ebiederm@...ssion.com>,
	Pavel Emelyanov <xemul@...nvz.org>,
	KOSAKI Motohiro <kosaki.motohiro@...fujitsu.com>,
	Ingo Molnar <mingo@...e.hu>, "H. Peter Anvin" <hpa@...or.com>,
	Pavel Emelyanov <xemul@...allels.com>,
	Andrey Vagin <avagin@...nvz.org>,
	KOSAKI Motohiro <kosaki.motohiro@...il.com>,
	Thomas Gleixner <tglx@...utronix.de>,
	Glauber Costa <glommer@...allels.com>,
	Andi Kleen <andi@...stfloor.org>, Tejun Heo <tj@...nel.org>,
	Matt Helsley <matthltc@...ibm.com>,
	Pekka Enberg <penberg@...nel.org>,
	Eric Dumazet <eric.dumazet@...il.com>,
	Vasiliy Kulikov <segoon@...nwall.com>,
	Alexey Dobriyan <adobriyan@...il.com>, Valdis.Kletnieks@...edu,
	Michal Marek <mmarek@...e.cz>
Subject: Re: [patch 2/4] syscalls, x86: Add __NR_kcmp syscall v8

On Mon, 13 Feb 2012 20:48:24 +0400
Cyrill Gorcunov <gorcunov@...nvz.org> wrote:

> While doing the checkpoint-restore in the user space one need to determine
> whether various kernel objects (like mm_struct-s of file_struct-s) are shared
> between tasks and restore this state.
> 
> The 2nd step can be solved by using appropriate CLONE_ flags and the unshare
> syscall, while there's currently no ways for solving the 1st one.
> 
> One of the ways for checking whether two tasks share e.g. mm_struct is to
> provide some mm_struct ID of a task to its proc file, but showing such
> info considered to be not that good for security reasons.
> 
> Thus after some debates we end up in conclusion that using that named
> 'comparison' syscall might be the best candidate. So here is it --
> __NR_kcmp.
> 
> It takes up to 5 arguments - the pids of the two tasks (which
> characteristics should be compared), the comparison type and
> (in case of comparison of files) two file descriptors.
> 
> Lookups for pids are done in the caller's PID namespace only.
> 
> At moment only x86 is supported and tested.
> 
>
> ...
>
> --- /dev/null
> +++ linux-2.6.git/tools/testing/selftests/kcmp/Makefile
> @@ -0,0 +1,36 @@
> +ifeq ($(strip $(V)),)
> +	E = @echo
> +	Q = @
> +else
> +	E = @\#
> +	Q =
> +endif
> +export E Q
> +
> +uname_M := $(shell uname -m 2>/dev/null || echo not)
> +ARCH ?= $(shell echo $(uname_M) | sed -e s/i.86/i386/)
> +ifeq ($(ARCH),i386)
> +        ARCH := X86
> +	CFLAGS := -DCONFIG_X86_32 -D__i386__
> +endif
> +ifeq ($(ARCH),x86_64)
> +	ARCH := X86
> +	CFLAGS := -DCONFIG_X86_64 -D__x86_64__
> +endif
> +
> +CFLAGS += -I../../../../arch/x86/include/generated/
> +CFLAGS += -I../../../../include/
> +CFLAGS += -I../../../../usr/include/
> +
> +all:
> +ifeq ($(ARCH),X86)
> +	$(E) "  CC run_test"
> +	$(Q) gcc $(CFLAGS) kcmp_test.c -o run_test
> +else
> +	$(E) "Not an x86 target, can't build kcmp selftest"
> +endif
> +
> +clean:
> +	$(E) "  CLEAN"
> +	$(Q) rm -fr ./run_test
> +	$(Q) rm -fr ./test-file

hm, what does all this stuff in the selftest makefile do?


The selftests code has undergone some changes since you last looked. 
The rules are, roughly:

- In tools/testing/selftests, a "make" will compile but not run all
  selftest code.

- In tools/testing/selftests, a "make run_tests" will compile all
  selftest code (if needed) and will then run all the tests.

  If a test is not applicable (eg wrong architecture, kernel feature
  not enabled, etc) then it should try to avoid breaking the build and,
  when executed it should emit a diagnostic and then exit(0) (ie:
  success) so as to avoid breaking the overall test run.

  IOW, the test should only fail if the feature is present but isn't
  working correctly.

Also, I hate with a passion Makefiles which hide the command lines from
me!  So I nuked all that E and Q stuff.

Result:

--- a/tools/testing/selftests/kcmp/Makefile~syscalls-x86-add-__nr_kcmp-syscall-v8-fix
+++ a/tools/testing/selftests/kcmp/Makefile
@@ -1,12 +1,3 @@
-ifeq ($(strip $(V)),)
-	E = @echo
-	Q = @
-else
-	E = @\#
-	Q =
-endif
-export E Q
-
 uname_M := $(shell uname -m 2>/dev/null || echo not)
 ARCH ?= $(shell echo $(uname_M) | sed -e s/i.86/i386/)
 ifeq ($(ARCH),i386)
@@ -24,13 +15,14 @@ CFLAGS += -I../../../../usr/include/
 
 all:
 ifeq ($(ARCH),X86)
-	$(E) "  CC run_test"
-	$(Q) gcc $(CFLAGS) kcmp_test.c -o run_test
+	gcc $(CFLAGS) kcmp_test.c -o run_test
 else
-	$(E) "Not an x86 target, can't build kcmp selftest"
+	echo "Not an x86 target, can't build kcmp selftest"
 endif
 
+run-tests: all
+	./kcmp_test
+
 clean:
-	$(E) "  CLEAN"
-	$(Q) rm -fr ./run_test
-	$(Q) rm -fr ./test-file
+	rm -fr ./run_test
+	rm -fr ./test-file
--- a/tools/testing/selftests/Makefile~syscalls-x86-add-__nr_kcmp-syscall-v8-fix
+++ a/tools/testing/selftests/Makefile
@@ -1,4 +1,4 @@
-TARGETS = breakpoints vm
+TARGETS = breakpoints vm kcmp
 
 all:
 	for TARGET in $(TARGETS); do \
_


However that didn't work for me:

akpm:/usr/src/25/tools/testing/selftests/kcmp> make
gcc -DCONFIG_X86_64 -D__x86_64__ -I../../../../arch/x86/include/generated/ -I../../../../include/ -I../../../../usr/include/ kcmp_test.c -o run_test
kcmp_test.c: In function 'sys_kcmp':
kcmp_test.c:22: error: '__NR_kcmp' undeclared (first use in this function)
kcmp_test.c:22: error: (Each undeclared identifier is reported only once
kcmp_test.c:22: error: for each function it appears in.)
kcmp_test.c: In function 'main':
kcmp_test.c:69: warning: format '%2d' expects type 'int', but argument 4 has type 'long int'
kcmp_test.c:69: warning: format '%2d' expects type 'int', but argument 5 has type 'long int'
kcmp_test.c:69: warning: format '%2d' expects type 'int', but argument 6 has type 'long int'
kcmp_test.c:69: warning: format '%2d' expects type 'int', but argument 7 has type 'long int'
kcmp_test.c:69: warning: format '%2d' expects type 'int', but argument 8 has type 'long int'
kcmp_test.c:69: warning: format '%2d' expects type 'int', but argument 9 has type 'long int'
kcmp_test.c:69: warning: format '%2d' expects type 'int', but argument 10 has type 'long int'
kcmp_test.c:69: warning: format '%2d' expects type 'int', but argument 11 has type 'long int'


How are we supposed to be picking up __NR_kcmp?


--
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