Re: [PATCH v2] sh: implicit access_ok() needs an #include

From: Arnd Bergmann
Date: Thu Feb 02 2023 - 02:48:11 EST


On Thu, Feb 2, 2023, at 06:31, Randy Dunlap wrote:
> Building arch/sh/ has a build error/warning that is fixed by
> adding an #include of a header file.
>
> ../arch/sh/include/asm/checksum_32.h: In function
> 'csum_and_copy_from_user':
> ../arch/sh/include/asm/checksum_32.h:53:14: error: implicit declaration
> of function 'access_ok' [-Werror=implicit-function-declaration]
> 53 | if (!access_ok(src, len))
> | ^~~~~~~~~
>
> Fixes: 7fe8970a78a1 ("sh32: convert to csum_and_copy_from_user()")
> Signed-off-by: Randy Dunlap <rdunlap@xxxxxxxxxxxxx>
> Cc: Al Viro <viro@xxxxxxxxxxxxxxxxxx>
> Cc: Yoshinori Sato <ysato@xxxxxxxxxxxxxxxxxxxx>
> Cc: Rich Felker <dalias@xxxxxxxx>
> Cc: linux-sh@xxxxxxxxxxxxxxx
> Cc: John Paul Adrian Glaubitz <glaubitz@xxxxxxxxxxxxxxxxxxx>
> Cc: Arnd Bergmann <arnd@xxxxxxxx>
> Cc: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
> ---
> v2: add Subject: and patch description

Thanks for the fix!

>
> arch/sh/include/asm/checksum_32.h | 1 +
> 1 file changed, 1 insertion(+)
>
> diff -- a/arch/sh/include/asm/checksum_32.h b/arch/sh/include/asm/checksum_32.h
> --- a/arch/sh/include/asm/checksum_32.h
> +++ b/arch/sh/include/asm/checksum_32.h
> @@ -7,6 +7,7 @@
> */
>
> #include <linux/in6.h>
> +#include <asm-generic/access_ok.h>

This will work correctly, but it is not the intended usage of the
header. Anything in asm-generic/*.h should only be included by
a particular header, usually the asm/*.h with the same name or in this
case the asm/uaccess.h header.

I think the correct fix here is to include asm/uaccess.h instead
of asm-generic/access_ok.h.

Arnd