]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
io_uring: disable polling pollfree files
authorPavel Begunkov <asml.silence@gmail.com>
Thu, 1 Sep 2022 15:19:15 +0000 (16:19 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 5 Sep 2022 08:27:47 +0000 (10:27 +0200)
Older kernels lack io_uring POLLFREE handling. As only affected files
are signalfd and android binder the safest option would be to disable
polling those files via io_uring and hope there are no users.

Fixes: 221c5eb233823 ("io_uring: add support for IORING_OP_POLL")
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/android/binder.c
fs/io_uring.c
fs/signalfd.c
include/linux/fs.h

index b9fb2a9269443d84a2a9ad3024d08a172d93b498..c273d0df69394400e010f9d97e6409484ddf7d5f 100644 (file)
@@ -6083,6 +6083,7 @@ const struct file_operations binder_fops = {
        .open = binder_open,
        .flush = binder_flush,
        .release = binder_release,
+       .may_pollfree = true,
 };
 
 static int __init init_binder_device(const char *name)
index e73969fa96bcb088f3ea005e7191c086cc7347a6..501c7e14c07cf1113b7de8691ef6635e36784b25 100644 (file)
@@ -1908,6 +1908,9 @@ static int io_poll_add(struct io_kiocb *req, const struct io_uring_sqe *sqe)
        __poll_t mask;
        u16 events;
 
+       if (req->file->f_op->may_pollfree)
+               return -EOPNOTSUPP;
+
        if (unlikely(req->ctx->flags & IORING_SETUP_IOPOLL))
                return -EINVAL;
        if (sqe->addr || sqe->ioprio || sqe->off || sqe->len || sqe->buf_index)
index 3e94d181930fdd0042aa2069230d20ddb31d5698..c3415d969ecfc3814184d725f0fc6bb3d77d443f 100644 (file)
@@ -248,6 +248,7 @@ static const struct file_operations signalfd_fops = {
        .poll           = signalfd_poll,
        .read           = signalfd_read,
        .llseek         = noop_llseek,
+       .may_pollfree   = true,
 };
 
 static int do_signalfd4(int ufd, sigset_t *mask, int flags)
index ef118b8ba6993158c3550ce191b1bb5d2d8af82a..4ecbe12f6215203de7287a99e8efcec6b05f5aa9 100644 (file)
@@ -1859,6 +1859,7 @@ struct file_operations {
                                   struct file *file_out, loff_t pos_out,
                                   loff_t len, unsigned int remap_flags);
        int (*fadvise)(struct file *, loff_t, loff_t, int);
+       bool may_pollfree;
 } __randomize_layout;
 
 struct inode_operations {