diff mbox series

finit_module02: fix exp. errno for O_WRONLY testcase

Message ID 04692b4000ee415add41128173e395f830ea3e56.1635168255.git.jstancek@redhat.com
State Changes Requested
Headers show
Series finit_module02: fix exp. errno for O_WRONLY testcase | expand

Commit Message

Jan Stancek Oct. 25, 2021, 1:25 p.m. UTC
commit 032146cda855 ("vfs: check fd has read access in
kernel_read_file_from_fd()") changed errno back to EBADF,
which is correct value according to man page, so tweak
the test to expect it for kernels >= 5.15.

Signed-off-by: Jan Stancek <jstancek@redhat.com>
---
 testcases/kernel/syscalls/finit_module/finit_module02.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Cyril Hrubis Oct. 26, 2021, 8:04 a.m. UTC | #1
Hi!
> commit 032146cda855 ("vfs: check fd has read access in
> kernel_read_file_from_fd()") changed errno back to EBADF,
> which is correct value according to man page, so tweak
> the test to expect it for kernels >= 5.15.

Shouldn't we drop the check completely and rather than working around
the bug add this commit to the test metadata?

> Signed-off-by: Jan Stancek <jstancek@redhat.com>
> ---
>  testcases/kernel/syscalls/finit_module/finit_module02.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/testcases/kernel/syscalls/finit_module/finit_module02.c b/testcases/kernel/syscalls/finit_module/finit_module02.c
> index 0d2bf917ea64..9b5d3563b74e 100644
> --- a/testcases/kernel/syscalls/finit_module/finit_module02.c
> +++ b/testcases/kernel/syscalls/finit_module/finit_module02.c
> @@ -52,7 +52,7 @@ static void bad_fd_setup(struct tcase *tc)
>  
>  static void wo_file_setup(struct tcase *tc)
>  {
> -	if (tst_kvercmp(4, 6, 0) < 0)
> +	if (tst_kvercmp(4, 6, 0) < 0 || tst_kvercmp(5, 15, 0) >= 0)
>  		tc->exp_errno = EBADF;
>  	else
>  		tc->exp_errno = ETXTBSY;
> -- 
> 2.27.0
> 
> 
> -- 
> Mailing list info: https://lists.linux.it/listinfo/ltp
Jan Stancek Oct. 26, 2021, 10:35 a.m. UTC | #2
On Tue, Oct 26, 2021 at 10:03 AM Cyril Hrubis <chrubis@suse.cz> wrote:
>
> Hi!
> > commit 032146cda855 ("vfs: check fd has read access in
> > kernel_read_file_from_fd()") changed errno back to EBADF,
> > which is correct value according to man page, so tweak
> > the test to expect it for kernels >= 5.15.
>
> Shouldn't we drop the check completely and rather than working around
> the bug add this commit to the test metadata?

Sure, I'll post v2.

>
> > Signed-off-by: Jan Stancek <jstancek@redhat.com>
> > ---
> >  testcases/kernel/syscalls/finit_module/finit_module02.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/testcases/kernel/syscalls/finit_module/finit_module02.c b/testcases/kernel/syscalls/finit_module/finit_module02.c
> > index 0d2bf917ea64..9b5d3563b74e 100644
> > --- a/testcases/kernel/syscalls/finit_module/finit_module02.c
> > +++ b/testcases/kernel/syscalls/finit_module/finit_module02.c
> > @@ -52,7 +52,7 @@ static void bad_fd_setup(struct tcase *tc)
> >
> >  static void wo_file_setup(struct tcase *tc)
> >  {
> > -     if (tst_kvercmp(4, 6, 0) < 0)
> > +     if (tst_kvercmp(4, 6, 0) < 0 || tst_kvercmp(5, 15, 0) >= 0)
> >               tc->exp_errno = EBADF;
> >       else
> >               tc->exp_errno = ETXTBSY;
> > --
> > 2.27.0
> >
> >
> > --
> > Mailing list info: https://lists.linux.it/listinfo/ltp
>
> --
> Cyril Hrubis
> chrubis@suse.cz
>
xuyang2018.jy@fujitsu.com Nov. 17, 2021, 7:54 a.m. UTC | #3
Hi Jan
> commit 032146cda855 ("vfs: check fd has read access in
> kernel_read_file_from_fd()") changed errno back to EBADF,
> which is correct value according to man page, so tweak
> the test to expect it for kernels>= 5.15.
It seems we still can hit ETXTBSY error if we  use RDWR fd on kernels >= 
5.15.

This error existed since the following commit because of 
deny_write_access api
commit 39d637af5aa7577f655c58b9e55587566c63a0af
Author: Dmitry Kasatkin <dmitry.kasatkin@huawei.com>
Date:   Sun Oct 26 12:42:07 2014 +0200

     vfs: forbid write access when reading a file into memory

I suggest add a RDWR test and send a patch to record a ETXTBSY error( 
Since linux 4.7).

What do you think about this?

Best Regards
Yang Xu
>
> Signed-off-by: Jan Stancek<jstancek@redhat.com>
> ---
>   testcases/kernel/syscalls/finit_module/finit_module02.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/testcases/kernel/syscalls/finit_module/finit_module02.c b/testcases/kernel/syscalls/finit_module/finit_module02.c
> index 0d2bf917ea64..9b5d3563b74e 100644
> --- a/testcases/kernel/syscalls/finit_module/finit_module02.c
> +++ b/testcases/kernel/syscalls/finit_module/finit_module02.c
> @@ -52,7 +52,7 @@ static void bad_fd_setup(struct tcase *tc)
>
>   static void wo_file_setup(struct tcase *tc)
>   {
> -	if (tst_kvercmp(4, 6, 0)<  0)
> +	if (tst_kvercmp(4, 6, 0)<  0 || tst_kvercmp(5, 15, 0)>= 0)
>   		tc->exp_errno = EBADF;
>   	else
>   		tc->exp_errno = ETXTBSY;
Jan Stancek Nov. 22, 2021, 6:42 a.m. UTC | #4
On Wed, Nov 17, 2021 at 8:54 AM xuyang2018.jy@fujitsu.com
<xuyang2018.jy@fujitsu.com> wrote:
>
> Hi Jan
> > commit 032146cda855 ("vfs: check fd has read access in
> > kernel_read_file_from_fd()") changed errno back to EBADF,
> > which is correct value according to man page, so tweak
> > the test to expect it for kernels>= 5.15.
> It seems we still can hit ETXTBSY error if we  use RDWR fd on kernels >=
> 5.15.
>
> This error existed since the following commit because of
> deny_write_access api
> commit 39d637af5aa7577f655c58b9e55587566c63a0af
> Author: Dmitry Kasatkin <dmitry.kasatkin@huawei.com>
> Date:   Sun Oct 26 12:42:07 2014 +0200
>
>      vfs: forbid write access when reading a file into memory
>
> I suggest add a RDWR test and send a patch to record a ETXTBSY error(
> Since linux 4.7).
>
> What do you think about this?

(Sorry for delay, I'm catching up with email after holidays)
Since it's also not documented, I'd wait for Cyril's patch first. But
we can always change it later (I see patch was already merged).


>
> Best Regards
> Yang Xu
> >
> > Signed-off-by: Jan Stancek<jstancek@redhat.com>
> > ---
> >   testcases/kernel/syscalls/finit_module/finit_module02.c | 2 +-
> >   1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/testcases/kernel/syscalls/finit_module/finit_module02.c b/testcases/kernel/syscalls/finit_module/finit_module02.c
> > index 0d2bf917ea64..9b5d3563b74e 100644
> > --- a/testcases/kernel/syscalls/finit_module/finit_module02.c
> > +++ b/testcases/kernel/syscalls/finit_module/finit_module02.c
> > @@ -52,7 +52,7 @@ static void bad_fd_setup(struct tcase *tc)
> >
> >   static void wo_file_setup(struct tcase *tc)
> >   {
> > -     if (tst_kvercmp(4, 6, 0)<  0)
> > +     if (tst_kvercmp(4, 6, 0)<  0 || tst_kvercmp(5, 15, 0)>= 0)
> >               tc->exp_errno = EBADF;
> >       else
> >               tc->exp_errno = ETXTBSY;
xuyang2018.jy@fujitsu.com Nov. 22, 2021, 7:09 a.m. UTC | #5
Hi Jan
> On Wed, Nov 17, 2021 at 8:54 AM xuyang2018.jy@fujitsu.com
> <xuyang2018.jy@fujitsu.com>  wrote:
>>
>> Hi Jan
>>> commit 032146cda855 ("vfs: check fd has read access in
>>> kernel_read_file_from_fd()") changed errno back to EBADF,
>>> which is correct value according to man page, so tweak
>>> the test to expect it for kernels>= 5.15.
>> It seems we still can hit ETXTBSY error if we  use RDWR fd on kernels>=
>> 5.15.
>>
>> This error existed since the following commit because of
>> deny_write_access api
>> commit 39d637af5aa7577f655c58b9e55587566c63a0af
>> Author: Dmitry Kasatkin<dmitry.kasatkin@huawei.com>
>> Date:   Sun Oct 26 12:42:07 2014 +0200
>>
>>       vfs: forbid write access when reading a file into memory
>>
>> I suggest add a RDWR test and send a patch to record a ETXTBSY error(
>> Since linux 4.7).
>>
>> What do you think about this?
>
> (Sorry for delay, I'm catching up with email after holidays)
> Since it's also not documented, I'd wait for Cyril's patch first. But
> we can always change it later (I see patch was already merged).
Yes, I have merged my patch with Richard's review.
Also, I  have documented this error by sending a patch[1](still in 
review) to man-pages community.
[1]https://lore.kernel.org/linux-man/1637136967-13028-1-git-send-email-xuyang2018.jy@fujitsu.com/T/#u

Best Regards
Yang Xu
>
>
>>
>> Best Regards
>> Yang Xu
>>>
>>> Signed-off-by: Jan Stancek<jstancek@redhat.com>
>>> ---
>>>    testcases/kernel/syscalls/finit_module/finit_module02.c | 2 +-
>>>    1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/testcases/kernel/syscalls/finit_module/finit_module02.c b/testcases/kernel/syscalls/finit_module/finit_module02.c
>>> index 0d2bf917ea64..9b5d3563b74e 100644
>>> --- a/testcases/kernel/syscalls/finit_module/finit_module02.c
>>> +++ b/testcases/kernel/syscalls/finit_module/finit_module02.c
>>> @@ -52,7 +52,7 @@ static void bad_fd_setup(struct tcase *tc)
>>>
>>>    static void wo_file_setup(struct tcase *tc)
>>>    {
>>> -     if (tst_kvercmp(4, 6, 0)<   0)
>>> +     if (tst_kvercmp(4, 6, 0)<   0 || tst_kvercmp(5, 15, 0)>= 0)
>>>                tc->exp_errno = EBADF;
>>>        else
>>>                tc->exp_errno = ETXTBSY;
>
diff mbox series

Patch

diff --git a/testcases/kernel/syscalls/finit_module/finit_module02.c b/testcases/kernel/syscalls/finit_module/finit_module02.c
index 0d2bf917ea64..9b5d3563b74e 100644
--- a/testcases/kernel/syscalls/finit_module/finit_module02.c
+++ b/testcases/kernel/syscalls/finit_module/finit_module02.c
@@ -52,7 +52,7 @@  static void bad_fd_setup(struct tcase *tc)
 
 static void wo_file_setup(struct tcase *tc)
 {
-	if (tst_kvercmp(4, 6, 0) < 0)
+	if (tst_kvercmp(4, 6, 0) < 0 || tst_kvercmp(5, 15, 0) >= 0)
 		tc->exp_errno = EBADF;
 	else
 		tc->exp_errno = ETXTBSY;