Re: [PATCH v2] hpet: Support 32-bit userspace
From: Arnd Bergmann
Date: Thu Jun 06 2024 - 06:34:48 EST
On Thu, Jun 6, 2024, at 11:46, He Zhe wrote:
> v2:
> - Use in_compat_syscall to determine if we're handling 32-bit or 64-bit
> - Drop unnecessary compat_ptr for hpet_ioctl_common
> - Add comment for COMPAT_HPET_INFO and COMPAT_HPET_IRQFREQ
Thanks, this version looks correct to me,
Reviewed-by: Arnd Bergmann <arnd@xxxxxxxx>
I would suggest one simplification though:
> +#ifdef CONFIG_COMPAT
> + if (in_compat_syscall()) {
> + if (count < sizeof(compat_ulong_t))
> + return -EINVAL;
> + } else {
> + if (count < sizeof(unsigned long))
> + return -EINVAL;
> + }
> +#else
> if (count < sizeof(unsigned long))
> return -EINVAL;
> +#endif
The #ifdef/#else is not really required here, since
in_compat_syscall() is defined to return false when
this is unset. For both cases, it should be sufficient
to keep the part inside of the #ifdef block.
Arnd