All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH] utimensat_tests.sh: returns EPERM on 4.4.27 and above
@ 2017-09-06 11:30 naresh.kamboju
  2017-09-06 11:54 ` Jan Stancek
  0 siblings, 1 reply; 8+ messages in thread
From: naresh.kamboju @ 2017-09-06 11:30 UTC (permalink / raw)
  To: ltp

From: Naresh Kamboju <naresh.kamboju@linaro.org>

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

Signed-off-by: Naresh Kamboju <naresh.kamboju@linaro.org>
---
 testcases/kernel/syscalls/utimensat/utimensat_tests.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/testcases/kernel/syscalls/utimensat/utimensat_tests.sh b/testcases/kernel/syscalls/utimensat/utimensat_tests.sh
index 48154d6..a832433 100755
--- a/testcases/kernel/syscalls/utimensat/utimensat_tests.sh
+++ b/testcases/kernel/syscalls/utimensat/utimensat_tests.sh
@@ -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
-- 
2.7.4


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

* [LTP] [PATCH] utimensat_tests.sh: returns EPERM on 4.4.27 and above
  2017-09-06 11:30 [LTP] [PATCH] utimensat_tests.sh: returns EPERM on 4.4.27 and above naresh.kamboju
@ 2017-09-06 11:54 ` Jan Stancek
  2017-09-06 15:29   ` Sumit Semwal
  0 siblings, 1 reply; 8+ messages in thread
From: Jan Stancek @ 2017-09-06 11:54 UTC (permalink / raw)
  To: ltp



----- Original Message -----
> From: Naresh Kamboju <naresh.kamboju@linaro.org>
> 
> 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
> 
> Signed-off-by: Naresh Kamboju <naresh.kamboju@linaro.org>
> ---
>  testcases/kernel/syscalls/utimensat/utimensat_tests.sh | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/testcases/kernel/syscalls/utimensat/utimensat_tests.sh
> b/testcases/kernel/syscalls/utimensat/utimensat_tests.sh
> index 48154d6..a832433 100755
> --- a/testcases/kernel/syscalls/utimensat/utimensat_tests.sh
> +++ b/testcases/kernel/syscalls/utimensat/utimensat_tests.sh
> @@ -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?

>  	imaccess=EACCES
>  else
>  	imaccess=EPERM
> --
> 2.7.4
> 
> 

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

* [LTP] [PATCH] utimensat_tests.sh: returns EPERM on 4.4.27 and above
  2017-09-06 11:54 ` Jan Stancek
@ 2017-09-06 15:29   ` Sumit Semwal
  2017-09-25 14:46     ` Cyril Hrubis
  0 siblings, 1 reply; 8+ messages in thread
From: Sumit Semwal @ 2017-09-06 15:29 UTC (permalink / raw)
  To: ltp

On 6 September 2017 at 17:24, Jan Stancek <jstancek@redhat.com> wrote:
>
>
> ----- Original Message -----
>> From: Naresh Kamboju <naresh.kamboju@linaro.org>
>>
>> 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
>>
>> Signed-off-by: Naresh Kamboju <naresh.kamboju@linaro.org>
>> ---
>>  testcases/kernel/syscalls/utimensat/utimensat_tests.sh | 4 ++--
>>  1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/testcases/kernel/syscalls/utimensat/utimensat_tests.sh
>> b/testcases/kernel/syscalls/utimensat/utimensat_tests.sh
>> index 48154d6..a832433 100755
>> --- a/testcases/kernel/syscalls/utimensat/utimensat_tests.sh
>> +++ b/testcases/kernel/syscalls/utimensat/utimensat_tests.sh
>> @@ -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?

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)?
>
>>       imaccess=EACCES
>>  else
>>       imaccess=EPERM
>> --
>> 2.7.4
>>
>>

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

* [LTP] [PATCH] utimensat_tests.sh: returns EPERM on 4.4.27 and above
  2017-09-06 15:29   ` Sumit Semwal
@ 2017-09-25 14:46     ` Cyril Hrubis
  2017-09-27 11:39       ` Cyril Hrubis
  2017-09-27 13:55       ` Jan Stancek
  0 siblings, 2 replies; 8+ messages in thread
From: Cyril Hrubis @ 2017-09-25 14:46 UTC (permalink / raw)
  To: ltp

Hi!
> 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):

diff --git a/testcases/kernel/syscalls/utimensat/utimensat_tests.sh b/testcases/kernel/syscalls/utimensat/utimensat_tests.sh
index 48154d6e6..41ea7997a 100755
--- a/testcases/kernel/syscalls/utimensat/utimensat_tests.sh
+++ b/testcases/kernel/syscalls/utimensat/utimensat_tests.sh
@@ -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

-- 
Cyril Hrubis
chrubis@suse.cz

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

* [LTP] [PATCH] utimensat_tests.sh: returns EPERM on 4.4.27 and above
  2017-09-25 14:46     ` Cyril Hrubis
@ 2017-09-27 11:39       ` Cyril Hrubis
  2017-09-27 13:55       ` Jan Stancek
  1 sibling, 0 replies; 8+ messages in thread
From: Cyril Hrubis @ 2017-09-27 11:39 UTC (permalink / raw)
  To: ltp

Hi!
> 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?

> diff --git a/testcases/kernel/syscalls/utimensat/utimensat_tests.sh b/testcases/kernel/syscalls/utimensat/utimensat_tests.sh
> index 48154d6e6..41ea7997a 100755
> --- a/testcases/kernel/syscalls/utimensat/utimensat_tests.sh
> +++ b/testcases/kernel/syscalls/utimensat/utimensat_tests.sh
> @@ -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
> 
> -- 
> Cyril Hrubis
> chrubis@suse.cz
> 
> -- 
> Mailing list info: https://lists.linux.it/listinfo/ltp

-- 
Cyril Hrubis
chrubis@suse.cz

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

* [LTP] [PATCH] utimensat_tests.sh: returns EPERM on 4.4.27 and above
  2017-09-25 14:46     ` Cyril Hrubis
  2017-09-27 11:39       ` Cyril Hrubis
@ 2017-09-27 13:55       ` Jan Stancek
  2017-09-27 15:12         ` Cyril Hrubis
  1 sibling, 1 reply; 8+ messages in thread
From: Jan Stancek @ 2017-09-27 13:55 UTC (permalink / raw)
  To: ltp



----- Original Message -----
> Hi!
> > 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.

diff --git a/testcases/kernel/syscalls/utimensat/utimensat_tests.sh b/testcases/kernel/syscalls/utimensat/utimensat_tests.sh
index 48154d6e65b2..6d7fc5030aff 100755
--- a/testcases/kernel/syscalls/utimensat/utimensat_tests.sh
+++ b/testcases/kernel/syscalls/utimensat/utimensat_tests.sh
@@ -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

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

* [LTP] [PATCH] utimensat_tests.sh: returns EPERM on 4.4.27 and above
  2017-09-27 13:55       ` Jan Stancek
@ 2017-09-27 15:12         ` Cyril Hrubis
  2017-09-27 22:38           ` Naresh Kamboju
  0 siblings, 1 reply; 8+ messages in thread
From: Cyril Hrubis @ 2017-09-27 15:12 UTC (permalink / raw)
  To: ltp

Hi!
> 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.

-- 
Cyril Hrubis
chrubis@suse.cz

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

* [LTP] [PATCH] utimensat_tests.sh: returns EPERM on 4.4.27 and above
  2017-09-27 15:12         ` Cyril Hrubis
@ 2017-09-27 22:38           ` Naresh Kamboju
  0 siblings, 0 replies; 8+ messages in thread
From: Naresh Kamboju @ 2017-09-27 22:38 UTC (permalink / raw)
  To: ltp

On 27 September 2017 at 08:12, Cyril Hrubis <chrubis@suse.cz> wrote:
> Hi!
>> 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

>
> --
> Cyril Hrubis
> chrubis@suse.cz

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

end of thread, other threads:[~2017-09-27 22:38 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-09-06 11:30 [LTP] [PATCH] utimensat_tests.sh: returns EPERM on 4.4.27 and above naresh.kamboju
2017-09-06 11:54 ` Jan Stancek
2017-09-06 15:29   ` Sumit Semwal
2017-09-25 14:46     ` Cyril Hrubis
2017-09-27 11:39       ` Cyril Hrubis
2017-09-27 13:55       ` Jan Stancek
2017-09-27 15:12         ` Cyril Hrubis
2017-09-27 22:38           ` Naresh Kamboju

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.