From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 23978 invoked from network); 2 Jun 2023 15:54:45 -0000 Received: from second.openwall.net (193.110.157.125) by inbox.vuxu.org with ESMTPUTF8; 2 Jun 2023 15:54:45 -0000 Received: (qmail 31994 invoked by uid 550); 2 Jun 2023 15:54:42 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com Received: (qmail 31962 invoked from network); 2 Jun 2023 15:54:41 -0000 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.ispras.ru 0230944C100B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ispras.ru; s=default; t=1685721269; bh=N4hLv+UvA7x1qYIG4wCWuAfH9UCaROLNHig7qowr6bg=; h=Date:From:To:Subject:Reply-To:In-Reply-To:References:From; b=RFl5bMVQhPDmLgi6SR+12KqPzIHce1kpDYRFa3EV22v+YfxzGDnxQlxvhmhi/xo+r rKczu07iXLmh6yBNp22dr5XZbGVOz+cNCMAiJtaZMIxNiqd0+yHsvga8kkZUdzI+La Hy2r68b3yjv78mF2W3UTiaDgCyZ5thAeexLXPr0M= MIME-Version: 1.0 Date: Fri, 02 Jun 2023 18:54:28 +0300 From: Alexey Izbyshev To: musl@lists.openwall.com Mail-Followup-To: musl@lists.openwall.com In-Reply-To: References: User-Agent: Roundcube Webmail/1.4.4 Message-ID: <59853ef30ea5fded2693cc2d18ebcf8a@ispras.ru> X-Sender: izbyshev@ispras.ru Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [musl] __convert_scm_timestamps() probably breaks with struct timeval 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