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.133.124]) by sourceware.org (Postfix) with ESMTPS id 08DAB38432F6 for ; Sun, 4 Dec 2022 18:46:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 08DAB38432F6 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=1670179581; 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=AJ7oTYHd5ufy9+RVLzStIB7J+lZbdGWnAr+U38sTOTE=; b=WAEj5GGyCXfAj9f5q3cgcYB7j+hKSKP6QfeEGHw5mq/BJAjbOgWfEpnTzs+2mBCJqXjk0O nbEwkWY1/PjBYiSesfanONLgcrrICU+BFYl6FCkFhT3hIWyUjHYTCx3U9khrIwAFNpYv6v u5YWnIK7mVMWNCoJPKFfcheq3VKNNmE= 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-498-aumXrjAvOkOgk3DYvcEDug-1; Sun, 04 Dec 2022 13:46:20 -0500 X-MC-Unique: aumXrjAvOkOgk3DYvcEDug-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0D68985A588; Sun, 4 Dec 2022 18:46:20 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.2.16.33]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2E1FCC15BB2; Sun, 4 Dec 2022 18:46:18 +0000 (UTC) From: Florian Weimer To: Alejandro Colomar via Libc-alpha Cc: Xi Ruoyao , Andreas Schwab , Alejandro Colomar Subject: Re: bind(2): Missing [[gnu::nonnull]] References: <8292ef824696e0fbac4f4ed036aad43c0458b8a2.camel@xry111.site> <87wn78cnpe.fsf@igel.home> <4e085ada-10eb-9de9-7681-1c96ec74da30@gmail.com> Date: Sun, 04 Dec 2022 19:46:15 +0100 In-Reply-To: <4e085ada-10eb-9de9-7681-1c96ec74da30@gmail.com> (Alejandro Colomar via Libc-alpha's message of "Sun, 4 Dec 2022 12:14:56 +0100") Message-ID: <87y1rnf1mw.fsf@oldenburg.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-Spam-Status: No, score=-4.5 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: * Alejandro Colomar via Libc-alpha: > Hi Xi, > > On 12/4/22 06:59, Xi Ruoyao wrote: >> On Sat, 2022-12-03 at 20:05 +0100, Andreas Schwab wrote: >>>> Currently the man page says: >>>> >>>> EFAULT: addr points outside the user's accessible address space. >>>> >>>> And bind(2) indeed sets errno to EFAULT and return -1 when NULL is >>>> passed as addr. >>> >>> You can never depend on EFAULT for invalid addresses. >> Hmm, is this documented somewhere? > > I don't know, but let me have an educated guess: > > Holding a pointer to invalid memory is Undefined Behavior by the > standard, except if that pointer is NULL, or is still indeterminate > because the pointer has not yet been initialized with a valid address. > Using an uninitialized pointer is UB as using any uninitialized > variable. Using a NULL pointer is only okay for comparisons, or as a > sentinel value, but never for accessing memory. So chances are high > that the program will already have invoked UB at the time bind(2) is > called with an invalid address. Currently, Linux does not report for vDSO-accelerated system calls, but generates SIGSEGV. We received bug reports when we added vDSO support for time/gettimeofday/clock_gettime because some tests were relying on the EFAULT behavior. Thanks, Florian