Re: [PATCH v2] hpet: Support 32-bit userspace

From: He Zhe
Date: Thu Jun 06 2024 - 08:39:09 EST




On 2024/6/6 18:34, Arnd Bergmann wrote:
> 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:

Thanks. v3 is sent.

Zhe

>
>> +#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