public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH] sched_setaffinity01: use ltp_syscall
@ 2014-07-25  8:18 Jan Stancek
  2014-07-25  8:35 ` Stanislav Kholmanskikh
  2014-07-25  8:36 ` Wanlong Gao
  0 siblings, 2 replies; 4+ messages in thread
From: Jan Stancek @ 2014-07-25  8:18 UTC (permalink / raw)
  To: ltp-list

Using glibc wrapper on kernel with smaller CONFIG_NR_CPUS (for example
255) leads to segmentation fault in glibc, because it triggers check,
which is verifying that there are no bits set beyond size of kernel cpu
mask:

int
__sched_setaffinity_new (pid_t pid, size_t cpusetsize, const cpu_set_t *cpuset)
  ...
  /* We now know the size of the kernel cpumask_t.  Make sure the user
     does not request to set a bit beyond that.  */
  for (size_t cnt = __kernel_cpumask_size; cnt < cpusetsize; ++cnt)
    if (((char *) cpuset)[cnt] != '\0') --> CRASH HERE

Call this syscall directly with ltp_syscall().

Reported-by: Xiaoguang Wang <wangxg.fnst@cn.fujitsu.com>
Signed-off-by: Jan Stancek <jstancek@redhat.com>
---
 .../sched_setaffinity/sched_setaffinity01.c        |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/testcases/kernel/syscalls/sched_setaffinity/sched_setaffinity01.c b/testcases/kernel/syscalls/sched_setaffinity/sched_setaffinity01.c
index 0ac4478..33a90b8 100644
--- a/testcases/kernel/syscalls/sched_setaffinity/sched_setaffinity01.c
+++ b/testcases/kernel/syscalls/sched_setaffinity/sched_setaffinity01.c
@@ -42,6 +42,7 @@
 #include "usctest.h"
 #include "safe_macros.h"
 #include "sched_setaffinity.h"
+#include "linux_syscall_numbers.h"
 
 char *TCID = "sched_setaffinity01";
 
@@ -151,9 +152,13 @@ int main(int argc, char *argv[])
 	for (lc = 0; TEST_LOOPING(lc); lc++) {
 		tst_count = 0;
 		for (i = 0; i < TST_TOTAL; i++) {
-			TEST(sched_setaffinity(*(test_cases[i].pid),
-						*(test_cases[i].mask_size),
-						*(test_cases[i].mask)));
+			/* Avoid calling glibc wrapper function, as it may
+			 * try to read/validate data in cpu mask. This test
+			 * is passing invalid pointer on purpose. */
+			TEST(ltp_syscall(__NR_sched_setaffinity,
+				*(test_cases[i].pid),
+				*(test_cases[i].mask_size),
+				*(test_cases[i].mask)));
 
 			if (TEST_RETURN != -1)
 				tst_resm(TFAIL,
-- 
1.7.1


------------------------------------------------------------------------------
Want fast and easy access to all the code in your enterprise? Index and
search up to 200,000 lines of code with a free copy of Black Duck
Code Sight - the same software that powers the world's largest code
search on Ohloh, the Black Duck Open Hub! Try it now.
http://p.sf.net/sfu/bds
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-07-25  9:58 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-25  8:18 [LTP] [PATCH] sched_setaffinity01: use ltp_syscall Jan Stancek
2014-07-25  8:35 ` Stanislav Kholmanskikh
2014-07-25  9:58   ` Jan Stancek
2014-07-25  8:36 ` Wanlong Gao

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox