From 63e2480c86bd610c1d52fdbb76dc6ebea08e518d Mon Sep 17 00:00:00 2001 From: Al Viro Date: Thu, 1 Feb 2018 10:02:53 -0500 Subject: smc: missing poll annotations Signed-off-by: Al Viro --- net/smc/af_smc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/smc/af_smc.c b/net/smc/af_smc.c index 3583c8ab1bae..ba4b84debc5a 100644 --- a/net/smc/af_smc.c +++ b/net/smc/af_smc.c @@ -1141,7 +1141,7 @@ out: static __poll_t smc_accept_poll(struct sock *parent) { struct smc_sock *isk = smc_sk(parent); - int mask = 0; + __poll_t mask = 0; spin_lock(&isk->accept_q_lock); if (!list_empty(&isk->accept_q)) -- cgit From 0148a635ce40d65653bfda469fae8e4b8360baf3 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Thu, 1 Feb 2018 10:07:32 -0500 Subject: xen: fix poll misannotation Signed-off-by: Al Viro --- drivers/xen/pvcalls-front.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/xen/pvcalls-front.h b/drivers/xen/pvcalls-front.h index 3332978f4fcd..f694ad77379f 100644 --- a/drivers/xen/pvcalls-front.h +++ b/drivers/xen/pvcalls-front.h @@ -20,7 +20,7 @@ int pvcalls_front_recvmsg(struct socket *sock, struct msghdr *msg, size_t len, int flags); -unsigned int pvcalls_front_poll(struct file *file, +__poll_t pvcalls_front_poll(struct file *file, struct socket *sock, poll_table *wait); int pvcalls_front_release(struct socket *sock); -- cgit From cfe39442ab8ce9670b4ddd04291b8cddb9cb1129 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Thu, 1 Feb 2018 12:14:57 -0500 Subject: use linux/poll.h instead of asm/poll.h The only place that has any business including asm/poll.h is linux/poll.h. Fortunately, asm/poll.h had only been included in 3 places beyond that one, and all of them are trivial to switch to using linux/poll.h. Signed-off-by: Al Viro --- fs/coda/psdev.c | 2 +- fs/debugfs/file.c | 2 +- fs/fcntl.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/coda/psdev.c b/fs/coda/psdev.c index 49d3c6fda89a..80b9b84391a9 100644 --- a/fs/coda/psdev.c +++ b/fs/coda/psdev.c @@ -39,7 +39,7 @@ #include #include #include -#include +#include #include #include diff --git a/fs/debugfs/file.c b/fs/debugfs/file.c index 6fdbf21be318..20bb73a931dd 100644 --- a/fs/debugfs/file.c +++ b/fs/debugfs/file.c @@ -18,7 +18,7 @@ #include #include #include -#include +#include #include "internal.h" diff --git a/fs/fcntl.c b/fs/fcntl.c index c7b9e0948107..ea3629c15c44 100644 --- a/fs/fcntl.c +++ b/fs/fcntl.c @@ -26,7 +26,7 @@ #include #include -#include +#include #include #include -- cgit From 65aaf87b3aa2d049c6b9fd85221858a895df3393 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Thu, 1 Feb 2018 11:00:50 -0500 Subject: add EPOLLNVAL, annotate EPOLL... and event_poll->event Signed-off-by: Al Viro --- include/uapi/linux/eventpoll.h | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/include/uapi/linux/eventpoll.h b/include/uapi/linux/eventpoll.h index 63e21be30f15..bf48e71f2634 100644 --- a/include/uapi/linux/eventpoll.h +++ b/include/uapi/linux/eventpoll.h @@ -28,20 +28,21 @@ #define EPOLL_CTL_MOD 3 /* Epoll event masks */ -#define EPOLLIN 0x00000001 -#define EPOLLPRI 0x00000002 -#define EPOLLOUT 0x00000004 -#define EPOLLERR 0x00000008 -#define EPOLLHUP 0x00000010 -#define EPOLLRDNORM 0x00000040 -#define EPOLLRDBAND 0x00000080 -#define EPOLLWRNORM 0x00000100 -#define EPOLLWRBAND 0x00000200 -#define EPOLLMSG 0x00000400 -#define EPOLLRDHUP 0x00002000 +#define EPOLLIN (__force __poll_t)0x00000001 +#define EPOLLPRI (__force __poll_t)0x00000002 +#define EPOLLOUT (__force __poll_t)0x00000004 +#define EPOLLERR (__force __poll_t)0x00000008 +#define EPOLLHUP (__force __poll_t)0x00000010 +#define EPOLLNVAL (__force __poll_t)0x00000020 +#define EPOLLRDNORM (__force __poll_t)0x00000040 +#define EPOLLRDBAND (__force __poll_t)0x00000080 +#define EPOLLWRNORM (__force __poll_t)0x00000100 +#define EPOLLWRBAND (__force __poll_t)0x00000200 +#define EPOLLMSG (__force __poll_t)0x00000400 +#define EPOLLRDHUP (__force __poll_t)0x00002000 /* Set exclusive wakeup mode for the target file descriptor */ -#define EPOLLEXCLUSIVE (1U << 28) +#define EPOLLEXCLUSIVE (__force __poll_t)(1U << 28) /* * Request the handling of system wakeup events so as to prevent system suspends @@ -53,13 +54,13 @@ * * Requires CAP_BLOCK_SUSPEND */ -#define EPOLLWAKEUP (1U << 29) +#define EPOLLWAKEUP (__force __poll_t)(1U << 29) /* Set the One Shot behaviour for the target file descriptor */ -#define EPOLLONESHOT (1U << 30) +#define EPOLLONESHOT (__force __poll_t)(1U << 30) /* Set the Edge Triggered behaviour for the target file descriptor */ -#define EPOLLET (1U << 31) +#define EPOLLET (__force __poll_t)(1U << 31) /* * On x86-64 make the 64bit structure have the same alignment as the @@ -74,7 +75,7 @@ #endif struct epoll_event { - __u32 events; + __poll_t events; __u64 data; } EPOLL_PACKED; -- cgit From e78cd95bebd94ede71285722f5bf2464bfa4c599 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Thu, 1 Feb 2018 11:01:35 -0500 Subject: preparation to switching ->poll() to returning EPOLL... Signed-off-by: Al Viro --- include/linux/poll.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/linux/poll.h b/include/linux/poll.h index 04781a753326..d23104b32931 100644 --- a/include/linux/poll.h +++ b/include/linux/poll.h @@ -11,6 +11,7 @@ #include #include #include +#include extern struct ctl_table epoll_table[]; /* for sysctl */ /* ~832 bytes of stack space used max in sys_select/sys_poll before allocating @@ -22,7 +23,7 @@ extern struct ctl_table epoll_table[]; /* for sysctl */ #define WQUEUES_STACK_ALLOC (MAX_STACK_ALLOC - FRONTEND_STACK_ALLOC) #define N_INLINE_POLL_ENTRIES (WQUEUES_STACK_ALLOC / sizeof(struct poll_table_entry)) -#define DEFAULT_POLLMASK (POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM) +#define DEFAULT_POLLMASK (EPOLLIN | EPOLLOUT | EPOLLRDNORM | EPOLLWRNORM) struct poll_table_struct; -- cgit From d7ebbe46f445d8c64fa37812818597dc466d74bb Mon Sep 17 00:00:00 2001 From: Al Viro Date: Thu, 1 Feb 2018 15:21:13 -0500 Subject: ep_send_events_proc(): return result via esed->res preparations for not mixing __poll_t and int in ep_scan_ready_list() Signed-off-by: Al Viro --- fs/eventpoll.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/fs/eventpoll.c b/fs/eventpoll.c index 42e35a6977c9..87452875eaec 100644 --- a/fs/eventpoll.c +++ b/fs/eventpoll.c @@ -260,6 +260,7 @@ struct ep_pqueue { struct ep_send_events_data { int maxevents; struct epoll_event __user *events; + int res; }; /* @@ -1616,7 +1617,6 @@ static int ep_send_events_proc(struct eventpoll *ep, struct list_head *head, void *priv) { struct ep_send_events_data *esed = priv; - int eventcnt; unsigned int revents; struct epitem *epi; struct epoll_event __user *uevent; @@ -1630,8 +1630,8 @@ static int ep_send_events_proc(struct eventpoll *ep, struct list_head *head, * Items cannot vanish during the loop because ep_scan_ready_list() is * holding "mtx" during this call. */ - for (eventcnt = 0, uevent = esed->events; - !list_empty(head) && eventcnt < esed->maxevents;) { + for (esed->res = 0, uevent = esed->events; + !list_empty(head) && esed->res < esed->maxevents;) { epi = list_first_entry(head, struct epitem, rdllink); /* @@ -1665,9 +1665,11 @@ static int ep_send_events_proc(struct eventpoll *ep, struct list_head *head, __put_user(epi->event.data, &uevent->data)) { list_add(&epi->rdllink, head); ep_pm_stay_awake(epi); - return eventcnt ? eventcnt : -EFAULT; + if (!esed->res) + esed->res = -EFAULT; + return 0; } - eventcnt++; + esed->res++; uevent++; if (epi->event.events & EPOLLONESHOT) epi->event.events &= EP_PRIVATE_BITS; @@ -1689,7 +1691,7 @@ static int ep_send_events_proc(struct eventpoll *ep, struct list_head *head, } } - return eventcnt; + return 0; } static int ep_send_events(struct eventpoll *ep, @@ -1700,7 +1702,8 @@ static int ep_send_events(struct eventpoll *ep, esed.maxevents = maxevents; esed.events = events; - return ep_scan_ready_list(ep, ep_send_events_proc, &esed, 0, false); + ep_scan_ready_list(ep, ep_send_events_proc, &esed, 0, false); + return esed.res; } static inline struct timespec64 ep_set_mstimeout(long ms) -- cgit From d85e2aa2e34dac793e70b900d865f48c69ecbc27 Mon Sep 17 00:00:00 2001 From: Al Viro Date: Thu, 1 Feb 2018 15:24:58 -0500 Subject: annotate ep_scan_ready_list() make it always return __poll_t and have its callbacks do the same Signed-off-by: Al Viro --- fs/eventpoll.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/fs/eventpoll.c b/fs/eventpoll.c index 87452875eaec..d1a490c7e6c3 100644 --- a/fs/eventpoll.c +++ b/fs/eventpoll.c @@ -661,12 +661,13 @@ static inline void ep_pm_stay_awake_rcu(struct epitem *epi) * * Returns: The same integer error code returned by the @sproc callback. */ -static int ep_scan_ready_list(struct eventpoll *ep, - int (*sproc)(struct eventpoll *, +static __poll_t ep_scan_ready_list(struct eventpoll *ep, + __poll_t (*sproc)(struct eventpoll *, struct list_head *, void *), void *priv, int depth, bool ep_locked) { - int error, pwake = 0; + __poll_t res; + int pwake = 0; unsigned long flags; struct epitem *epi, *nepi; LIST_HEAD(txlist); @@ -695,7 +696,7 @@ static int ep_scan_ready_list(struct eventpoll *ep, /* * Now call the callback function. */ - error = (*sproc)(ep, &txlist, priv); + res = (*sproc)(ep, &txlist, priv); spin_lock_irqsave(&ep->lock, flags); /* @@ -748,7 +749,7 @@ static int ep_scan_ready_list(struct eventpoll *ep, if (pwake) ep_poll_safewake(&ep->poll_wait); - return error; + return res; } static void epi_rcu_free(struct rcu_head *head) @@ -865,7 +866,7 @@ static int ep_eventpoll_release(struct inode *inode, struct file *file) return 0; } -static int ep_read_events_proc(struct eventpoll *ep, struct list_head *head, +static __poll_t ep_read_events_proc(struct eventpoll *ep, struct list_head *head, void *priv); static void ep_ptable_queue_proc(struct file *file, wait_queue_head_t *whead, poll_table *pt); @@ -875,7 +876,7 @@ static void ep_ptable_queue_proc(struct file *file, wait_queue_head_t *whead, * the ep->mtx so we need to start from depth=1, such that mutex_lock_nested() * is correctly annotated. */ -static unsigned int ep_item_poll(const struct epitem *epi, poll_table *pt, +static __poll_t ep_item_poll(const struct epitem *epi, poll_table *pt, int depth) { struct eventpoll *ep; @@ -895,7 +896,7 @@ static unsigned int ep_item_poll(const struct epitem *epi, poll_table *pt, locked) & epi->event.events; } -static int ep_read_events_proc(struct eventpoll *ep, struct list_head *head, +static __poll_t ep_read_events_proc(struct eventpoll *ep, struct list_head *head, void *priv) { struct epitem *epi, *tmp; @@ -1415,7 +1416,8 @@ static noinline void ep_destroy_wakeup_source(struct epitem *epi) static int ep_insert(struct eventpoll *ep, const struct epoll_event *event, struct file *tfile, int fd, int full_check) { - int error, revents, pwake = 0; + int error, pwake = 0; + __poll_t revents; unsigned long flags; long user_watches; struct epitem *epi; @@ -1613,11 +1615,11 @@ static int ep_modify(struct eventpoll *ep, struct epitem *epi, return 0; } -static int ep_send_events_proc(struct eventpoll *ep, struct list_head *head, +static __poll_t ep_send_events_proc(struct eventpoll *ep, struct list_head *head, void *priv) { struct ep_send_events_data *esed = priv; - unsigned int revents; + __poll_t revents; struct epitem *epi; struct epoll_event __user *uevent; struct wakeup_source *ws; -- cgit