set_robust_list: Add error check
set_robust_list is not supported by McKernel. Change-Id: I1f679e2e4df24139cceb1f2294bc072cb7956002 Refs: 1399
This commit is contained in:
committed by
Masamichi Takagi
parent
ebc91cea0e
commit
b44b11ace7
@ -3531,9 +3531,15 @@ SYSCALL_DECLARE(setpgid)
|
|||||||
|
|
||||||
/* Ignore the registration by start_thread() (in pthread_create.c)
|
/* Ignore the registration by start_thread() (in pthread_create.c)
|
||||||
because McKernel doesn't unlock mutex-es held by the thread which has been killed. */
|
because McKernel doesn't unlock mutex-es held by the thread which has been killed. */
|
||||||
|
#define ROBUST_LIST_HEAD_SIZE 24
|
||||||
SYSCALL_DECLARE(set_robust_list)
|
SYSCALL_DECLARE(set_robust_list)
|
||||||
{
|
{
|
||||||
// Palliative fix. wait for impl.
|
size_t len = (size_t)ihk_mc_syscall_arg1(ctx);
|
||||||
|
|
||||||
|
if (len != ROBUST_LIST_HEAD_SIZE) {
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
41
test/issues/1399/C1399.sh
Executable file
41
test/issues/1399/C1399.sh
Executable file
@ -0,0 +1,41 @@
|
|||||||
|
#/bin/sh
|
||||||
|
|
||||||
|
USELTP=1
|
||||||
|
USEOSTEST=0
|
||||||
|
|
||||||
|
. ../../common.sh
|
||||||
|
|
||||||
|
issue="1399"
|
||||||
|
tid=01
|
||||||
|
|
||||||
|
for tno in 01
|
||||||
|
do
|
||||||
|
tname=`printf "C${issue}T%02d" ${tid}`
|
||||||
|
echo "*** ${tname} start *******************************"
|
||||||
|
sudo ${MCEXEC} ./C1399T${tno}
|
||||||
|
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
echo "*** ${tname} PASSED ******************************"
|
||||||
|
else
|
||||||
|
echo "*** ${tname} FAILED ******************************"
|
||||||
|
fi
|
||||||
|
let tid++
|
||||||
|
echo ""
|
||||||
|
done
|
||||||
|
|
||||||
|
for tp in set_robust_list01 get_robust_list01
|
||||||
|
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
|
||||||
|
|
||||||
36
test/issues/1399/C1399T01.c
Normal file
36
test/issues/1399/C1399T01.c
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <linux/futex.h>
|
||||||
|
#include <syscall.h>
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
|
int main(int argc, void *argv[])
|
||||||
|
{
|
||||||
|
struct robust_list_head rlh;
|
||||||
|
size_t len = sizeof(struct robust_list_head);
|
||||||
|
int rc = 0, ret = 0;
|
||||||
|
|
||||||
|
errno = 0;
|
||||||
|
rc = syscall(__NR_set_robust_list, &rlh, len + 1);
|
||||||
|
if (rc == -1 && errno == EINVAL) {
|
||||||
|
printf("[OK] invalid len (1 greater than correct): EINVAL\n");
|
||||||
|
} else {
|
||||||
|
printf("[NG] invalid len (1 greater than correct): Succeed\n");
|
||||||
|
ret = -1;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
errno = 0;
|
||||||
|
rc = syscall(__NR_set_robust_list, &rlh, len - 1);
|
||||||
|
if (rc == -1 && errno == EINVAL) {
|
||||||
|
printf("[OK] invalid len (1 less than correct): EINVAL\n");
|
||||||
|
} else {
|
||||||
|
printf("[NG] invalid len (1 less than correct): Succeed\n");
|
||||||
|
ret = -1;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
out:
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
11
test/issues/1399/Makefile
Normal file
11
test/issues/1399/Makefile
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
CFLAGS=-g
|
||||||
|
LDFLAGS=
|
||||||
|
|
||||||
|
TARGET=C1399T01
|
||||||
|
|
||||||
|
all: $(TARGET)
|
||||||
|
|
||||||
|
test: all
|
||||||
|
./C1399.sh
|
||||||
|
clean:
|
||||||
|
rm -f $(TARGET) *.o *.txt
|
||||||
24
test/issues/1399/README
Normal file
24
test/issues/1399/README
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
【Issue#1399 動作確認】
|
||||||
|
□ テスト内容
|
||||||
|
1. 下記のテストプログラムを実行し、症状が発生しないことを確認する
|
||||||
|
C1399T01:
|
||||||
|
1. struct robust_list_head のサイズよりも1大きい値をサイズとして指定して
|
||||||
|
set_robsut_list を呼び出し、EINVALで失敗することを確認
|
||||||
|
2. struct robust_list_head のサイズよりも1小さい値をサイズとして指定して
|
||||||
|
set_robsut_list を呼び出し、EINVALで失敗することを確認
|
||||||
|
|
||||||
|
2. 以下のLTPを用いて既存のrobust_list機能に影響が無いことを確認
|
||||||
|
- set_robst_list01
|
||||||
|
- get_robst_list01
|
||||||
|
|
||||||
|
□ 実行手順
|
||||||
|
$ 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していることを確認。
|
||||||
18
test/issues/1399/aarch64_result.log
Normal file
18
test/issues/1399/aarch64_result.log
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
*** C1399T01 start *******************************
|
||||||
|
[OK] invalid len (1 greater than correct): EINVAL
|
||||||
|
[OK] invalid len (1 less than correct): EINVAL
|
||||||
|
*** C1399T01 PASSED ******************************
|
||||||
|
|
||||||
|
*** C1399T02 start *******************************
|
||||||
|
set_robust_list01 1 TPASS : set_robust_list: retval = -1 (expected -1), errno = 22 (expected 22)
|
||||||
|
set_robust_list01 2 TPASS : set_robust_list: retval = 0 (expected 0), errno = 0 (expected 0)
|
||||||
|
*** C1399T02 PASSED (2)
|
||||||
|
|
||||||
|
*** C1399T03 start *******************************
|
||||||
|
get_robust_list01 1 TPASS : get_robust_list failed as expected with EFAULT
|
||||||
|
get_robust_list01 2 TPASS : get_robust_list failed as expected with EFAULT
|
||||||
|
get_robust_list01 3 TPASS : get_robust_list failed as expected with ESRCH
|
||||||
|
get_robust_list01 4 TPASS : get_robust_list succeeded
|
||||||
|
get_robust_list01 5 TPASS : get_robust_list failed as expected with EPERM
|
||||||
|
*** C1399T03 PASSED (5)
|
||||||
|
|
||||||
18
test/issues/1399/x86_64_result.log
Normal file
18
test/issues/1399/x86_64_result.log
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
*** C1399T01 start *******************************
|
||||||
|
[OK] invalid len (1 greater than correct): EINVAL
|
||||||
|
[OK] invalid len (1 less than correct): EINVAL
|
||||||
|
*** C1399T01 PASSED ******************************
|
||||||
|
|
||||||
|
*** C1399T02 start *******************************
|
||||||
|
set_robust_list01 1 TPASS : set_robust_list: retval = -1 (expected -1), errno = 22 (expected 22)
|
||||||
|
set_robust_list01 2 TPASS : set_robust_list: retval = 0 (expected 0), errno = 0 (expected 0)
|
||||||
|
*** C1399T02 PASSED (2)
|
||||||
|
|
||||||
|
*** C1399T03 start *******************************
|
||||||
|
get_robust_list01 1 TPASS : get_robust_list failed as expected with EFAULT
|
||||||
|
get_robust_list01 2 TPASS : get_robust_list failed as expected with EFAULT
|
||||||
|
get_robust_list01 3 TPASS : get_robust_list failed as expected with ESRCH
|
||||||
|
get_robust_list01 4 TPASS : get_robust_list succeeded
|
||||||
|
get_robust_list01 5 TPASS : get_robust_list failed as expected with EPERM
|
||||||
|
*** C1399T03 PASSED (5)
|
||||||
|
|
||||||
Reference in New Issue
Block a user