mailing list of musl libc
 help / color / mirror / code / Atom feed
* [musl] [PATCH] epoll: return EINVAL from epoll_create() if size is non-positive
@ 2022-08-24 14:26 Kristina Martsenko
  2022-08-24 18:47 ` Markus Wichmann
  0 siblings, 1 reply; 3+ messages in thread
From: Kristina Martsenko @ 2022-08-24 14:26 UTC (permalink / raw)
  To: musl

The man page for epoll_create() states that the 'size' argument must be
positive, otherwise EINVAL is returned. musl currently ignores the
argument and does not return EINVAL. Change it to match the man page.

Worth noting that this is needed for an LTP (Linux Test Project) test to
pass (epoll_create02).
---
 src/linux/epoll.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/linux/epoll.c b/src/linux/epoll.c
index 93baa814..e56e8f4c 100644
--- a/src/linux/epoll.c
+++ b/src/linux/epoll.c
@@ -5,6 +5,7 @@
 
 int epoll_create(int size)
 {
+	if (size<=0) return __syscall_ret(-EINVAL);
 	return epoll_create1(0);
 }
 

base-commit: 37e18b7bf307fa4a8c745feebfcba54a0ba74f30
-- 
2.30.2


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [musl] [PATCH] epoll: return EINVAL from epoll_create() if size is non-positive
  2022-08-24 14:26 [musl] [PATCH] epoll: return EINVAL from epoll_create() if size is non-positive Kristina Martsenko
@ 2022-08-24 18:47 ` Markus Wichmann
  2022-08-24 23:34   ` Rich Felker
  0 siblings, 1 reply; 3+ messages in thread
From: Markus Wichmann @ 2022-08-24 18:47 UTC (permalink / raw)
  To: musl

On Wed, Aug 24, 2022 at 03:26:52PM +0100, Kristina Martsenko wrote:
> The man page for epoll_create() states that the 'size' argument must be
> positive, otherwise EINVAL is returned. musl currently ignores the
> argument and does not return EINVAL. Change it to match the man page.
>
> Worth noting that this is needed for an LTP (Linux Test Project) test to
> pass (epoll_create02).

I am wondering if this change is sensible. On musl, the size argument is
never handed to the kernel. Failing for nonpositive arguments may be in
the spec, but it might make users assume the argument is actually used.
But it isn't. epoll_create() always calls epoll_create1(), and that
function falls back to the epoll_create syscall with a constant argument
of 1 if epoll_create1 is not available.

Ciao,
Markus

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [musl] [PATCH] epoll: return EINVAL from epoll_create() if size is non-positive
  2022-08-24 18:47 ` Markus Wichmann
@ 2022-08-24 23:34   ` Rich Felker
  0 siblings, 0 replies; 3+ messages in thread
From: Rich Felker @ 2022-08-24 23:34 UTC (permalink / raw)
  To: Markus Wichmann; +Cc: musl

On Wed, Aug 24, 2022 at 08:47:04PM +0200, Markus Wichmann wrote:
> On Wed, Aug 24, 2022 at 03:26:52PM +0100, Kristina Martsenko wrote:
> > The man page for epoll_create() states that the 'size' argument must be
> > positive, otherwise EINVAL is returned. musl currently ignores the
> > argument and does not return EINVAL. Change it to match the man page.
> >
> > Worth noting that this is needed for an LTP (Linux Test Project) test to
> > pass (epoll_create02).
> 
> I am wondering if this change is sensible. On musl, the size argument is
> never handed to the kernel. Failing for nonpositive arguments may be in
> the spec, but it might make users assume the argument is actually used.
> But it isn't. epoll_create() always calls epoll_create1(), and that
> function falls back to the epoll_create syscall with a constant argument
> of 1 if epoll_create1 is not available.

Being that it's documented to fail with EINVAL for nonpositive
arguments, I think we should do that, even if the argument is
otherwise ignored.

Rich

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-08-24 23:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-24 14:26 [musl] [PATCH] epoll: return EINVAL from epoll_create() if size is non-positive Kristina Martsenko
2022-08-24 18:47 ` Markus Wichmann
2022-08-24 23:34   ` Rich Felker

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

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 NNTP newsgroup(s).