# Re: \[PATCH v06 05/36\] uapi linux/sysctl.h: use \_\_kernel\_size\_t instead of size\_t

- From: Dmitry V. Levin \<hidden\>
- Date: 2017-08-08 22:34:24 
- List: linux-api
- Page: https://ratatoskr.run/linux-api/2017/08/5062476
- Thread: https://ratatoskr.run/linux-api/2017/08/5060470/t.md

```text
On Sun, Aug 06, 2017 at 06:43:56PM +0200, Mikko Rapeli wrote:
> Fixes userspace compilation error:
> 
> error: unknown type name ‘size_t’
> 
> Signed-off-by: Mikko Rapeli <redacted>
> Cc: Arnd Bergmann <redacted>
> Cc: David S. Miller <redacted>
> ---
>  include/uapi/linux/sysctl.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/include/uapi/linux/sysctl.h b/include/uapi/linux/sysctl.h
> index e13d48058b8d..35a4b8b417fe 100644
> --- a/include/uapi/linux/sysctl.h
> +++ b/include/uapi/linux/sysctl.h
> @@ -35,9 +35,9 @@ struct __sysctl_args {
>  	int __user *name;
>  	int nlen;
>  	void __user *oldval;
> -	size_t __user *oldlenp;
> +	__kernel_size_t __user *oldlenp;
>  	void __user *newval;
> -	size_t newlen;
> +	__kernel_size_t newlen;
>  	unsigned long __unused[4];
>  };

You should be extremely careful when replacing size_t with __kernel_size_t
because e.g. on x32 you have sizeof(size_t) < sizeof(__kernel_size_t).

In case of sysctl.h this replacement would be wrong.

I submitted an alternative fix for this bug some time ago, see
http://lkml.kernel.org/r/20170222230652.GA14373-u2l5PoMzF/Vg9hUCZPvPmw@public.gmane.org


-- 
ldv
```

## Attachments

- [signature.asc](https://ratatoskr.run/linux-api/2017/08/5062476/attachment/0) (application/pgp-signature, 801 bytes)
