Re: [PATCH v2 2/4] uaccess: always export _copy_[from|to]_user with CONFIG_RUST

From: Valentin Obst
Date: Fri Feb 09 2024 - 11:49:58 EST


>>> -#else
>>> extern __must_check unsigned long
>>> _copy_from_user(void *, const void __user *, unsigned long);
>>> -#endif
>>
>> This function is now unconditionally declared, but only defined if
>> `!defined(INLINE_COPY_FROM_USER) || defined(CONFIG_RUST)`, i.e., in the
>> common case where it is inlined and Rust is disabled this can lead to
>> link-time problems if someone decides to use it.
>
> Yes, that is intentional.
>
> If someone tries to use it when the declaration is not there,
> they just get a compile-time error, which is not all that
> different from a link-time error in practice.
>
> It's unlikely to make a difference here, but enclosing
> declarations in an #ifdef is annoying when you want to
> reference it from somewhere that is parsed by the compiler
> but not called without the respective options.
>
> The if(IS_ENABLED()) and PTR_IF() constructs in particular
> only work when the unused functions are still declared.

I see, thanks for the explanation.

- Best Valentin

>
> Arnd