From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id BE0863858D35 for ; Mon, 6 Feb 2023 18:45:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BE0863858D35 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1675709138; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=wLTq6kW7n8piPxBWivlhBz748fbHyw8XZ0rKluo0WpQ=; b=Slls2srBAHER2mUUwgSMlkgaZMD66VCZZHKlRND3ufp/AlB6wEsSGeReKOsndWhlzJA5RZ KzAiuFmb2RK3ZoCcF6BIVIoeHKRW8Z/5O06nSF8Fn4XPozeoLdh20QmM2dF/gEFaxuJG74 H4yJPGJrzwMm5B2Yu8lJFz01e87/Z6M= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-385-yC9CZOPeM7ikHZThRRUiiA-1; Mon, 06 Feb 2023 13:45:35 -0500 X-MC-Unique: yC9CZOPeM7ikHZThRRUiiA-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id ED455101B42B; Mon, 6 Feb 2023 18:45:33 +0000 (UTC) Received: from redhat.com (unknown [10.2.16.104]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0FD2A1121315; Mon, 6 Feb 2023 18:45:31 +0000 (UTC) Date: Mon, 6 Feb 2023 12:45:30 -0600 From: Eric Blake To: Alejandro Colomar Cc: linux-man@vger.kernel.org, Alejandro Colomar , GCC , glibc , Bastien =?utf-8?Q?Roucari=C3=A8s?= , Stefan Puiu , Igor Sysoev , Rich Felker , Andrew Clayton , Richard Biener , Zack Weinberg , Florian Weimer , Joseph Myers , Jakub Jelinek Subject: Re: [PATCH] sockaddr.3type: BUGS: Document that libc should be fixed using a union Message-ID: <20230206184530.zn5kq7x6xmcfxhqm@redhat.com> References: <20230205152835.17413-1-alx@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230205152835.17413-1-alx@kernel.org> User-Agent: NeoMutt/20220429 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-Spam-Status: No, score=-3.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,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: 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 Unedfined 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 union. > +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