Skip to contentSkip to conversation

utimensat_tests.sh: returns EPERM on 4.4.27 and above

PATCH New [email protected] 4 participants 8 messages Sep 6, 2017 – Sep 27, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 utimensat_tests.sh: returns EPERM on 4.4.27 and above

From: Naresh Kamboju <[email protected]>

Test utimensat failed on 4.4 kernel is due to expected error is EACCES but got EPERM.

The below LTP patch setting up expected error as EACCES for 4.8.0 below kernel
b9157aee: utimensat: re-apply: fix immutable file retcodes for 4.8.0 and newer

Amending patch to check 4.4.27 instead of 4.8.0 according to below patch
tree: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git
branch: v4.4.27
commit id: b3b4283
vfs: move permission checking into notify_change() for utimes(NULL)

Bug reported on this case,
LKFT: linux-stable-4.4: LTP utimensat01 failed-EXPECTED: EACCES but got EPERM
https://bugs.linaro.org/show_bug.cgi?id=3142

---
 testcases/kernel/syscalls/utimensat/utimensat_tests.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
testcases/kernel/syscalls/utimensat/utimensat_tests.sh +2 -2
index 48154d6..a832433 100755
@@ -30,9 +30,9 @@ if tst_kvcmp -lt "2.6.22"; then
 	tst_brkm TCONF "System kernel version is less than 2.6.22,cannot execute test"
 fi
 
-# Starting with 4.8.0 operations on immutable files return EPERM instead of
+# Starting with 4.4.27 operations on immutable files return EPERM instead of
 # EACCES.
-if tst_kvcmp -lt "4.8.0"; then
+if tst_kvcmp -lt "4.4.27"; then
 	imaccess=EACCES
 else
 	imaccess=EPERM
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/1 utimensat_tests.sh: returns EPERM on 4.4.27 and above

----- Original Message -----

Quoted 31 lines

From: Naresh Kamboju <[email protected]>

Test utimensat failed on 4.4 kernel is due to expected error is EACCES but got EPERM.

The below LTP patch setting up expected error as EACCES for 4.8.0 below kernel
b9157aee: utimensat: re-apply: fix immutable file retcodes for 4.8.0 and newer

Amending patch to check 4.4.27 instead of 4.8.0 according to below patch
tree: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git
branch: v4.4.27
commit id: b3b4283
vfs: move permission checking into notify_change() for utimes(NULL)

Bug reported on this case,
LKFT: linux-stable-4.4: LTP utimensat01 failed-EXPECTED: EACCES but got EPERM
https://bugs.linaro.org/show_bug.cgi?id=3142

---
 testcases/kernel/syscalls/utimensat/utimensat_tests.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
testcases/kernel/syscalls/utimensat/utimensat_tests.sh +0 -0
index 48154d6..a832433 100755

testcases/kernel/syscalls/utimensat/utimensat_tests.sh if tst_kvcmp -lt "2.6.22"; then · line 36

Quoted 9 lines
testcases/kernel/syscalls/utimensat/utimensat_tests.sh +2 -2
@@ -30,9 +30,9 @@ if tst_kvcmp -lt "2.6.22"; then
 	tst_brkm TCONF "System kernel version is less than 2.6.22,cannot execute
 	test"
 fi
 
-# Starting with 4.8.0 operations on immutable files return EPERM instead of
+# Starting with 4.4.27 operations on immutable files return EPERM instead of
 # EACCES.
-if tst_kvcmp -lt "4.8.0"; then
+if tst_kvcmp -lt "4.4.27"; then

Isn't this going to break the test for kernels 4.5 up to 4.7?

Quoted 7 lines
testcases/kernel/syscalls/utimensat/utimensat_tests.sh +0 -0
 	imaccess=EACCES
 else

imaccess=EPERM
--
2.7.4

#2 lore raw

PATCH 1/1 utimensat_tests.sh: returns EPERM on 4.4.27 and above

Quoted 38 lines · Jan Stancek

----- Original Message -----

Quoted 35 lines

From: Naresh Kamboju <[email protected]>

Test utimensat failed on 4.4 kernel is due to expected error is EACCES but got EPERM.

The below LTP patch setting up expected error as EACCES for 4.8.0 below kernel
b9157aee: utimensat: re-apply: fix immutable file retcodes for 4.8.0 and newer

Amending patch to check 4.4.27 instead of 4.8.0 according to below patch
tree: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git
branch: v4.4.27
commit id: b3b4283
vfs: move permission checking into notify_change() for utimes(NULL)

Bug reported on this case,
LKFT: linux-stable-4.4: LTP utimensat01 failed-EXPECTED: EACCES but got EPERM
https://bugs.linaro.org/show_bug.cgi?id=3142

---
 testcases/kernel/syscalls/utimensat/utimensat_tests.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
testcases/kernel/syscalls/utimensat/utimensat_tests.sh +0 -0
index 48154d6..a832433 100755
@@ -30,9 +30,9 @@ if tst_kvcmp -lt "2.6.22"; then
      tst_brkm TCONF "System kernel version is less than 2.6.22,cannot execute
      test"
 fi
 
Quoted 7 lines

testcases/kernel/syscalls/utimensat/utimensat_tests.sh if tst_kvcmp -lt "2.6.22"; then · line 35

Quoted 5 lines
testcases/kernel/syscalls/utimensat/utimensat_tests.sh +2 -2
-# Starting with 4.8.0 operations on immutable files return EPERM instead of
+# Starting with 4.4.27 operations on immutable files return EPERM instead of
 # EACCES.
-if tst_kvcmp -lt "4.8.0"; then
+if tst_kvcmp -lt "4.4.27"; then

Isn't this going to break the test for kernels 4.5 up to 4.7?

I'd think so too - perhaps a better check is to check for (if 4.4.X, then if > .27) OR (greater than 4.8.0)?

Quoted 8 lines
Quoted 8 lines
testcases/kernel/syscalls/utimensat/utimensat_tests.sh +0 -0
      imaccess=EACCES
 else

imaccess=EPERM
--
2.7.4

#3 lore raw

PATCH 1/1 utimensat_tests.sh: returns EPERM on 4.4.27 and above

Hi!

Quoted 2 lines

I'd think so too - perhaps a better check is to check for (if 4.4.X, then if > .27) OR (greater than 4.8.0)?

The safest bet would be allowing both for kernels between 4.4 and 4.8.

Something like this may work (beware untested):

testcases/kernel/syscalls/utimensat/utimensat_tests.sh +23 -12
index 48154d6e6..41ea7997a 100755
@@ -31,13 +31,18 @@ if tst_kvcmp -lt "2.6.22"; then
 fi
 
 # Starting with 4.8.0 operations on immutable files return EPERM instead of
-# EACCES.
-if tst_kvcmp -lt "4.8.0"; then
+# EACCES. The patch that changed the errno got as well backported to stable
+# kernel branches and so we cannot really say what is correct for kernels in
+# the range between 4.4 and 4.8.
+imaccess="EACCES EPERM"
+
+if tst_kvcmp -lt "4.4"; then
 	imaccess=EACCES
-else
-	imaccess=EPERM
 fi
 
+if tst_kvcmp -ge "4.8"; then
+	imaccess=EPERM
+fi
 
 RESULT_FILE=$TMPDIR/utimensat.result
 
@@ -142,7 +147,13 @@ check_result()
          "$EXPECT_MTIME_CHANGED"
     echo "RESULT:   $res $atime $mtime"
 
-    if test "$res" != "$EXPECTED_RESULT"; then
+    for err in $EXPECTED_RESULT; do
+	if test "$res" = "$err"; then
+	    errno_found="$err";
+	fi
+    done
+
+    if test -z "$errno_found"; then
         test_failed
         return
     fi
@@ -223,7 +234,7 @@ run_test()
     CMD="./$TEST_PROG -q $FILE $4"
     echo "$CMD"
     sudo $s_arg -u $test_user $CMD > $RESULT_FILE
-    check_result $? $5 $6 $7
+    check_result $? "$5" $6 $7
     echo
 
     if test $do_read_fd_test -ne 0; then
@@ -232,7 +243,7 @@ run_test()
         CMD="./$TEST_PROG -q -d $FILE NULL $4"
         echo "$CMD"
         sudo $s_arg -u $test_user $CMD > $RESULT_FILE
-        check_result $? $5 $6 $7
+        check_result $? "$5" $6 $7
         echo
     fi
 
@@ -245,7 +256,7 @@ run_test()
         CMD="./$TEST_PROG -q -w -d $FILE NULL $4"
         echo "$CMD"
         sudo $s_arg -u $test_user $CMD > $RESULT_FILE
-        check_result $? $5 $6 $7
+        check_result $? "$5" $6 $7
         echo
     fi
 
@@ -424,10 +435,10 @@ echo "Testing immutable file, owned by self"
 echo
 
 echo "***** Testing times==NULL case *****"
-run_test -W "" 600 "+i" "" $imaccess
+run_test -W "" 600 "+i" "" "$imaccess"
 
 echo "***** Testing times=={ UTIME_NOW, UTIME_NOW } case *****"
-run_test -W "" 600 "+i" "0 n 0 n" $imaccess
+run_test -W "" 600 "+i" "0 n 0 n" "$imaccess"
 
 echo "***** Testing times=={ UTIME_OMIT, UTIME_OMIT } case *****"
 run_test -W "" 600 "+i" "0 o 0 o" SUCCESS n n
@@ -450,10 +461,10 @@ echo "Testing immutable append-only file, owned by self"
 echo
 
 echo "***** Testing times==NULL case *****"
-run_test -W "" 600 "+ai" "" $imaccess
+run_test -W "" 600 "+ai" "" "$imaccess"
 
 echo "***** Testing times=={ UTIME_NOW, UTIME_NOW } case *****"
-run_test -W "" 600 "+ai" "0 n 0 n" $imaccess
+run_test -W "" 600 "+ai" "0 n 0 n" "$imaccess"
 
 echo "***** Testing times=={ UTIME_OMIT, UTIME_OMIT } case *****"
 run_test -W "" 600 "+ai" "0 o 0 o" SUCCESS n n
Signature · 2 lines
Cyril Hrubis
[email protected]
#4 lore raw

PATCH 1/1 utimensat_tests.sh: returns EPERM on 4.4.27 and above

Hi!

Quoted 3 lines

The safest bet would be allowing both for kernels between 4.4 and 4.8.

Something like this may work (beware untested):

And I've just checked the patch, it seems to work fine for me.

Can anybody else test this before it gets commited?

Quoted 102 lines
testcases/kernel/syscalls/utimensat/utimensat_tests.sh +23 -12
index 48154d6e6..41ea7997a 100755
@@ -31,13 +31,18 @@ if tst_kvcmp -lt "2.6.22"; then
 fi
 
 # Starting with 4.8.0 operations on immutable files return EPERM instead of
-# EACCES.
-if tst_kvcmp -lt "4.8.0"; then
+# EACCES. The patch that changed the errno got as well backported to stable
+# kernel branches and so we cannot really say what is correct for kernels in
+# the range between 4.4 and 4.8.
+imaccess="EACCES EPERM"
+
+if tst_kvcmp -lt "4.4"; then
 	imaccess=EACCES
-else
-	imaccess=EPERM
 fi
 
+if tst_kvcmp -ge "4.8"; then
+	imaccess=EPERM
+fi
 
 RESULT_FILE=$TMPDIR/utimensat.result
 
@@ -142,7 +147,13 @@ check_result()
          "$EXPECT_MTIME_CHANGED"
     echo "RESULT:   $res $atime $mtime"
 
-    if test "$res" != "$EXPECTED_RESULT"; then
+    for err in $EXPECTED_RESULT; do
+	if test "$res" = "$err"; then
+	    errno_found="$err";
+	fi
+    done
+
+    if test -z "$errno_found"; then
         test_failed
         return
     fi
@@ -223,7 +234,7 @@ run_test()
     CMD="./$TEST_PROG -q $FILE $4"
     echo "$CMD"
     sudo $s_arg -u $test_user $CMD > $RESULT_FILE
-    check_result $? $5 $6 $7
+    check_result $? "$5" $6 $7
     echo
 
     if test $do_read_fd_test -ne 0; then
@@ -232,7 +243,7 @@ run_test()
         CMD="./$TEST_PROG -q -d $FILE NULL $4"
         echo "$CMD"
         sudo $s_arg -u $test_user $CMD > $RESULT_FILE
-        check_result $? $5 $6 $7
+        check_result $? "$5" $6 $7
         echo
     fi
 
@@ -245,7 +256,7 @@ run_test()
         CMD="./$TEST_PROG -q -w -d $FILE NULL $4"
         echo "$CMD"
         sudo $s_arg -u $test_user $CMD > $RESULT_FILE
-        check_result $? $5 $6 $7
+        check_result $? "$5" $6 $7
         echo
     fi
 
@@ -424,10 +435,10 @@ echo "Testing immutable file, owned by self"
 echo
 
 echo "***** Testing times==NULL case *****"
-run_test -W "" 600 "+i" "" $imaccess
+run_test -W "" 600 "+i" "" "$imaccess"
 
 echo "***** Testing times=={ UTIME_NOW, UTIME_NOW } case *****"
-run_test -W "" 600 "+i" "0 n 0 n" $imaccess
+run_test -W "" 600 "+i" "0 n 0 n" "$imaccess"
 
 echo "***** Testing times=={ UTIME_OMIT, UTIME_OMIT } case *****"
 run_test -W "" 600 "+i" "0 o 0 o" SUCCESS n n
@@ -450,10 +461,10 @@ echo "Testing immutable append-only file, owned by self"
 echo
 
 echo "***** Testing times==NULL case *****"
-run_test -W "" 600 "+ai" "" $imaccess
+run_test -W "" 600 "+ai" "" "$imaccess"
 
 echo "***** Testing times=={ UTIME_NOW, UTIME_NOW } case *****"
-run_test -W "" 600 "+ai" "0 n 0 n" $imaccess
+run_test -W "" 600 "+ai" "0 n 0 n" "$imaccess"
 
 echo "***** Testing times=={ UTIME_OMIT, UTIME_OMIT } case *****"
 run_test -W "" 600 "+ai" "0 o 0 o" SUCCESS n n
Signature · 6 lines
-- 
Cyril Hrubis
[email protected]

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
Signature · 2 lines
Cyril Hrubis
[email protected]
#5 lore raw

PATCH 1/1 utimensat_tests.sh: returns EPERM on 4.4.27 and above

In reply to Cyril Hrubis

----- Original Message -----

Quoted 5 lines

Hi!

Quoted 2 lines

I'd think so too - perhaps a better check is to check for (if 4.4.X, then if > .27) OR (greater than 4.8.0)?

The safest bet would be allowing both for kernels between 4.4 and 4.8.

But also less strict. Why not just add check for 3rd digit? We already do that in other tests.

testcases/kernel/syscalls/utimensat/utimensat_tests.sh +5 -1
index 48154d6e65b2..6d7fc5030aff 100755
@@ -32,13 +32,16 @@ fi
 
 # Starting with 4.8.0 operations on immutable files return EPERM instead of
 # EACCES.
-if tst_kvcmp -lt "4.8.0"; then
+# This patch has also been merged to stable 4.4 with
+# b3b4283 ("vfs: move permission checking into notify_change() for utimes(NULL)")
+if tst_kvcmp -ge "4.4.27" -a -lt "4.5.0"; then
+       imaccess=EPERM
+else if tst_kvcmp -lt "4.8.0"; then
        imaccess=EACCES
 else
        imaccess=EPERM
 fi
 

Regards,
Jan

#6 lore raw

PATCH 1/1 utimensat_tests.sh: returns EPERM on 4.4.27 and above

Hi!

Quoted 2 lines

But also less strict. Why not just add check for 3rd digit? We already do that in other tests.

If that works for everyone, let's go with it. I just want to avoid a need to maintain a maze of kernel versions.

Signature · 2 lines
Cyril Hrubis
[email protected]
#7 lore raw

PATCH 1/1 utimensat_tests.sh: returns EPERM on 4.4.27 and above

Quoted 6 lines · Cyril Hrubis

Hi!

Quoted 2 lines

But also less strict. Why not just add check for 3rd digit? We already do that in other tests.

If that works for everyone, let's go with it. I just want to avoid a need to maintain a maze of kernel versions.

I have tested Jan 's patch there is a syntax problem.

- else if
+ elif

I am sending v2 patch.
Thanks for looking into this issue.

- Naresh

Quoted 4 lines

--
Cyril Hrubis
[email protected]