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
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
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