[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <0c2ea86d55454b55a88db716f967dda4@AcuMS.aculab.com>
Date: Wed, 19 Apr 2023 15:43:45 +0000
From: David Laight <David.Laight@...LAB.COM>
To: 'Brad Spencer' <bspencer@...ckberry.com>,
"netdev@...r.kernel.org" <netdev@...r.kernel.org>
CC: "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: RE: netlink getsockopt() sets only one byte?
From: Brad Spencer <bspencer@...ckberry.com>
> Sent: 18 April 2023 18:38
>
> Calling getsockopt() on a netlink socket with SOL_NETLINK options that
> use type int only sets the first byte of the int value but returns an
> optlen equal to sizeof(int), at least on x86_64.
>
>
> The detailed description:
>
> It looks like netlink_getsockopt() calls put_user() with a char*
> pointer, and I think that causes it to copy only one byte from the val
> result, despite len being sizeof(int).
>
> Is this the expected behaviour? The returned size is 4, after all,
> and other int-sized socket options (outside of netlink) like
> SO_REUSEADDR set all bytes of the int.
It will be horribly broken on anything big-endian.
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
Powered by blists - more mailing lists