diff mbox series

ustat: Fix EFAULT in 32bit compatability mode

Message ID 20190207101835.641-1-rpalethorpe@suse.com
State Accepted
Delegated to: Petr Vorel
Headers show
Series ustat: Fix EFAULT in 32bit compatability mode | expand

Commit Message

Richard Palethorpe Feb. 7, 2019, 10:18 a.m. UTC
This test fails with -m32 on Intel because the user land dev_num is too
large.

Signed-off-by: Richard Palethorpe <rpalethorpe@suse.com>
---

From looking at glibc, this test may also be broken on mips, but I am not sure
if that matters. AFAICT on all other platforms glibc always casts to uint
after performing a sanity check..

 testcases/kernel/syscalls/ustat/ustat01.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Jan Stancek Feb. 7, 2019, 12:16 p.m. UTC | #1
----- Original Message -----
> This test fails with -m32 on Intel because the user land dev_num is too
> large.
> 
> Signed-off-by: Richard Palethorpe <rpalethorpe@suse.com>
> ---
> 
> From looking at glibc, this test may also be broken on mips, but I am not
> sure
> if that matters. AFAICT on all other platforms glibc always casts to uint
> after performing a sanity check..

LGTM, LTP is using only 0 (and -1 for errno tests), so it shouldn't matter.

What about ustat02? Are you planning on sending something similar for that test?

Regards,
Jan

> 
>  testcases/kernel/syscalls/ustat/ustat01.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/testcases/kernel/syscalls/ustat/ustat01.c
> b/testcases/kernel/syscalls/ustat/ustat01.c
> index 3f1186c49..2e7dcc9d7 100644
> --- a/testcases/kernel/syscalls/ustat/ustat01.c
> +++ b/testcases/kernel/syscalls/ustat/ustat01.c
> @@ -20,7 +20,7 @@ void run(void)
>  {
>  	struct ustat ubuf;
>  
> -	TEST(tst_syscall(__NR_ustat, dev_num, &ubuf));
> +	TEST(tst_syscall(__NR_ustat, (unsigned int)dev_num, &ubuf));
>  
>  	if (TST_RET == -1)
>  		tst_res(TFAIL | TTERRNO, "ustat(2) failed");
> --
> 2.20.1
> 
> 
> --
> Mailing list info: https://lists.linux.it/listinfo/ltp
>
Petr Vorel Feb. 7, 2019, 12:52 p.m. UTC | #2
Hi Richard,

> This test fails with -m32 on Intel because the user land dev_num is too
> large.

Thanks for the fix, merged.


Kind regards,
Petr
Petr Vorel Feb. 7, 2019, 1:07 p.m. UTC | #3
Hi Jan,

> > From looking at glibc, this test may also be broken on mips, but I am not
> > sure
> > if that matters. AFAICT on all other platforms glibc always casts to uint
> > after performing a sanity check..

> LGTM, LTP is using only 0 (and -1 for errno tests), so it shouldn't matter.
I'm sorry I missed your mail, so pushed without your ack.

> What about ustat02? Are you planning on sending something similar for that test?
It's not needed for ustat02. Is it because *tc[test].dev in ustat02 is pointer?

Kind regards,
Petr
Richard Palethorpe Feb. 7, 2019, 2:38 p.m. UTC | #4
Hello,

Petr Vorel <pvorel@suse.cz> writes:

> Hi Jan,
>
>> > From looking at glibc, this test may also be broken on mips, but I am not
>> > sure
>> > if that matters. AFAICT on all other platforms glibc always casts to uint
>> > after performing a sanity check..
>
>> LGTM, LTP is using only 0 (and -1 for errno tests), so it shouldn't matter.
> I'm sorry I missed your mail, so pushed without your ack.
>
>> What about ustat02? Are you planning on sending something similar for that test?
> It's not needed for ustat02. Is it because *tc[test].dev in ustat02 is
> pointer?

I don't think so, but AFAICT ustat02 is still valid because passing the
wrong data type still has the desired effect of creating an invalid
buffer pointer in the bad address test. On the invalid parameter test,
only the first 32bits of dev are checked before EINVAL is thrown, so
again, it doesn't matter.

So I won't send another patch, but I am not against adding the cast
either.

>
> Kind regards,
> Petr


--
Thank you,
Richard.
diff mbox series

Patch

diff --git a/testcases/kernel/syscalls/ustat/ustat01.c b/testcases/kernel/syscalls/ustat/ustat01.c
index 3f1186c49..2e7dcc9d7 100644
--- a/testcases/kernel/syscalls/ustat/ustat01.c
+++ b/testcases/kernel/syscalls/ustat/ustat01.c
@@ -20,7 +20,7 @@  void run(void)
 {
 	struct ustat ubuf;
 
-	TEST(tst_syscall(__NR_ustat, dev_num, &ubuf));
+	TEST(tst_syscall(__NR_ustat, (unsigned int)dev_num, &ubuf));
 
 	if (TST_RET == -1)
 		tst_res(TFAIL | TTERRNO, "ustat(2) failed");