From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by sourceware.org (Postfix) with ESMTPS id C34BA3858C78 for ; Sun, 3 Dec 2023 22:09:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C34BA3858C78 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=jguk.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=jguk.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org C34BA3858C78 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::32a ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701641366; cv=none; b=k6h4IA/OQVAztzUc25ays089CxhCSm/SAwyfCNGkHot6zxEeG53x7lJ6p0qpOx2HIYKXwEB0SC7v5CRNXV4kXY35qTt24xb94OiqZZ2p1Fbxl2R5xA1Heo1bOg5USTnHq4eSRADNu5Rqi+LzCz2LWIFKaQSqoEOA+j6mFKpytn8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701641366; c=relaxed/simple; bh=36ObJIy9R8OgYYsHY21Qv7VCG3en3ALcSxfiNuqk+hI=; h=DKIM-Signature:Message-ID:Date:MIME-Version:From:Subject:To; b=Qgilf0TvmRk29CxJif+riKAwo/ET+RNJ1f45ATTZfHh65XolOo44bL76z+MUYY1LOmhyN26+i+gKCpJoqakUIIXApOfeNWHvFIgIiW7Iecvp4VwUlDGSINHz55XkALv9QyRwSxI1sIfuMGbOE2YXhq3AmVAyN2KQTH7wiQ7cDfo= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-40b2ad4953cso30481955e9.0 for ; Sun, 03 Dec 2023 14:09:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jguk.org; s=google; t=1701641363; x=1702246163; darn=sourceware.org; h=content-transfer-encoding:in-reply-to:content-language:references :cc:to:subject:from:user-agent:mime-version:date:message-id:from:to :cc:subject:date:message-id:reply-to; bh=pTbPty497fnuMY5O/wnBlv1TAsJl8oOq0b1/gRnEktA=; b=O5aIBMCBf7q97dkcYNqGI8tH1Dg+kYzpsF53glmTLBMnty/tYKYJ3P+cz7rJ+8On5w Jc9Td+o1HuH0k66TC50Y1nEWs9G5tcfuCmERsQRFRWubq+U2Ep5X/HUsAwfhRuMWg3YZ Hm7oe9C3hrn4Dg9GohEJ8nLHPCytfBBIAKy184iE9UqKwaYUSDxhLoLY/gc5biVFE6pt nxtYXncfo1lajvxrLZZywKjD/fYVXQ8D+gFVJOaM7cG2M2cyo5ttogTuwV8w4n61VUMC ZfCKWrBSawNlk6uoJlhd9td6eSuzVc7Te99XuColGK3EukJC5rD3SIJ5t+R8KTVSVjPF F0kw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701641363; x=1702246163; h=content-transfer-encoding:in-reply-to:content-language:references :cc:to:subject:from:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=pTbPty497fnuMY5O/wnBlv1TAsJl8oOq0b1/gRnEktA=; b=RY8z9r4QGs72ImII6HXWr8Eiehq5s84UaSmCV4hCEBaeAzW2G1L84Jc8FB/eO2QEqB Ql12hcJfjkRcvwdEbnO+n5sGNVp8a6gZw7LSTt0EnapI7Mera9SadvfBdXnXENZY7+6U UOIaO1rnHKHnGH+LmIhOcInK5iJlxXvCaRfS/fKnmWYOrFr8fM7f3bbNTPtz4t2TizAX wZ5mdMixyg4YBAYDvWJXtJlOuD8MRKBil/HN0q4RIlmhvQG8YhpJPvc8prInD65WhWnF zgapCqS4SAFEYyCiBBy6f8BBsa7xzTAHuvG4OtCjPjmqKjM/PjuXzerj2v+yIuGDJtI+ jr3Q== X-Gm-Message-State: AOJu0YwMgpsnYNA28L2uOGp5E1vZQQmSgooEwh/grGdkg7OSZ+vFmpsx zfSwaog7VvN6HA0jUqOa4ttebG/xqtC0N6IeWWE= X-Google-Smtp-Source: AGHT+IHzarHV2FbVjcRbtE7eHhgaDRxwtGFOdIkgPHY76kegE4Y9U7b3juLTb0B1V81ZokFVi3dWPQ== X-Received: by 2002:a05:600c:1f96:b0:40b:5e1f:c386 with SMTP id je22-20020a05600c1f9600b0040b5e1fc386mr2534833wmb.28.1701641363474; Sun, 03 Dec 2023 14:09:23 -0800 (PST) Received: from [192.168.0.12] (cpc87345-slou4-2-0-cust172.17-4.cable.virginm.net. [81.101.252.173]) by smtp.gmail.com with ESMTPSA id f18-20020a05600c155200b004094d4292aesm12847991wmg.18.2023.12.03.14.09.22 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 03 Dec 2023 14:09:22 -0800 (PST) Message-ID: <39e80d0d-bf0b-486f-a1c0-895a1fc4c28f@jguk.org> Date: Sun, 3 Dec 2023 22:09:22 +0000 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird From: Jonny Grant Subject: Re: glibc misc/sys/cdefs.h nonull - typo in comment To: Xi Ruoyao , Andreas Schwab Cc: Paul Eggert , Adhemerval Zanella Netto , GNU C Library References: <25d0b6fa-7b45-3f8e-946a-ad3256e211a4@jguk.org> <0d99df74-fb83-1647-ca19-17d2229f0ae0@linaro.org> <514c11a4-405b-f7f3-9a67-0b6c10ad7740@jguk.org> <21bc9125ab8ced26aa85f3f787f084c4af460a18.camel@xry111.site> <84e4081c-35ef-4f2d-89d0-0fea04732737@cs.ucla.edu> <984eaee1-251f-4917-91f3-d19b5f8a95bc@jguk.org> <8eccb33c97d225c797cebf8d29f5370d7c5a8ae1.camel@xry111.site> Content-Language: en-GB In-Reply-To: <8eccb33c97d225c797cebf8d29f5370d7c5a8ae1.camel@xry111.site> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,KAM_SHORT,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,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: On 30/10/2023 10:10, Xi Ruoyao wrote: > On Mon, 2023-10-30 at 10:04 +0100, Andreas Schwab wrote: >> On Okt 29 2023, Jonny Grant wrote: >> >>> glibc does go beyond POSIX and set errno to EFAULT if a null pointer >>> constant is passed. >>> https://man7.org/linux/man-pages/man2/olduname.2.html >>> >>> Although I looked at glibc/posix/uname.c and it has EINVAL there, >>> couldn't spot where the EFAULT comes from, probably there is another >>> file. >> >> glibc never generates EFAULT on its own, it always comes from the >> kernel. > > And POSIX is clear that people should not rely on EFAULT, at all: > > [EFAULT] > Bad address. The system detected an invalid address in attempting to use > an argument of a call. The reliable detection of this error cannot be > guaranteed, and when not detected may result in the generation of a > signal, indicating an address violation, which is sent to the process. > Fair enough, as you and Andreas have said, the EFAULT is returned due to the kernel and POSIX doesn't state many functions that actually specify supporting a NULL pointer argument [a few eg. free(), realloc(), time()]. I usually just wrap calls to add extra checks when I'm not in control of how safe the rest of the user space software is, it is more tricky if 3rd party libraries are using symbols from libc directly. Kind regards, Jonny