Re: [PATCH v4 18/26] arm64: vdso32: Replace TASK_SIZE_32 check in vgettimeofday

From: Andy Lutomirski
Date: Thu Mar 19 2020 - 11:50:01 EST


On Tue, Mar 17, 2020 at 7:38 AM Catalin Marinas <catalin.marinas@xxxxxxx> wrote:
>
> On Tue, Mar 17, 2020 at 12:22:12PM +0000, Vincenzo Frascino wrote:
> > diff --git a/arch/arm64/kernel/vdso32/vgettimeofday.c b/arch/arm64/kernel/vdso32/vgettimeofday.c
> > index 54fc1c2ce93f..91138077b073 100644
> > --- a/arch/arm64/kernel/vdso32/vgettimeofday.c
> > +++ b/arch/arm64/kernel/vdso32/vgettimeofday.c
> > @@ -8,11 +8,14 @@
> > #include <linux/time.h>
> > #include <linux/types.h>
> >
> > +#define VALID_CLOCK_ID(x) \
> > + ((x >= 0) && (x < VDSO_BASES))
> > +
> > int __vdso_clock_gettime(clockid_t clock,
> > struct old_timespec32 *ts)
> > {
> > /* The checks below are required for ABI consistency with arm */
> > - if ((u32)ts >= TASK_SIZE_32)
> > + if ((u32)ts > UINTPTR_MAX - sizeof(*ts) + 1)
> > return -EFAULT;
> >
> > return __cvdso_clock_gettime32(clock, ts);
>
> I probably miss something but I can't find the TASK_SIZE check in the
> arch/arm/vdso/vgettimeofday.c code. Is this done elsewhere?
>

Can you not just remove the TASK_SIZE_32 check entirely? If you pass
a garbage address to the vDSO, you are quite likely to get SIGSEGV.
Why does this particular type of error need special handling?