diff mbox series

ustat02: Fix EFAULT in 32bit compatibility mode

Message ID 20190719124817.5140-1-steven.price@arm.com
State Accepted
Headers show
Series ustat02: Fix EFAULT in 32bit compatibility mode | expand

Commit Message

Steven Price July 19, 2019, 12:48 p.m. UTC
The size of dev_t is larger than 32 bits which causes the dev argument
to be passed incorrectly. On Arm this means that the EFAULT test case
actually returns EINVAL because the device number isn't recognised.

Signed-off-by: Steven Price <steven.price@arm.com>
---
This is the same fix as 989bcfc7544d ("ustat: Fix EFAULT in 32bit
compatability mode") applied to ustat02. Originally it was justified[1]
that this doesn't affect ustat02 as the test works on x86, however it
does affect Arm.

I believe this only affects Arm and not x86 because only Arm requires a
64 bit argument to be aligned in registers. This means the test is
currently passing the dev number in r2/r3 and leaving junk in r1 which
is then being treated as the device number.

However even on x86 the pointer value is actually the upper bits of
root_dev rather than the expected (void*)-1.

[1] http://lists.linux.it/pipermail/ltp/2019-February/010752.html
---
 testcases/kernel/syscalls/ustat/ustat02.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Li Wang July 22, 2019, 9:55 a.m. UTC | #1
On Fri, Jul 19, 2019 at 11:19 PM Steven Price <steven.price@arm.com> wrote:
>
> The size of dev_t is larger than 32 bits which causes the dev argument
> to be passed incorrectly. On Arm this means that the EFAULT test case
> actually returns EINVAL because the device number isn't recognised.
>
> Signed-off-by: Steven Price <steven.price@arm.com>
Acked-by: Li Wang <liwang@redhat.com>

Thanks for the fix, this patch works for me,
Li Wang July 23, 2019, 3:14 a.m. UTC | #2
On Mon, Jul 22, 2019 at 5:55 PM Li Wang <liwang@redhat.com> wrote:
>
> On Fri, Jul 19, 2019 at 11:19 PM Steven Price <steven.price@arm.com> wrote:
> >
> > The size of dev_t is larger than 32 bits which causes the dev argument
> > to be passed incorrectly. On Arm this means that the EFAULT test case
> > actually returns EINVAL because the device number isn't recognised.
> >
> > Signed-off-by: Steven Price <steven.price@arm.com>
> Acked-by: Li Wang <liwang@redhat.com>

Pushed.
diff mbox series

Patch

diff --git a/testcases/kernel/syscalls/ustat/ustat02.c b/testcases/kernel/syscalls/ustat/ustat02.c
index 9bbe4f3f5..1a0e9e059 100644
--- a/testcases/kernel/syscalls/ustat/ustat02.c
+++ b/testcases/kernel/syscalls/ustat/ustat02.c
@@ -36,7 +36,7 @@  int TST_TOTAL = ARRAY_SIZE(tc);
 
 void run(unsigned int test)
 {
-	TEST(tst_syscall(__NR_ustat, *tc[test].dev, tc[test].buf));
+	TEST(tst_syscall(__NR_ustat, (unsigned int)*tc[test].dev, tc[test].buf));
 
 	if ((TST_RET == -1) && (TST_ERR == tc[test].exp_errno))
 		tst_res(TPASS | TTERRNO, "ustat(2) expected failure");