public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Martin Sebor <msebor@gmail.com>
To: Florian Weimer <fweimer@redhat.com>,
	Martin Sebor via Libc-alpha <libc-alpha@sourceware.org>
Subject: Re: [PATCH] more out of bounds checking improvements
Date: Tue, 8 Dec 2020 17:18:33 -0700	[thread overview]
Message-ID: <a334e63a-208f-2e9a-02a1-1fbefadfc07e@gmail.com> (raw)
In-Reply-To: <87mu09ata4.fsf@oldenburg2.str.redhat.com>

On 10/26/20 9:41 AM, Florian Weimer wrote:
> * Martin Sebor via Libc-alpha:
> 
>> Besides attribute access, the change adds attribute nonnull to
>> the readv and writev functions in misc/sys/uio.h.  The functions
>> don't necessarily access the array elements when their count is
>> zero but neither POSIX nor the Linux manual document this so it
>> seems appropriate to warn.
> 
> This change is questionable because it breaks interoperability with
> abstract data types such as std::vector, where the base pointer can be
> null when the array is empty.  The kernel does not return EFAULT in this
> case, as expected.

Let me separate this out from the main patch if it isn't
straightforward.  Although POSIX doesn't require the functions to
fail, it does suggest, albeit obliquely, they may fail when the iov
pointer is null:

   The iovcnt argument is valid if greater than 0 and less than or
   equal to {IOV_MAX}, as defined in <limits.h>.

   The writev() function may fail and set errno to:

   [EINVAL]
     The iovcnt argument was less than or equal to 0, or greater than
     {IOV_MAX}.

Passing the functions a null iov pointer is only realistic when
iovcnt is zero.  The former is nonconforming and undefined under
any conditions (null isn't a valid argument to any library
function unless specified otherwise), and the latter may cause
the function to fail.  A warning for it seems to me both
appropriate and helpful, certainly in the absence of the Glibc
or Linux man pages documenting the behavior under these
conditions.

Martin

> I think we need a special case for this.
> 
> Thanks,
> Florian
> 


  reply	other threads:[~2020-12-09  0:18 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-26 15:01 Martin Sebor
2020-10-26 15:41 ` Florian Weimer
2020-12-09  0:18   ` Martin Sebor [this message]
2020-10-26 16:08 ` Joseph Myers
2020-12-09 21:46   ` Martin Sebor
2020-12-18 16:56     ` Ping: " Martin Sebor
2021-01-04 15:54       ` Ping 2: " Martin Sebor
2021-01-10 20:44         ` Ping 3: " Martin Sebor
2021-04-22 21:36           ` Ping 4: " Martin Sebor
2021-04-23 10:31     ` Florian Weimer
2021-04-23 15:06       ` Martin Sebor
2021-04-23 16:01         ` Florian Weimer
2021-05-04 19:58           ` Martin Sebor
2021-05-06 17:03             ` Martin Sebor
2021-05-06 18:15               ` Joseph Myers
2021-05-06 19:40                 ` Martin Sebor
2021-05-07  9:20               ` Andreas Schwab
2021-05-07  9:24                 ` Florian Weimer
2021-05-07 11:48                   ` Andreas Schwab
2021-05-07 19:30                 ` Tulio Magno Quites Machado Filho
2021-05-10 17:23                   ` Joseph Myers
2021-05-10  8:45               ` Florian Weimer
2021-05-10 17:14                 ` Martin Sebor
2021-05-10 17:49                   ` Florian Weimer
2021-05-10 18:37                     ` Martin Sebor
2021-05-10 19:22                       ` Andreas Schwab
2021-05-10 19:50                         ` Florian Weimer
2021-05-10 20:31                           ` Martin Sebor
2021-05-11 10:53                             ` Florian Weimer

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=a334e63a-208f-2e9a-02a1-1fbefadfc07e@gmail.com \
    --to=msebor@gmail.com \
    --cc=fweimer@redhat.com \
    --cc=libc-alpha@sourceware.org \
    /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).