diff --git a/executer/user/mcexec.c b/executer/user/mcexec.c index 377ad6d4..60b0756e 100644 --- a/executer/user/mcexec.c +++ b/executer/user/mcexec.c @@ -3498,7 +3498,7 @@ checkexist_resolvelinks: if (buf[0] == '/') { /* cannot snprintf from same source and dest */ n = snprintf(tmpbuf2, PATH_MAX, "%s/%s", buf, - linkpath); + linkpath + 1); if (n >= PATH_MAX) return in; strcpy(tmpbuf, tmpbuf2); diff --git a/test/issues/1463/C1463.sh b/test/issues/1463/C1463.sh new file mode 100755 index 00000000..f325f400 --- /dev/null +++ b/test/issues/1463/C1463.sh @@ -0,0 +1,58 @@ +#/bin/sh + +USELTP=0 +USEOSTEST=0 + +. ../../common.sh + +issue="1463" +tid=01 + +TEST_DIR="/tmp/test" +ABS_PATH="${TEST_DIR}" +REL_PATH="./test" +ABS_LN="${TEST_DIR}_1463_abs_ln" +REL_LN="${TEST_DIR}_1463_rel_ln" + +mkdir -p ${TEST_DIR} +touch ${TEST_DIR}/L.dir + +tname=`printf "C${issue}T%02d" ${tid}` +echo "*** ${tname} start *******************************" +ln -fns ${ABS_PATH} ${ABS_LN} +mcexec readlink ${ABS_LN}/L.dir | tee ./${tname}.txt +cnt=`grep "a.dir" ./${tname}.txt | wc -l` +if [ ${cnt} -eq 1 ]; then + echo "*** ${tname} PASSED ******************************" +else + echo "*** ${tname} FAILED ******************************" +fi +let tid++ +echo "" + +tname=`printf "C${issue}T%02d" ${tid}` +echo "*** ${tname} start *******************************" +ln -fns ${REL_PATH} ${REL_LN} +mcexec readlink ${REL_LN}/L.dir | tee ./${tname}.txt +cnt=`grep "a.dir" ./${tname}.txt | wc -l` +if [ ${cnt} -eq 1 ]; then + echo "*** ${tname} PASSED ******************************" +else + echo "*** ${tname} FAILED ******************************" +fi +let tid++ +echo "" + +tname=`printf "C${issue}T%02d" ${tid}` +echo "*** ${tname} start *******************************" +mcexec cat /sys/devices/system/cpu/offline | tee ./${tname}.txt +echo "** (expected blank output)" +lines=`grep -e "[0-9]" ./${tname}.txt | wc -l` +if [ ${lines} -eq 0 ]; then + echo "*** ${tname} PASSED ******************************" +else + echo "*** ${tname} FAILED ******************************" +fi +let tid++ +echo "" + diff --git a/test/issues/1463/Makefile b/test/issues/1463/Makefile new file mode 100644 index 00000000..6e38aba4 --- /dev/null +++ b/test/issues/1463/Makefile @@ -0,0 +1,12 @@ +CFLAGS= +LDFLAGS= + +TARGET= + +all: $(TARGET) + +test: all + sh ./C1463.sh +clean: + rm -f $(TARGET) *.o *.txt + diff --git a/test/issues/1463/README b/test/issues/1463/README new file mode 100644 index 00000000..ce71fefc --- /dev/null +++ b/test/issues/1463/README @@ -0,0 +1,49 @@ +【Issue#1463 動作確認】 +□ テスト内容 +Issue#1463の修正は、mcexec.c: mcoverlay_path() 内で行われる/sys/ 配下への +リンク解決処理に関する修正である。 +上記のリンク解決処理を/tmp/ 配下にも行うようにするテストパッチを適用した上で +/tmp/ 配下へのmcoverlay_path()を実行して動作を確認する。 + +なお、リンク解決処理の動作確認には、McKernelによって作成される、 +/sys/devices/virtual/mcos/mcos0/sys/test/L.dir を利用する。 +このL.dirは、同ディレクトリのa.dir へのシンボリックリンクとなっている。 + +C1463T01: + 以下の流れで、リンク解決処理対象パスの途中に絶対パスのシンボリックリンクが + 存在している場合にも、/sys/devices/virtual/mcos/mcos0/sys/ 下に + 誘導されることを確認する。 + a. /tmp/test/L.dir に空のファイルを作成 + b. /tmp/test への絶対パスのシンボリックリンクとして、/tmp/test_1463_abs_ln を作成 + c. mcexec readlink /tmp/test_1463_abs_ln/L.dir を実行し、a.dir が出力されることを確認 + +C1463T02: + 以下の流れで、リンク解決処理対象パスの途中に相対パスのシンボリックリンクが + 存在している場合にも、/sys/devices/virtual/mcos/mcos0/sys/ 下に + 誘導されることを確認する。 + a. /tmp/test/L.dir に空のファイルを作成 + b. /tmp/test への相対パスのシンボリックリンクとして、/tmp/test_1463_rel_ln を作成 + c. mcexec readlink /tmp/test_1463_rel_ln/L.dir を実行し、a.dir が出力されることを確認 + +C1463T03: + 以下の流れで、/sys/ 配下へのアクセスが/sys/devices/virtual/mcos/mcos0/sys/ 下に + 誘導されることを確認する。 + a. mcexecで確認した場合の /sys/devices/system/cpu/offline が空であることを確認 + ※通常、mckernelではofflineのCPUが存在しないため + +□ 実行手順 +・下記の手順でテストを実行する +$ cd +$ patch -p0 < test/issues/1463/tmp_overlay_path.patch +(build mckernel) +$ cd test/issues/1463 +$ 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/1463/aarch64_result.log b/test/issues/1463/aarch64_result.log new file mode 100644 index 00000000..a4c88afd --- /dev/null +++ b/test/issues/1463/aarch64_result.log @@ -0,0 +1,15 @@ +sh ./C1463.sh +mcstop+release.sh ... done +mcreboot.sh -c 37-43,49-55 -m 2G@2,2G@3 -r 37-43:36+49-55:48 -O ... done +*** C1463T01 start ******************************* +a.dir +*** C1463T01 PASSED ****************************** + +*** C1463T02 start ******************************* +a.dir +*** C1463T02 PASSED ****************************** + +*** C1463T03 start ******************************* + +** (expected blank output) +*** C1463T03 PASSED ****************************** diff --git a/test/issues/1463/tmp_overlay_path.patch b/test/issues/1463/tmp_overlay_path.patch new file mode 100644 index 00000000..7fbc00d6 --- /dev/null +++ b/test/issues/1463/tmp_overlay_path.patch @@ -0,0 +1,17 @@ +diff --git executer/user/mcexec.c executer/user/mcexec.c +index acae1f8..d220dd9 100644 +--- executer/user/mcexec.c ++++ executer/user/mcexec.c +@@ -3458,6 +3458,12 @@ overlay_path(int dirfd, const char *in, char *buf, int *resolvelinks) + goto checkexist_resolvelinks; + } + ++ /* for #1463's test */ ++ if (!strncmp(path, "/tmp", 4) && ++ (path[4] == '/' || path[4] == '\0')) { ++ goto checkexist_resolvelinks; ++ } ++ + return in; + + checkexist_resolvelinks: diff --git a/test/issues/1463/x86_64_result.log b/test/issues/1463/x86_64_result.log new file mode 100644 index 00000000..e6ba68a9 --- /dev/null +++ b/test/issues/1463/x86_64_result.log @@ -0,0 +1,15 @@ +sh ./C1463.sh +mcstop+release.sh ... done +mcreboot.sh -c 1-7,9-15,17-23,25-31 -m 10G@0,10G@1 -r 1-7:0+9-15:8+17-23:16+25-31:24 -O ... done +*** C1463T01 start ******************************* +a.dir +*** C1463T01 PASSED ****************************** + +*** C1463T02 start ******************************* +a.dir +*** C1463T02 PASSED ****************************** + +*** C1463T03 start ******************************* + +** (expected blank output) +*** C1463T03 PASSED ******************************