From: Hengyu Liang <hengyul@cs.unc.edu>
To: joe@dama.to
Cc: brauner@kernel.org, davem@davemloft.net, edumazet@google.com,
hengyul@cs.unc.edu, horms@kernel.org, jack@suse.cz,
jirislaby@kernel.org, kuba@kernel.org,
linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-kselftest@vger.kernel.org, netdev@vger.kernel.org,
pabeni@redhat.com, sdf@fomichev.me, shuah@kernel.org,
viro@zeniv.linux.org.uk
Subject: Re: [PATCH] eventpoll: return -ENOIOCTLCMD for unknown ioctl commands
Date: Wed, 30 Sep 2026 05:50:58 -0400 [thread overview]
Message-ID: <20260930095058.1062123-1-hengyul@cs.unc.edu> (raw)
In-Reply-To: <arWdMDek0iv0obDy@devvm20253.cco0.facebook.com>
On Fri, Sep 25, 2026 at 5:59 AM Joe Damato <joe@dama.to> wrote:
>
> On Thu, Sep 24, 2026 at 02:57:47PM -0400, hengyul@cs.unc.edu wrote:
[...]
> > default:
> > - ret = -EINVAL;
> > + ret = -ENOIOCTLCMD;
> > break;
> > }
>
> I think based on the documentation this is probably right, but I am now
> wondering why both ep_eventpoll_ioctl and ep_eventpoll_bp_ioctl need to
> exist.
>
> Maybe when I first implemented this I thought it made sense to factor
> out the busy poll ioctls into their own function, but in retrospect maybe
> it's cleaner to just collapse the ioctl function into a single one
> instead of having two layers?
>
> In other words, maybe:
> - delete ep_eventpoll_ioctl
> - add the is_file_epoll check to ep_eventpoll_bp_ioctl
> - rename ep_eventpoll_bp_ioctl to ep_eventpoll_ioctl
> - fix the test (as you did in this version of the patch)
>
> Would result in a cleaner fewer helpers / cleaner code ?
Thanks for taking a look. Agreed, a single handler would be cleaner.
Two things I noticed while looking into it:
1. With CONFIG_NET_RX_BUSY_POLL=n, ep_eventpoll_bp_ioctl() is the stub
that returns -EOPNOTSUPP for every command. If it became the
.unlocked_ioctl handler as is, every ioctl on an epoll fd would fail
with EOPNOTSUPP on those kernels, which is the same problem in a
different config. So the stub would need to keep a small switch:
static long ep_eventpoll_ioctl(struct file *file, unsigned int cmd,
unsigned long arg)
{
switch (cmd) {
case EPIOCSPARAMS:
case EPIOCGPARAMS:
return -EOPNOTSUPP;
default:
return -ENOIOCTLCMD;
}
}
2. The is_file_epoll() check cannot fail there: the handler is only
reachable through eventpoll_fops, so file->f_op is always
&eventpoll_fops. Unless you would like to keep it as a defensive
check, I'd drop it rather than move it.
Since this changes the errno userspace sees and 18e2bf0edf4d is in
6.12 and 6.18, I'd like to keep the fix itself minimal so it backports
cleanly. How about a two-patch v2:
1/2 this patch unchanged (Fixes: 18e2bf0edf4d)
2/2 fold ep_eventpoll_bp_ioctl() into ep_eventpoll_ioctl() as you
suggested, no functional change
If you'd prefer a single patch, I'm happy to do that instead.
next prev parent reply other threads:[~2026-09-30 9:51 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-24 18:57 [PATCH] eventpoll: return -ENOIOCTLCMD for unknown ioctl commands hengyul
2026-09-24 21:59 ` Joe Damato
2026-09-30 9:50 ` Hengyu Liang [this message]
2026-10-01 20:05 ` Joe Damato
2026-10-01 20:06 ` Joe Damato
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=20260930095058.1062123-1-hengyul@cs.unc.edu \
--to=hengyul@cs.unc.edu \
--cc=brauner@kernel.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=jack@suse.cz \
--cc=jirislaby@kernel.org \
--cc=joe@dama.to \
--cc=kuba@kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=sdf@fomichev.me \
--cc=shuah@kernel.org \
--cc=viro@zeniv.linux.org.uk \
/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