diff --git a/kernel/syscall.c b/kernel/syscall.c index 3b395d81..7fb6e11f 100644 --- a/kernel/syscall.c +++ b/kernel/syscall.c @@ -3240,7 +3240,6 @@ SYSCALL_DECLARE(kill) return error; } -// see linux-2.6.34.13/kernel/signal.c SYSCALL_DECLARE(tgkill) { int tgid = ihk_mc_syscall_arg0(ctx); @@ -3249,16 +3248,15 @@ SYSCALL_DECLARE(tgkill) struct thread *thread = cpu_local_var(current); struct siginfo info; + if (tgid <= 0 || tid <= 0) { + return -EINVAL; + } + memset(&info, '\0', sizeof info); info.si_signo = sig; info.si_code = SI_TKILL; info._sifields._kill.si_pid = thread->proc->pid; - if(tid <= 0) - return -EINVAL; - if(tgid <= 0 && tgid != -1) - return -EINVAL; - return do_kill(thread, tgid, tid, sig, &info, 0); } diff --git a/test/issues/1380/C1380.sh b/test/issues/1380/C1380.sh new file mode 100755 index 00000000..b26163e5 --- /dev/null +++ b/test/issues/1380/C1380.sh @@ -0,0 +1,26 @@ +#/bin/sh + +USELTP=1 +USEOSTEST=0 + +. ../../common.sh + +issue="1380" +tid=01 + +for tp in tgkill03 tgkill01 tkill01 tkill02 +do + tname=`printf "C${issue}T%02d" ${tid}` + echo "*** ${tname} start *******************************" + sudo $MCEXEC $LTPBIN/$tp 2>&1 | tee $tp.txt + ok=`grep PASS $tp.txt | wc -l` + ng=`grep FAIL $tp.txt | wc -l` + if [ $ng = 0 ]; then + echo "*** ${tname} PASSED ($ok)" + else + echo "*** ${tname} FAILED (ok=$ok ng=$ng)" + fi + let tid++ + echo "" +done + diff --git a/test/issues/1380/Makefile b/test/issues/1380/Makefile new file mode 100644 index 00000000..569f3ab6 --- /dev/null +++ b/test/issues/1380/Makefile @@ -0,0 +1,11 @@ +CFLAGS=-g +LDFLAGS= + +TARGET= + +all: $(TARGET) + +test: all + ./C1380.sh +clean: + rm -f $(TARGET) *.o *.txt diff --git a/test/issues/1380/README b/test/issues/1380/README new file mode 100644 index 00000000..82bade72 --- /dev/null +++ b/test/issues/1380/README @@ -0,0 +1,21 @@ +【Issue#1324 動作確認】 +□ テスト内容 +1. 以下のLTPを用いてIssueで報告された症状が発生しないことを確認 + - tgkill03 + +3. 以下のLTPを用いて既存機能に影響が無いことを確認 + - tgkill01 + - tkill01 + - tkill02 + +□ 実行手順 +$ make test + +McKernelのインストール先や、OSTEST, LTPの配置場所は、 +$HOME/.mck_test_config を参照している +.mck_test_config は、McKernelをビルドした際に生成されるmck_test_config.sample ファイルを +$HOMEにコピーし、適宜編集する + +□ 実行結果 +x86_64_result.log aarch64_result.log 参照。 +すべての項目をPASSしていることを確認。 diff --git a/test/issues/1380/aarch64_result.log b/test/issues/1380/aarch64_result.log new file mode 100644 index 00000000..f3facb21 --- /dev/null +++ b/test/issues/1380/aarch64_result.log @@ -0,0 +1,37 @@ +*** C1380T01 start ******************************* +tst_test.c:1096: INFO: Timeout per run is 0h 05m 00s +tgkill03.c:92: PASS: Invalid tgid failed as expected: EINVAL +tgkill03.c:92: PASS: Invalid tid failed as expected: EINVAL +tgkill03.c:92: PASS: Invalid signal failed as expected: EINVAL +tgkill03.c:92: PASS: Defunct tid failed as expected: ESRCH +tgkill03.c:92: PASS: Defunct tgid failed as expected: ESRCH +tgkill03.c:99: PASS: Valid tgkill call succeeded + +Summary: +passed 6 +failed 0 +skipped 0 +warnings 0 +*** C1380T01 PASSED (6) + +*** C1380T02 start ******************************* +tst_test.c:1096: INFO: Timeout per run is 0h 05m 00s +tgkill01.c:99: PASS: SIGUSR1 delivered to correct threads + +Summary: +passed 1 +failed 0 +skipped 0 +warnings 0 +*** C1380T02 PASSED (1) + +*** C1380T03 start ******************************* +tkill01 1 TPASS : tkill call succeeded +tkill01 2 TPASS : tkill call succeeded +*** C1380T03 PASSED (2) + +*** C1380T04 start ******************************* +tkill02 1 TPASS : tkill(-1, SIGUSR1) failed as expected: TEST_ERRNO=EINVAL(22): Invalid argument +tkill02 2 TPASS : tkill(29822, SIGUSR1) failed as expected: TEST_ERRNO=ESRCH(3): No such process +*** C1380T04 PASSED (2) + diff --git a/test/issues/1380/x86_64_result.log b/test/issues/1380/x86_64_result.log new file mode 100644 index 00000000..23cbb056 --- /dev/null +++ b/test/issues/1380/x86_64_result.log @@ -0,0 +1,37 @@ +*** C1380T01 start ******************************* +tst_test.c:1096: INFO: Timeout per run is 0h 05m 00s +tgkill03.c:92: PASS: Invalid tgid failed as expected: EINVAL +tgkill03.c:92: PASS: Invalid tid failed as expected: EINVAL +tgkill03.c:92: PASS: Invalid signal failed as expected: EINVAL +tgkill03.c:92: PASS: Defunct tid failed as expected: ESRCH +tgkill03.c:92: PASS: Defunct tgid failed as expected: ESRCH +tgkill03.c:99: PASS: Valid tgkill call succeeded + +Summary: +passed 6 +failed 0 +skipped 0 +warnings 0 +*** C1380T01 PASSED (6) + +*** C1380T02 start ******************************* +tst_test.c:1096: INFO: Timeout per run is 0h 05m 00s +tgkill01.c:99: PASS: SIGUSR1 delivered to correct threads + +Summary: +passed 1 +failed 0 +skipped 0 +warnings 0 +*** C1380T02 PASSED (1) + +*** C1380T03 start ******************************* +tkill01 1 TPASS : tkill call succeeded +tkill01 2 TPASS : tkill call succeeded +*** C1380T03 PASSED (2) + +*** C1380T04 start ******************************* +tkill02 1 TPASS : tkill(-1, SIGUSR1) failed as expected: TEST_ERRNO=EINVAL(22): Invalid argument +tkill02 2 TPASS : tkill(32768, SIGUSR1) failed as expected: TEST_ERRNO=ESRCH(3): No such process +*** C1380T04 PASSED (2) +