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.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H2, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 8937 invoked from network); 3 May 2023 07:13:57 -0000 Received: from second.openwall.net (193.110.157.125) by inbox.vuxu.org with ESMTPUTF8; 3 May 2023 07:13:57 -0000 Received: (qmail 16142 invoked by uid 550); 3 May 2023 07:13:54 -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 16097 invoked from network); 3 May 2023 07:13:53 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=inria.fr; s=dc; h=date:from:to:cc:subject:message-id:in-reply-to: references:mime-version; bh=6K4FYQjx4i/cyWqOL950xOy8Whp+XfIar+pMoxLR1oQ=; b=PUZxhHik2PLI92y3sxA7EcIRptHdpAhSpEr/yWr0Emlqxbp6jCd6AjdW Kd7l/W0Bu+MMsrYiHbSvMz+Hi8jwDxkmLRmCxxEGx5jqv40iOYGXXvXhh O6yaTz3e/bhNCAvOZCUvmkyxzj1/BJOFnGoaaZhV7eN36xvY1ELx+8Rq/ g=; Authentication-Results: mail2-relais-roc.national.inria.fr; dkim=none (message not signed) header.i=none; spf=SoftFail smtp.mailfrom=jens.gustedt@inria.fr; dmarc=fail (p=none dis=none) d=inria.fr X-IronPort-AV: E=Sophos;i="5.99,246,1677538800"; d="scan'208";a="105955234" Date: Wed, 3 May 2023 09:13:40 +0200 From: =?UTF-8?B?SuKCkeKCmeKCmw==?= Gustedt To: Rich Felker Cc: musl@lists.openwall.com Message-ID: <20230503091340.4627057a@inria.fr> In-Reply-To: <20230502232009.GT4163@brightrain.aerifal.cx> References: <20230501205037.29e42745@inria.fr> <20230501194121.GS4163@brightrain.aerifal.cx> <20230502085740.23ff20d5@inria.fr> <20230502155903.30bee099@inria.fr> <20230502232009.GT4163@brightrain.aerifal.cx> Organization: inria.fr X-Mailer: Claws Mail 4.0.0 (GTK+ 3.24.33; x86_64-pc-linux-gnu) X-Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAAXNSR0IArs4c6QAAACRQTFRFERslNjAsLTE9Ok9wUk9TaUs8iWhSrYZkj42Rz6aD3sGZ MIME-Version: 1.0 Content-Type: multipart/signed; boundary="Sig_/DaYKM03BDWhmoo.+TGwxp=N"; protocol="application/pgp-signature"; micalg=pgp-sha1 Subject: Re: [musl] patches for C23 --Sig_/DaYKM03BDWhmoo.+TGwxp=N Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Rich, on Tue, 2 May 2023 19:20:09 -0400 you (Rich Felker ) wrote: > On Tue, May 02, 2023 at 03:59:03PM +0200, J=E2=82=91=E2=82=99=E2=82=9B Gu= stedt wrote: > > on Tue, 2 May 2023 08:57:40 +0200 you (J=E2=82=91=E2=82=99=E2=82=9B Gus= tedt > > ) wrote: > > =20 > > > I'll also setup a git repository for those who would be willing to > > > test the whole. Just be aware that is really testing and review, > > > not yet ready for direct inclusion. So probably this will be > > > rebased several times. =20 > >=20 > > So this can now be found here > >=20 > > https://icube-forge.unistra.fr/icps/musl/ > >=20 > > with my additional branch called "c23". I also put on tags for what > > I think might be good groups to treat together. An overview should > > be accessible here > >=20 > > https://icube-forge.unistra.fr/icps/musl/-/network/c23?ref_t= ype=3Dheads > >=20 > > Let me know if you have any problems in accessing this. > >=20 > > I will then post the patches on the ML later, probably need some > > time for that to do it right. =20 >=20 > One quick find, in > https://icube-forge.unistra.fr/icps/musl/-/commit/3a2b83bf32d7c94f1bf0b2b= 2fd6ba8b6bf980d99 >=20 > - np =3D strtoul(r+9, &z, 10); > + np =3D strtoul(r+9, (char**)&z, 10); >=20 > is UB. I think it the situation is more subtle than that. If this were application C code the implementation of `strtoul` would provoque UB under certain circumstances. And this UB would be happening in line 16 of strtol.c, not at the calling side. Here at the calling side, we only have a pointer cast, which as such is well-defined because the two pointer types have same representation and alignment. Spinning that further, the code would then be UB as written before (with an unqualified `z`) because the call to `strtoul` then stores a `char const*` value into a `char*` object. By providing a declaration of `z` as `char const*`, the store in fact is now valid. So with that application side notion of UB, the proposed patch changes the code from UB to well-defined. But since we are the C library implementation nothing of that is UB, because the C standard enforces that the `char const*` value is stored in a `char*` object. So that cast as written above only calls out a special situation. > Accessing a const char * as char *. I would prefer in general > we just #undef any of the const-stuff-tg macros in files that use > them, or just have src/include/string.h always do that. (Not really > needed since musl source is written in c99 not c23, but it would be > nice to have it also compile with c11 and c23 compilers, so I think > the #undef is useful.) I am not sure that I understand how you think that should work, we have to provide these tg macros to our users, don't we? In any case, I prefer to mark such positions explicitly with something like `(strchr)(r, '\n')` as in line 222 of the code that you are refering to. All of this is marked as obsolescent in 7.26.5.1 If a macro definition of any of these generic functions is suppressed to access an actual function, the external declaration with the corresponding concrete type is visible.381) 381) This is an obsolescent feature. J=E2=82=91=E2=82=99=E2=82=9B --=20 :: ICube :::::::::::::::::::::::::::::: deputy director :: :: Universit=C3=A9 de Strasbourg :::::::::::::::::::::: ICPS :: :: INRIA Nancy Grand Est :::::::::::::::::::::::: Camus :: :: :::::::::::::::::::::::::::::::::::: =E2=98=8E +33 368854536 :: :: https://icube-icps.unistra.fr/index.php/Jens_Gustedt :: --Sig_/DaYKM03BDWhmoo.+TGwxp=N Content-Type: application/pgp-signature Content-Description: OpenPGP digital signature -----BEGIN PGP SIGNATURE----- iF0EARECAB0WIQSN9stI2OFN1pLljN0P0+hp2tU34gUCZFIJpQAKCRAP0+hp2tU3 4vsPAJ0XjevmNtGXwjQVFUCEN+MKWx5CUACggiOFn15ZUbKrJ+gzdxbyq4ucAJ0= =bBY9 -----END PGP SIGNATURE----- --Sig_/DaYKM03BDWhmoo.+TGwxp=N--