public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Jonny Grant <jg@jguk.org>
To: Xi Ruoyao <xry111@xry111.site>, Andreas Schwab <schwab@suse.de>
Cc: Paul Eggert <eggert@cs.ucla.edu>,
	Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>,
	GNU C Library <libc-alpha@sourceware.org>
Subject: Re: glibc misc/sys/cdefs.h nonull - typo in comment
Date: Sun, 3 Dec 2023 22:09:22 +0000	[thread overview]
Message-ID: <39e80d0d-bf0b-486f-a1c0-895a1fc4c28f@jguk.org> (raw)
In-Reply-To: <8eccb33c97d225c797cebf8d29f5370d7c5a8ae1.camel@xry111.site>



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


  reply	other threads:[~2023-12-03 22:09 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-11  9:09 Jonny Grant
2023-04-11 13:39 ` Adhemerval Zanella Netto
2023-04-12 15:56   ` Jonny Grant
2023-04-12 16:26     ` Xi Ruoyao
2023-04-12 16:31       ` Xi Ruoyao
2023-10-28 23:50       ` Jonny Grant
2023-10-29  5:24         ` Paul Eggert
2023-10-29 22:43           ` Jonny Grant
2023-10-30  9:04             ` Andreas Schwab
2023-10-30 10:10               ` Xi Ruoyao
2023-12-03 22:09                 ` Jonny Grant [this message]
2023-11-01  7:38           ` Florian Weimer
2023-11-01 19:30             ` Paul Eggert
2023-11-01 19:52               ` Jonny Grant
2023-11-01 20:05                 ` Florian Weimer
2023-11-01 20:16                   ` Jonny Grant
2023-11-01 20:06               ` Florian Weimer
2023-04-12 17:28     ` Adhemerval Zanella Netto

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=39e80d0d-bf0b-486f-a1c0-895a1fc4c28f@jguk.org \
    --to=jg@jguk.org \
    --cc=adhemerval.zanella@linaro.org \
    --cc=eggert@cs.ucla.edu \
    --cc=libc-alpha@sourceware.org \
    --cc=schwab@suse.de \
    --cc=xry111@xry111.site \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).