From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by sourceware.org (Postfix) with ESMTPS id 188973858C74 for ; Mon, 20 Mar 2023 10:49:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 188973858C74 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wm1-x335.google.com with SMTP id w11so6102628wmo.2 for ; Mon, 20 Mar 2023 03:49:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679309365; h=in-reply-to:from:content-language:references:cc:to:subject :user-agent:mime-version:date:message-id:from:to:cc:subject:date :message-id:reply-to; bh=mb4CGkqoeuBc5ZiGqAFmsynytYO5j7QFyVnyShniP6k=; b=THRSHR56xGuyl5WsKZ+N5rDGn/m6cFIRPSPJBta0MQ2o9SLOSQN/k3Sb8spQhQZul5 EIJNf8Aj7SxnayMqKcmjvj2NfdGJMwy34kl8zuX7HbzYg1TdvtjDntOdLPmFcK3YpFrt yfgUUP2PsLZfnrd7xLeyIS1FvTG+ttPOpybHV9ycrJU5qHQMClfeD97pdK0bTb07ErGw WPqOMFbtZnQisIcOk1lnZsOyyuh0b2ZcXqSe9Xbgu+LP9rdyDmIaezhFH4et8g2PuejW NXzIjIfhOTvi2H4WfwRrUVZZjBrRWmu++271aqhJLALz8IGdRoel69HTYBdsTCqk3Nyx jOAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679309365; h=in-reply-to:from:content-language:references:cc:to:subject :user-agent:mime-version:date:message-id:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=mb4CGkqoeuBc5ZiGqAFmsynytYO5j7QFyVnyShniP6k=; b=1BbyLKSzkgwio+eaXvI1Zp0MnyTJIjJkr6d7/doEKXIhJ0Fo/qCoesFr0jPyd9gA23 9JCFAjgT2TcHjutWMoZxV9WqQqGiU5mbfA+Rv/uvgejFVbFly2Z88M98T5QGBy0soVVm pzJQq78uQtxEi/UFWNbFk4fw5R+rPG8j/Zx8mvXyV+HSdVfP7VQ6YSNv9A5/VuBvupzV 9WdaYueGpLblAJwxkuo9u6EygOwET5hib5O0KAhTSdhsBfgE3LatZoNvvcbdgRKpRry2 a6urEtvBmyss0tXa2GTw60eRvNE+qHhtESH4jWQb5d0ai8HLcQ8Rdt4PdHT+9aXDsx+v 0twg== X-Gm-Message-State: AO0yUKVoNCUkYmSKIZVeTZAoKw4MBXL0fWgjnTih8CusTGxv5hWLTydp eiBBR7M0fraTZyiY1deNVpE= X-Google-Smtp-Source: AK7set/2Jf1XWuU7HAFOhr3irXWg3eiR1OQzdVt4WXtvzxZ2IKXUgGf/qRd41IUmwZYV0XClHB2z5A== X-Received: by 2002:a05:600c:5408:b0:3ea:ecc2:daab with SMTP id he8-20020a05600c540800b003eaecc2daabmr35644416wmb.3.1679309364640; Mon, 20 Mar 2023 03:49:24 -0700 (PDT) Received: from [192.168.0.160] ([170.253.51.134]) by smtp.gmail.com with ESMTPSA id x20-20020a1c7c14000000b003edc11c2ecbsm6054186wmc.4.2023.03.20.03.49.23 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 20 Mar 2023 03:49:24 -0700 (PDT) Message-ID: <15fcdfb3-4029-343b-2867-d92445426ed3@gmail.com> Date: Mon, 20 Mar 2023 11:49:14 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.8.0 Subject: Re: [PATCH] sockaddr.3type: BUGS: Document that libc should be fixed using a union To: roucaries bastien , Eric Blake Cc: linux-man@vger.kernel.org, Alejandro Colomar , GCC , glibc , =?UTF-8?Q?Bastien_Roucari=c3=a8s?= , Stefan Puiu , Igor Sysoev , Rich Felker , Andrew Clayton , Richard Biener , Zack Weinberg , Florian Weimer , Joseph Myers , Jakub Jelinek References: <20230205152835.17413-1-alx@kernel.org> <20230206184530.zn5kq7x6xmcfxhqm@redhat.com> Content-Language: en-US From: Alejandro Colomar In-Reply-To: Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="------------mcO6DJocvMkKprtIDiS2DuHl" X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP 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: This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --------------mcO6DJocvMkKprtIDiS2DuHl Content-Type: multipart/mixed; boundary="------------JFG9csQQbZJ6Ui07mdFWym87"; protected-headers="v1" From: Alejandro Colomar To: roucaries bastien , Eric Blake Cc: linux-man@vger.kernel.org, Alejandro Colomar , GCC , glibc , =?UTF-8?Q?Bastien_Roucari=c3=a8s?= , Stefan Puiu , Igor Sysoev , Rich Felker , Andrew Clayton , Richard Biener , Zack Weinberg , Florian Weimer , Joseph Myers , Jakub Jelinek Message-ID: <15fcdfb3-4029-343b-2867-d92445426ed3@gmail.com> Subject: Re: [PATCH] sockaddr.3type: BUGS: Document that libc should be fixed using a union References: <20230205152835.17413-1-alx@kernel.org> <20230206184530.zn5kq7x6xmcfxhqm@redhat.com> In-Reply-To: --------------JFG9csQQbZJ6Ui07mdFWym87 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Hi Bastien and Eric! On 3/18/23 08:54, roucaries bastien wrote: > Hi, >=20 > I have opened a defect at austin group > https://www.austingroupbugs.net/view.php?id=3D1641 Sorry for not having prepared yet my report as I promised to Eric. I've been busy with other stuff, but still had in mind doing it :). But yes, basically that report is what I would have written, so you have my +1. ;) Cheers, Alex >=20 > Bastien >=20 > Le lun. 6 f=C3=A9vr. 2023 =C3=A0 18:45, Eric Blake = a =C3=A9crit : >> >> On Sun, Feb 05, 2023 at 04:28:36PM +0100, Alejandro Colomar wrote: >> >> Regardless of the merits of the patch, let's not introduce typos: >> >>> +++ b/man3type/sockaddr.3type >>> @@ -120,6 +120,26 @@ .SH NOTES >>> .I >>> and >>> .IR . >>> +.SH BUGS >>> +.I sockaddr_storage >>> +was designed back when strict aliasing wasn't a problem. >>> +Back then, >>> +one would define a variable of that type, >>> +and then access it as any of the other >>> +.IR sockaddr_ * >>> +types, >>> +depending on the value of the first member. >>> +This is Undefined Behavior. >>> +However, there is no way to use these APIs without invoking Unedfine= d Behavior, >> >> Undefined >> >>> +either in the user program or in libc, >>> +so it is still recommended to use this method. >>> +The only correct way to use different types in an API is through a u= nion. >>> +However, >>> +that union must be implemented in the library, >>> +since the type must be shared between the library and user code, >>> +so libc should be fixed by implementing >>> +.I sockaddr_storage >>> +as a union. >>> .SH SEE ALSO >>> .BR accept (2), >>> .BR bind (2), >> >> Also, while I could raise the issue with the Austin Group on your >> behalf to get the POSIX wording improved, I think it would work better= >> if you initiate a bug report rather than having me do it: >> >> https://www.austingroupbugs.net/main_page.php >> >> -- >> Eric Blake, Principal Software Engineer >> Red Hat, Inc. +1-919-301-3266 >> Virtualization: qemu.org | libvirt.org >> --=20 GPG key fingerprint: A9348594CE31283A826FBDD8D57633D441E25BB5 --------------JFG9csQQbZJ6Ui07mdFWym87-- --------------mcO6DJocvMkKprtIDiS2DuHl Content-Type: application/pgp-signature; name="OpenPGP_signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="OpenPGP_signature" -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEE6jqH8KTroDDkXfJAnowa+77/2zIFAmQYOioACgkQnowa+77/ 2zL71A//egN8dcXcKW6MVuqeh31dh7VJi43cKW/5nh3XtE+m3GBlbCL/gJiKk52q HNt/J7S1PnTEMoIQ7CwZR78rXuyW5vkJXAqBjYEBMunv+2LDcGei+dxDOVavg+FA Qd7RdHSzI/vvOdAtCbhrnIdBKsLfBIWEDMbO78Bmi74IXx8n6xFGAS1DzN5agMZi uq4bMBZaraayYLL7U6RBBSv9HaEjrLGuJFc8GgiE6YsGha/kUP0AqN+63DInqGls o06ocvlEzPsP7dTqUE/Eom7tVKP5xUk22aTLbVyf5+UC8bTEktcR3PQQhlIUjDVS t4Pse8trnWFIh+Q1rnTelXRMguMbySqmvW6WdN8TmVDfb/BG5wwWpJv2EXbmD28j VknnZMvaR1zxLexMVIbLMUrU/vMhpXMTafvOzbrXD3zK8+VUoVHHxjw60WJHWL7S pGbyXm5mVOa19ErbVt1pcODeJ93siExUTAjXY66ZVP334ijHCbTxk/csPF6kY4RI qfxCZN7TDPmmIA0bFJeYQ+lrLnvs/SkmE6E0qXFyJ7MDyG8dEoxsAtt0T3gkW8My Xhu1/HWKh2CwHOZh+9lHbtRN8R1SIziKaFg0uanIwyKc9B162x3PQyrIlAb45Gh1 MXfPyMkr/iAL2kRv56P2uUTPfpfb2MTLOpMKlWYcsAlTLbEvhcs= =bRBy -----END PGP SIGNATURE----- --------------mcO6DJocvMkKprtIDiS2DuHl--