From: Alexey Izbyshev <izbyshev@ispras.ru>
To: musl@lists.openwall.com
Subject: Re: [musl] __convert_scm_timestamps() probably breaks with struct timeval
Date: Fri, 02 Jun 2023 18:54:28 +0300 [thread overview]
Message-ID: <59853ef30ea5fded2693cc2d18ebcf8a@ispras.ru> (raw)
In-Reply-To: <ZHoBgc69aLVKVscf@voyager>
On 2023-06-02 17:49, Markus Wichmann wrote:
> Hi all,
>
> I couldn't think of a better subject. For unrelated reasons, today I
> stumbled upon the abovenamed function. It looks through all control
> messages in a msghdr, looking for SCM_TIMESTAMP_OLD and
> SCM_TIMESTAMPNS_OLD, and converting an array two long into an array of
> two long long.
>
> This will work with struct timespec (or SCM_TIMESTAMPNS_OLD) on all
> architectures, because struct timespec has been defined specifically
> for
> this to work (due to the kernel accessing it the same way). But it will
> break with struct timeval (or SCM_TIMESTAMP_OLD).
>
> First of all, on some 32-bit archs (and this code is only used on
> 32-bit
> archs) we have alignof(int64_t) == 4, and therefore sizeof (struct
> timeval) == 12. Therefore CMSG_LEN(sizeof (long long[2])) !=
> CMSG_LEN(struct timeval), and therefore, applications won't read the
> newly converted cmsg. All the work for nothing.
Hi,
timeval is specified in alltypes.h.in as:
STRUCT timeval { time_t tv_sec; suseconds_t tv_usec; };
And suseconds_t as:
TYPEDEF _Int64 suseconds_t;
So timeval and timespec structs have the same layout in musl, and it
matches long long[2]. Maybe you assumed that suseconds_t is a 32-bit
type?
Alexey
prev parent reply other threads:[~2023-06-02 15:54 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-02 14:49 Markus Wichmann
2023-06-02 15:23 ` Rich Felker
2023-06-02 15:55 ` Markus Wichmann
2023-06-02 16:56 ` Rich Felker
2023-06-02 15:54 ` Alexey Izbyshev [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=59853ef30ea5fded2693cc2d18ebcf8a@ispras.ru \
--to=izbyshev@ispras.ru \
--cc=musl@lists.openwall.com \
/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.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/musl/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).