public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>
To: Alejandro Colomar <alx.manpages@gmail.com>,
	GNU C Library <libc-alpha@sourceware.org>
Subject: Re: nonnull on epoll_wait(2) syscall wrappers?
Date: Mon, 22 May 2023 17:51:04 -0300	[thread overview]
Message-ID: <6c399f6b-6e89-17c4-2a56-1219a1b86448@linaro.org> (raw)
In-Reply-To: <cbc3cd53-72a1-df82-6ed5-b1088660fce1@gmail.com>



On 19/05/23 19:50, Alejandro Colomar wrote:
> Hi Adhemerval,
> 
> I was checking the epoll_pwait2(2) man page to see if it needs some
> updating for the wrapper you added recently.  It seems all's good.
> 
> <https://sourceware.org/bugzilla/show_bug.cgi?id=27359>
> 
> However, I noticed that there's a difference between the current
> manual page and the glibc wrappers for the 3 related functions:
> 
> 
> $ grepc -x /sys/epoll.h$ epoll_wait /usr/include/
> /usr/include/x86_64-linux-gnu/sys/epoll.h:124:
> extern int epoll_wait (int __epfd, struct epoll_event *__events,
> 		       int __maxevents, int __timeout)
> 	__attr_access ((__write_only__, 2, 3));
> $ grepc -x /sys/epoll.h$ epoll_pwait /usr/include/
> /usr/include/x86_64-linux-gnu/sys/epoll.h:134:
> extern int epoll_pwait (int __epfd, struct epoll_event *__events,
> 			int __maxevents, int __timeout,
> 			const __sigset_t *__ss)
> 	__attr_access ((__write_only__, 2, 3));
> $ grepc -x /sys/epoll.h$ epoll_pwait2 /usr/include/
> /usr/include/x86_64-linux-gnu/sys/epoll.h:144:
> extern int epoll_pwait2 (int __epfd, struct epoll_event *__events,
> 			 int __maxevents, const struct timespec *__timeout,
> 			 const __sigset_t *__ss)
> 	__attr_access ((__write_only__, 2, 3));
> 
> 
> /usr/include/x86_64-linux-gnu/sys/epoll.h:157:
> #  define epoll_pwait2 __epoll_pwait2_time64
> 
> 
> The man page synopsis is:
> 
> 
> SYNOPSIS
>        #include <sys/epoll.h>
> 
>        int epoll_wait(int epfd, struct epoll_event *events,
>                       int maxevents, int timeout);
>        int epoll_pwait(int epfd, struct epoll_event *events,
>                       int maxevents, int timeout,
>                       const sigset_t *_Nullable sigmask);
>        int epoll_pwait2(int epfd, struct epoll_event *events,
>                       int maxevents, const struct timespec *_Nullable timeout,
>                       const sigset_t *_Nullable sigmask);
> 
> 
> I didn't use _Nullable in the events parameter, because I don't think
> it can be NULL.  Does it make any sense in any case having a NULL
> there?  Should we use nonnull in glibc?

It does make sense to mark the epoll_events argument as nonnull, since
either the kernel will return EINVAL for maxevents equal to 0 or
EFAULT for invalid events:

fs/eventpoll.c

2284  * Implement the event wait interface for the eventpoll file. It is the kernel
2285  * part of the user space epoll_wait(2).
2286  */
2287 static int do_epoll_wait(int epfd, struct epoll_event __user *events,
2288                          int maxevents, struct timespec64 *to)
2289 {
2290         int error;
2291         struct fd f;
2292         struct eventpoll *ep;
2293
2294         /* The maximum number of event must be greater than zero */
2295         if (maxevents <= 0 || maxevents > EP_MAX_EVENTS)
2296                 return -EINVAL;
2297
2298         /* Verify that the area passed by the user is writeable */
2299         if (!access_ok(events, maxevents * sizeof(struct epoll_event)))
2300                 return -EFAULT;

  reply	other threads:[~2023-05-22 20:51 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-19 22:50 Alejandro Colomar
2023-05-22 20:51 ` Adhemerval Zanella Netto [this message]
2023-05-22 22:01   ` [PATCH] Use __nonnull for the epoll_wait(2) family of syscalls Alejandro Colomar
2023-05-23 12:27     ` Adhemerval Zanella Netto
2023-05-29 17:39       ` Adhemerval Zanella Netto
2023-05-29 23:17         ` Alejandro Colomar
2023-05-30 11:41           ` Adhemerval Zanella Netto
2023-05-31 20:44   ` [PATCH v2 1/2] Fix invalid use of NULL in epoll_pwait2(2) test Alejandro Colomar
2023-06-01 17:59     ` Adhemerval Zanella Netto
2023-05-31 20:44   ` [PATCH v2 2/2] Use __nonnull for the epoll_wait(2) family of syscalls Alejandro Colomar
2023-06-01 18:00     ` Adhemerval Zanella Netto
2023-06-01 23:46       ` Alejandro Colomar

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=6c399f6b-6e89-17c4-2a56-1219a1b86448@linaro.org \
    --to=adhemerval.zanella@linaro.org \
    --cc=alx.manpages@gmail.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).