From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from eggs.gnu.org (eggs.gnu.org [IPv6:2001:470:142:3::10]) by sourceware.org (Postfix) with ESMTPS id 91B943858D28 for ; Mon, 1 May 2023 16:34:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 91B943858D28 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gnu.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gnu.org Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ptWTe-0000VH-Aq; Mon, 01 May 2023 12:34:14 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=In-Reply-To:MIME-Version:References:Subject:To:From: Date; bh=oEohaTIiMMT587cqHXoR4IwFDNM/1qjHCYeWrJMAUbE=; b=glaLp3+2bsmOIWMj6R0F 1JGZy6jXyg14vptzQ5DRNdtc8YDjFV0lr/60Hn+leCrWUTr0NCYoRAJvNG8+YuvLBTZponA7UeDY6 onuo5KYmGdT+hpcFD2SrqHlLQaRtSocZdQ9X4Y3i37XzmWygh4lQ5rzPRUgXhvMN5P8Tre0dul0pq a9lcgt/vfJtNLabiNUUNNRHKM0Ph1tE35trI7DHcsNmkNhlE11etbvov6QnBDAJaNNm6bvJJkdxHL UbADhhQp9qav9lv7SsnbEZurNkFM5aOC6eaL1TQc7/VNyJIsf0eMv66HIXnWLQqEk5Lb6yVtCunEi IbrYI5hFvJ4HEw==; Received: from [2a01:cb19:4a:a400:de41:a9ff:fe47:ec49] (helo=begin) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ptWTd-0007mA-Sz; Mon, 01 May 2023 12:34:13 -0400 Received: from samy by begin with local (Exim 4.96) (envelope-from ) id 1ptWTb-00Gkhp-1u; Mon, 01 May 2023 18:34:11 +0200 Date: Mon, 1 May 2023 18:34:11 +0200 From: Samuel Thibault To: Andreas Schwab Cc: bug-hurd@gnu.org, libc-alpha@sourceware.org, commit-hurd@gnu.org Subject: Re: [hurd, commited] socket: Fix tst-cmsghdr-skeleton.c use of cmsg_len Message-ID: <20230501163411.lujr4wldix7x7nry@begin> Mail-Followup-To: Andreas Schwab , bug-hurd@gnu.org, libc-alpha@sourceware.org, commit-hurd@gnu.org References: <20230501130607.3846669-1-samuel.thibault@ens-lyon.org> <874jow41ei.fsf@igel.home> <20230501134344.64xqz7doskwlsmyb@begin> <87zg6o2lor.fsf@igel.home> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: <87zg6o2lor.fsf@igel.home> Organization: I am not organized User-Agent: NeoMutt/20170609 (1.8.3) X-Spam-Status: No, score=-12.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,SPF_HELO_PASS,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Andreas Schwab, le lun. 01 mai 2023 16:03:32 +0200, a ecrit: > On Mai 01 2023, Samuel Thibault wrote: >=20 > > Andreas Schwab, le lun. 01 mai 2023 15:38:45 +0200, a ecrit: > >> On Mai 01 2023, Samuel Thibault wrote: > >>=20 > >> > cmsg_len is supposed to be socklen_t according to standards, but it = was made > >> > size_t on Linux, see BZ 16919. For ports that have it socklen_t, SIZ= E_MAX is > >> > too large. We can however explicitly cast it to the type of cmsg_len= so it > >> > will fit according to that type. > >> > --- > >> > socket/tst-cmsghdr-skeleton.c | 2 +- > >> > 1 file changed, 1 insertion(+), 1 deletion(-) > >> > > >> > diff --git a/socket/tst-cmsghdr-skeleton.c b/socket/tst-cmsghdr-skel= eton.c > >> > index 296a0a8581..9516139f87 100644 > >> > --- a/socket/tst-cmsghdr-skeleton.c > >> > +++ b/socket/tst-cmsghdr-skeleton.c > >> > @@ -49,7 +49,7 @@ RUN_TEST_FUNCNAME (CMSG_NXTHDR_IMPL) (void) > >> > /* The first header length is so big, using it would cause an ove= rflow. */ > >> > cmsg =3D CMSG_FIRSTHDR (&m); > >> > TEST_VERIFY_EXIT ((char *) cmsg =3D=3D cmsgbuf); > >> > - cmsg->cmsg_len =3D SIZE_MAX; > >> > + cmsg->cmsg_len =3D (__typeof (cmsg->cmsg_len)) SIZE_MAX; > >>=20 > >> What does that fix? > > > > 64bit hurd, where cmsg_len is socklen_t as the standards require (thus > > 32bit). >=20 > And what does it fix? You mean the error message? The SIZE_MAX constant truncation down from 64bit to 32bit: x86_64-glibc-gnu-gcc tst-cmsghdr.c -c -std=3Dgnu11 -fgnu89-inline -g -O2 -= Wall -Wwrite-strings -Wundef -Werror -fmerge-all-constants -frounding-math = -fno-stack-protector -fno-common -Wno-parentheses -Wstrict-prototypes -Wold= -style-definition -fmath-errno -fPIE -I../include -I/mnt/scratch= /sthibault/build-glibc/build/glibcs/x86_64-gnu/glibc/socket -I/mnt/scratch= /sthibault/build-glibc/build/glibcs/x86_64-gnu/glibc -I../sysdeps/mach/hur= d/x86_64 -I../sysdeps/mach/hurd/x86 -I../sysdeps/mach/hurd/x86_64/htl -I= =2E./sysdeps/mach/hurd/htl -I../sysdeps/hurd/htl -I../sysdeps/mach/htl -= I../sysdeps/htl/include -I../sysdeps/htl -I../sysdeps/pthread -I../sysdep= s/mach/hurd/x86/htl -I../sysdeps/x86_64/htl -I../sysdeps/x86/htl -I../sy= sdeps/mach/hurd -I../sysdeps/gnu -I../sysdeps/unix/bsd -I../sysdeps/unix= /inet -I../sysdeps/mach/x86_64 -I../sysdeps/mach/x86 -I../sysdeps/mach/i= nclude -I../sysdeps/mach -I../sysdeps/x86_64/64 -I../sysdeps/x86_64/fpu/m= ultiarch -I../sysdeps/x86_64/fpu -I../sysdeps/x86/fpu -I../sysdeps/x86_6= 4/multiarch -I../sysdeps/x86_64 -I../sysdeps/x86/include -I../sysdeps/x86= -I../sysdeps/ieee754/float128 -I../sysdeps/ieee754/ldbl-96/include -I../= sysdeps/ieee754/ldbl-96 -I../sysdeps/ieee754/dbl-64 -I../sysdeps/ieee754/= flt-32 -I../sysdeps/hurd/include -I../sysdeps/hurd -I../sysdeps/unix -I.= =2E/sysdeps/posix -I../sysdeps/wordsize-64 -I../sysdeps/ieee754 -I../sys= deps/generic -I../hurd -I/mnt/scratch/sthibault/build-glibc/build/glibcs/x8= 6_64-gnu/glibc/hurd/ -I../mach -I/mnt/scratch/sthibault/build-glibc/build/g= libcs/x86_64-gnu/glibc/mach/ -I.. -I../libio -I. -D_LIBC_REENTRANT -includ= e /mnt/scratch/sthibault/build-glibc/build/glibcs/x86_64-gnu/glibc/libc-mod= ules.h -DMODULE_NAME=3Dtestsuite -include ../include/libc-symbols.h -DPIC = -DTOP_NAMESPACE=3Dglibc -o /mnt/scratch/sthibault/build-glibc/build/gli= bcs/x86_64-gnu/glibc/socket/tst-cmsghdr.o -MD -MP -MF /mnt/scratch/sthibaul= t/build-glibc/build/glibcs/x86_64-gnu/glibc/socket/tst-cmsghdr.o.dt -MT /mn= t/scratch/sthibault/build-glibc/build/glibcs/x86_64-gnu/glibc/socket/tst-cm= sghdr.o In file included from ../include/stdint.h:1, from tst-cmsghdr-skeleton.c:24, from tst-cmsghdr.c:31: tst-cmsghdr-skeleton.c: In function 'run_test_CMSG_NXTHDR': =2E./stdlib/stdint.h:227:33: error: conversion from 'long unsigned int' to = 'socklen_t' {aka 'unsigned int'} changes value from '18446744073709551615' = to '4294967295' [-Werror=3Doverflow] 227 | # define SIZE_MAX (18446744073709551615UL) | ^ tst-cmsghdr-skeleton.c:52:20: note: in expansion of macro 'SIZE_MAX' 52 | cmsg->cmsg_len =3D SIZE_MAX; | ^~~~~~~~ Samuel