Subject: Re: [PATCH v1 net] netlink: Use copy_to_user() for optval in netlink_getsockopt().

From: Jakub Kicinski <[email-masked]>
Date: Tue, 18 Apr 2023 20:33:18 -0700

On Tue, 18 Apr 2023 17:42:46 -0700 Kuniyuki Iwashima wrote:
> Brad Spencer provided a detailed report that when calling getsockopt()
> for AF_NETLINK, some SOL_NETLINK options set only 1 byte even though such
> options require more than int as length.
> 
> The options return a flag value that fits into 1 byte, but such behaviour
> confuses users who do not strictly check the value as char.
> 
> Currently, netlink_getsockopt() uses put_user() to copy data to optlen and
> optval, but put_user() casts the data based on the pointer, char *optval.
> So, only 1 byte is set to optval.
> 
> To avoid this behaviour, we need to use copy_to_user() or cast optval for
> put_user().
> 
> Now getsockopt() accepts char as optval as the flags are only 1 byte.

I think it's worth doing, but it will change the return value on big
endian, right?