From 94aefd32f431a2c15f9d2c5f8f19dece73a77b52 Mon Sep 17 00:00:00 2001 From: Avi Kivity Date: Fri, 8 Jun 2018 17:55:05 +0300 Subject: aio: mark __aio_sigset::sigmask const io_pgetevents() will not change the signal mask. Mark it const to make it clear and to reduce the need for casts in user code. Reviewed-by: Christoph Hellwig Signed-off-by: Avi Kivity Signed-off-by: Al Viro --- include/uapi/linux/aio_abi.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/uapi/linux/aio_abi.h b/include/uapi/linux/aio_abi.h index 75846164290e..d00221345c19 100644 --- a/include/uapi/linux/aio_abi.h +++ b/include/uapi/linux/aio_abi.h @@ -109,7 +109,7 @@ struct iocb { #undef IFLITTLE struct __aio_sigset { - sigset_t __user *sigmask; + const sigset_t __user *sigmask; size_t sigsetsize; }; -- cgit From 4d572d9f46507be8cfe326aa5bc3698babcbdfa7 Mon Sep 17 00:00:00 2001 From: Avi Kivity Date: Fri, 8 Jun 2018 22:12:32 +0300 Subject: eventfd: only return events requested in poll_mask() The ->poll_mask() operation has a mask of events that the caller is interested in, but we're returning all events regardless. Change to return only the events the caller is interested in. This fixes aio IO_CMD_POLL returning immediately when called with POLLIN on an eventfd, since an eventfd is almost always ready for a write. Signed-off-by: Avi Kivity Signed-off-by: Al Viro --- fs/eventfd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/eventfd.c b/fs/eventfd.c index 61c9514da5e9..ceb1031f1cac 100644 --- a/fs/eventfd.c +++ b/fs/eventfd.c @@ -156,11 +156,11 @@ static __poll_t eventfd_poll_mask(struct file *file, __poll_t eventmask) count = READ_ONCE(ctx->count); if (count > 0) - events |= EPOLLIN; + events |= (EPOLLIN & eventmask); if (count == ULLONG_MAX) events |= EPOLLERR; if (ULLONG_MAX - 1 > count) - events |= EPOLLOUT; + events |= (EPOLLOUT & eventmask); return events; } -- cgit From 2739b807b0885a09996659be82f813af219c7360 Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Mon, 11 Jun 2018 08:50:10 +0200 Subject: aio: only return events requested in poll_mask() for IOCB_CMD_POLL The ->poll_mask() operation has a mask of events that the caller is interested in, but not all implementations might take it into account. Mask the return value to only the requested events, similar to what the poll and epoll code does. Reported-by: Avi Kivity Signed-off-by: Christoph Hellwig Signed-off-by: Al Viro --- fs/aio.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/aio.c b/fs/aio.c index 134e5b635d64..e1d20124ec0e 100644 --- a/fs/aio.c +++ b/fs/aio.c @@ -1661,7 +1661,7 @@ static int aio_poll_wake(struct wait_queue_entry *wait, unsigned mode, int sync, if (mask && !(mask & req->events)) return 0; - mask = file->f_op->poll_mask(file, req->events); + mask = file->f_op->poll_mask(file, req->events) & req->events; if (!mask) return 0; @@ -1719,7 +1719,7 @@ static ssize_t aio_poll(struct aio_kiocb *aiocb, struct iocb *iocb) spin_lock_irq(&ctx->ctx_lock); spin_lock(&req->head->lock); - mask = req->file->f_op->poll_mask(req->file, req->events); + mask = req->file->f_op->poll_mask(req->file, req->events) & req->events; if (!mask) { __add_wait_queue(req->head, &req->wait); list_add_tail(&aiocb->ki_list, &ctx->active_reqs); -- cgit From 11c5ad0ec441129adef42c16bbd5139707a8c5b6 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Fri, 15 Jun 2018 00:32:07 +0200 Subject: eventpoll: switch to ->poll_mask Signed-off-by: Ben Noordhuis Signed-off-by: Al Viro --- fs/eventpoll.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/fs/eventpoll.c b/fs/eventpoll.c index 67db22fe99c5..ea4436f409fb 100644 --- a/fs/eventpoll.c +++ b/fs/eventpoll.c @@ -922,13 +922,17 @@ static __poll_t ep_read_events_proc(struct eventpoll *ep, struct list_head *head return 0; } -static __poll_t ep_eventpoll_poll(struct file *file, poll_table *wait) +static struct wait_queue_head *ep_eventpoll_get_poll_head(struct file *file, + __poll_t eventmask) { struct eventpoll *ep = file->private_data; - int depth = 0; + return &ep->poll_wait; +} - /* Insert inside our poll wait queue */ - poll_wait(file, &ep->poll_wait, wait); +static __poll_t ep_eventpoll_poll_mask(struct file *file, __poll_t eventmask) +{ + struct eventpoll *ep = file->private_data; + int depth = 0; /* * Proceed to find out if wanted events are really available inside @@ -968,7 +972,8 @@ static const struct file_operations eventpoll_fops = { .show_fdinfo = ep_show_fdinfo, #endif .release = ep_eventpoll_release, - .poll = ep_eventpoll_poll, + .get_poll_head = ep_eventpoll_get_poll_head, + .poll_mask = ep_eventpoll_poll_mask, .llseek = noop_llseek, }; -- cgit