From: David Laight <David.Laight@ACULAB.COM>
To: 'Brad Spencer' <bspencer@blackberry.com>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: RE: netlink getsockopt() sets only one byte?
Date: Wed, 19 Apr 2023 15:43:45 +0000 [thread overview]
Message-ID: <0c2ea86d55454b55a88db716f967dda4@AcuMS.aculab.com> (raw)
In-Reply-To: <ZD7VkNWFfp22kTDt@datsun.rim.net>
From: Brad Spencer <bspencer@blackberry.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)
prev parent reply other threads:[~2023-04-19 15:44 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-18 17:38 Brad Spencer
2023-04-18 21:26 ` Kuniyuki Iwashima
2023-04-19 15:43 ` David Laight [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=0c2ea86d55454b55a88db716f967dda4@AcuMS.aculab.com \
--to=david.laight@aculab.com \
--cc=bspencer@blackberry.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®