diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2018-02-11 16:57:19 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2018-02-11 16:57:19 -0500 |
commit | ee5daa1361fceb6f482c005bcc9ba8d01b92ea5c (patch) | |
tree | 71736f733c7efec13218756ab8635b258b8a1c53 | |
parent | 3fc928dc5308f6533d0e8004c8c63b46709a5276 (diff) | |
parent | d85e2aa2e34dac793e70b900d865f48c69ecbc27 (diff) |
Merge branch 'work.poll2' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull more poll annotation updates from Al Viro:
"This is preparation to solving the problems you've mentioned in the
original poll series.
After this series, the kernel is ready for running
for V in IN OUT PRI ERR RDNORM RDBAND WRNORM WRBAND HUP RDHUP NVAL MSG; do
L=`git grep -l -w POLL$V | grep -v '^t' | grep -v /um/ | grep -v '^sa' | grep -v '/poll.h$'|grep -v '^D'`
for f in $L; do sed -i "-es/^\([^\"]*\)\(\<POLL$V\>\)/\\1E\\2/" $f; done
done
as a for bulk search-and-replace.
After that, the kernel is ready to apply the patch to unify
{de,}mangle_poll(), and then get rid of kernel-side POLL... uses
entirely, and we should be all done with that stuff.
Basically, that's what you suggested wrt KPOLL..., except that we can
use EPOLL... instead - they already are arch-independent (and equal to
what is currently kernel-side POLL...).
After the preparations (in this series) switch to returning EPOLL...
from ->poll() instances is completely mechanical and kernel-side
POLL... can go away. The last step (killing kernel-side POLL... and
unifying {de,}mangle_poll() has to be done after the
search-and-replace job, since we need userland-side POLL... for
unified {de,}mangle_poll(), thus the cherry-pick at the last step.
After that we will have:
- POLL{IN,OUT,...} *not* in __poll_t, so any stray instances of
->poll() still using those will be caught by sparse.
- eventpoll.c and select.c warning-free wrt __poll_t
- no more kernel-side definitions of POLL... - userland ones are
visible through the entire kernel (and used pretty much only for
mangle/demangle)
- same behavior as after the first series (i.e. sparc et.al. epoll(2)
working correctly)"
* 'work.poll2' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
annotate ep_scan_ready_list()
ep_send_events_proc(): return result via esed->res
preparation to switching ->poll() to returning EPOLL...
add EPOLLNVAL, annotate EPOLL... and event_poll->event
use linux/poll.h instead of asm/poll.h
xen: fix poll misannotation
smc: missing poll annotations
-rw-r--r-- | drivers/xen/pvcalls-front.h | 2 | ||||
-rw-r--r-- | fs/coda/psdev.c | 2 | ||||
-rw-r--r-- | fs/debugfs/file.c | 2 | ||||
-rw-r--r-- | fs/eventpoll.c | 41 | ||||
-rw-r--r-- | fs/fcntl.c | 2 | ||||
-rw-r--r-- | include/linux/poll.h | 3 | ||||
-rw-r--r-- | include/uapi/linux/eventpoll.h | 33 | ||||
-rw-r--r-- | net/smc/af_smc.c | 2 |
8 files changed, 47 insertions, 40 deletions
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, | |||
20 | struct msghdr *msg, | 20 | struct msghdr *msg, |
21 | size_t len, | 21 | size_t len, |
22 | int flags); | 22 | int flags); |
23 | unsigned int pvcalls_front_poll(struct file *file, | 23 | __poll_t pvcalls_front_poll(struct file *file, |
24 | struct socket *sock, | 24 | struct socket *sock, |
25 | poll_table *wait); | 25 | poll_table *wait); |
26 | int pvcalls_front_release(struct socket *sock); | 26 | int pvcalls_front_release(struct socket *sock); |
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 @@ | |||
39 | #include <linux/device.h> | 39 | #include <linux/device.h> |
40 | #include <linux/pid_namespace.h> | 40 | #include <linux/pid_namespace.h> |
41 | #include <asm/io.h> | 41 | #include <asm/io.h> |
42 | #include <asm/poll.h> | 42 | #include <linux/poll.h> |
43 | #include <linux/uaccess.h> | 43 | #include <linux/uaccess.h> |
44 | 44 | ||
45 | #include <linux/coda.h> | 45 | #include <linux/coda.h> |
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 @@ | |||
18 | #include <linux/slab.h> | 18 | #include <linux/slab.h> |
19 | #include <linux/atomic.h> | 19 | #include <linux/atomic.h> |
20 | #include <linux/device.h> | 20 | #include <linux/device.h> |
21 | #include <asm/poll.h> | 21 | #include <linux/poll.h> |
22 | 22 | ||
23 | #include "internal.h" | 23 | #include "internal.h" |
24 | 24 | ||
diff --git a/fs/eventpoll.c b/fs/eventpoll.c index 42e35a6977c9..d1a490c7e6c3 100644 --- a/fs/eventpoll.c +++ b/fs/eventpoll.c | |||
@@ -260,6 +260,7 @@ struct ep_pqueue { | |||
260 | struct ep_send_events_data { | 260 | struct ep_send_events_data { |
261 | int maxevents; | 261 | int maxevents; |
262 | struct epoll_event __user *events; | 262 | struct epoll_event __user *events; |
263 | int res; | ||
263 | }; | 264 | }; |
264 | 265 | ||
265 | /* | 266 | /* |
@@ -660,12 +661,13 @@ static inline void ep_pm_stay_awake_rcu(struct epitem *epi) | |||
660 | * | 661 | * |
661 | * Returns: The same integer error code returned by the @sproc callback. | 662 | * Returns: The same integer error code returned by the @sproc callback. |
662 | */ | 663 | */ |
663 | static int ep_scan_ready_list(struct eventpoll *ep, | 664 | static __poll_t ep_scan_ready_list(struct eventpoll *ep, |
664 | int (*sproc)(struct eventpoll *, | 665 | __poll_t (*sproc)(struct eventpoll *, |
665 | struct list_head *, void *), | 666 | struct list_head *, void *), |
666 | void *priv, int depth, bool ep_locked) | 667 | void *priv, int depth, bool ep_locked) |
667 | { | 668 | { |
668 | int error, pwake = 0; | 669 | __poll_t res; |
670 | int pwake = 0; | ||
669 | unsigned long flags; | 671 | unsigned long flags; |
670 | struct epitem *epi, *nepi; | 672 | struct epitem *epi, *nepi; |
671 | LIST_HEAD(txlist); | 673 | LIST_HEAD(txlist); |
@@ -694,7 +696,7 @@ static int ep_scan_ready_list(struct eventpoll *ep, | |||
694 | /* | 696 | /* |
695 | * Now call the callback function. | 697 | * Now call the callback function. |
696 | */ | 698 | */ |
697 | error = (*sproc)(ep, &txlist, priv); | 699 | res = (*sproc)(ep, &txlist, priv); |
698 | 700 | ||
699 | spin_lock_irqsave(&ep->lock, flags); | 701 | spin_lock_irqsave(&ep->lock, flags); |
700 | /* | 702 | /* |
@@ -747,7 +749,7 @@ static int ep_scan_ready_list(struct eventpoll *ep, | |||
747 | if (pwake) | 749 | if (pwake) |
748 | ep_poll_safewake(&ep->poll_wait); | 750 | ep_poll_safewake(&ep->poll_wait); |
749 | 751 | ||
750 | return error; | 752 | return res; |
751 | } | 753 | } |
752 | 754 | ||
753 | static void epi_rcu_free(struct rcu_head *head) | 755 | static void epi_rcu_free(struct rcu_head *head) |
@@ -864,7 +866,7 @@ static int ep_eventpoll_release(struct inode *inode, struct file *file) | |||
864 | return 0; | 866 | return 0; |
865 | } | 867 | } |
866 | 868 | ||
867 | static int ep_read_events_proc(struct eventpoll *ep, struct list_head *head, | 869 | static __poll_t ep_read_events_proc(struct eventpoll *ep, struct list_head *head, |
868 | void *priv); | 870 | void *priv); |
869 | static void ep_ptable_queue_proc(struct file *file, wait_queue_head_t *whead, | 871 | static void ep_ptable_queue_proc(struct file *file, wait_queue_head_t *whead, |
870 | poll_table *pt); | 872 | poll_table *pt); |
@@ -874,7 +876,7 @@ static void ep_ptable_queue_proc(struct file *file, wait_queue_head_t *whead, | |||
874 | * the ep->mtx so we need to start from depth=1, such that mutex_lock_nested() | 876 | * the ep->mtx so we need to start from depth=1, such that mutex_lock_nested() |
875 | * is correctly annotated. | 877 | * is correctly annotated. |
876 | */ | 878 | */ |
877 | static unsigned int ep_item_poll(const struct epitem *epi, poll_table *pt, | 879 | static __poll_t ep_item_poll(const struct epitem *epi, poll_table *pt, |
878 | int depth) | 880 | int depth) |
879 | { | 881 | { |
880 | struct eventpoll *ep; | 882 | struct eventpoll *ep; |
@@ -894,7 +896,7 @@ static unsigned int ep_item_poll(const struct epitem *epi, poll_table *pt, | |||
894 | locked) & epi->event.events; | 896 | locked) & epi->event.events; |
895 | } | 897 | } |
896 | 898 | ||
897 | static int ep_read_events_proc(struct eventpoll *ep, struct list_head *head, | 899 | static __poll_t ep_read_events_proc(struct eventpoll *ep, struct list_head *head, |
898 | void *priv) | 900 | void *priv) |
899 | { | 901 | { |
900 | struct epitem *epi, *tmp; | 902 | struct epitem *epi, *tmp; |
@@ -1414,7 +1416,8 @@ static noinline void ep_destroy_wakeup_source(struct epitem *epi) | |||
1414 | static int ep_insert(struct eventpoll *ep, const struct epoll_event *event, | 1416 | static int ep_insert(struct eventpoll *ep, const struct epoll_event *event, |
1415 | struct file *tfile, int fd, int full_check) | 1417 | struct file *tfile, int fd, int full_check) |
1416 | { | 1418 | { |
1417 | int error, revents, pwake = 0; | 1419 | int error, pwake = 0; |
1420 | __poll_t revents; | ||
1418 | unsigned long flags; | 1421 | unsigned long flags; |
1419 | long user_watches; | 1422 | long user_watches; |
1420 | struct epitem *epi; | 1423 | struct epitem *epi; |
@@ -1612,12 +1615,11 @@ static int ep_modify(struct eventpoll *ep, struct epitem *epi, | |||
1612 | return 0; | 1615 | return 0; |
1613 | } | 1616 | } |
1614 | 1617 | ||
1615 | static int ep_send_events_proc(struct eventpoll *ep, struct list_head *head, | 1618 | static __poll_t ep_send_events_proc(struct eventpoll *ep, struct list_head *head, |
1616 | void *priv) | 1619 | void *priv) |
1617 | { | 1620 | { |
1618 | struct ep_send_events_data *esed = priv; | 1621 | struct ep_send_events_data *esed = priv; |
1619 | int eventcnt; | 1622 | __poll_t revents; |
1620 | unsigned int revents; | ||
1621 | struct epitem *epi; | 1623 | struct epitem *epi; |
1622 | struct epoll_event __user *uevent; | 1624 | struct epoll_event __user *uevent; |
1623 | struct wakeup_source *ws; | 1625 | struct wakeup_source *ws; |
@@ -1630,8 +1632,8 @@ static int ep_send_events_proc(struct eventpoll *ep, struct list_head *head, | |||
1630 | * Items cannot vanish during the loop because ep_scan_ready_list() is | 1632 | * Items cannot vanish during the loop because ep_scan_ready_list() is |
1631 | * holding "mtx" during this call. | 1633 | * holding "mtx" during this call. |
1632 | */ | 1634 | */ |
1633 | for (eventcnt = 0, uevent = esed->events; | 1635 | for (esed->res = 0, uevent = esed->events; |
1634 | !list_empty(head) && eventcnt < esed->maxevents;) { | 1636 | !list_empty(head) && esed->res < esed->maxevents;) { |
1635 | epi = list_first_entry(head, struct epitem, rdllink); | 1637 | epi = list_first_entry(head, struct epitem, rdllink); |
1636 | 1638 | ||
1637 | /* | 1639 | /* |
@@ -1665,9 +1667,11 @@ static int ep_send_events_proc(struct eventpoll *ep, struct list_head *head, | |||
1665 | __put_user(epi->event.data, &uevent->data)) { | 1667 | __put_user(epi->event.data, &uevent->data)) { |
1666 | list_add(&epi->rdllink, head); | 1668 | list_add(&epi->rdllink, head); |
1667 | ep_pm_stay_awake(epi); | 1669 | ep_pm_stay_awake(epi); |
1668 | return eventcnt ? eventcnt : -EFAULT; | 1670 | if (!esed->res) |
1671 | esed->res = -EFAULT; | ||
1672 | return 0; | ||
1669 | } | 1673 | } |
1670 | eventcnt++; | 1674 | esed->res++; |
1671 | uevent++; | 1675 | uevent++; |
1672 | if (epi->event.events & EPOLLONESHOT) | 1676 | if (epi->event.events & EPOLLONESHOT) |
1673 | epi->event.events &= EP_PRIVATE_BITS; | 1677 | epi->event.events &= EP_PRIVATE_BITS; |
@@ -1689,7 +1693,7 @@ static int ep_send_events_proc(struct eventpoll *ep, struct list_head *head, | |||
1689 | } | 1693 | } |
1690 | } | 1694 | } |
1691 | 1695 | ||
1692 | return eventcnt; | 1696 | return 0; |
1693 | } | 1697 | } |
1694 | 1698 | ||
1695 | static int ep_send_events(struct eventpoll *ep, | 1699 | static int ep_send_events(struct eventpoll *ep, |
@@ -1700,7 +1704,8 @@ static int ep_send_events(struct eventpoll *ep, | |||
1700 | esed.maxevents = maxevents; | 1704 | esed.maxevents = maxevents; |
1701 | esed.events = events; | 1705 | esed.events = events; |
1702 | 1706 | ||
1703 | return ep_scan_ready_list(ep, ep_send_events_proc, &esed, 0, false); | 1707 | ep_scan_ready_list(ep, ep_send_events_proc, &esed, 0, false); |
1708 | return esed.res; | ||
1704 | } | 1709 | } |
1705 | 1710 | ||
1706 | static inline struct timespec64 ep_set_mstimeout(long ms) | 1711 | static inline struct timespec64 ep_set_mstimeout(long ms) |
diff --git a/fs/fcntl.c b/fs/fcntl.c index e95fa0a352ea..4fc731876d6b 100644 --- a/fs/fcntl.c +++ b/fs/fcntl.c | |||
@@ -26,7 +26,7 @@ | |||
26 | #include <linux/shmem_fs.h> | 26 | #include <linux/shmem_fs.h> |
27 | #include <linux/compat.h> | 27 | #include <linux/compat.h> |
28 | 28 | ||
29 | #include <asm/poll.h> | 29 | #include <linux/poll.h> |
30 | #include <asm/siginfo.h> | 30 | #include <asm/siginfo.h> |
31 | #include <linux/uaccess.h> | 31 | #include <linux/uaccess.h> |
32 | 32 | ||
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 @@ | |||
11 | #include <linux/sysctl.h> | 11 | #include <linux/sysctl.h> |
12 | #include <linux/uaccess.h> | 12 | #include <linux/uaccess.h> |
13 | #include <uapi/linux/poll.h> | 13 | #include <uapi/linux/poll.h> |
14 | #include <uapi/linux/eventpoll.h> | ||
14 | 15 | ||
15 | extern struct ctl_table epoll_table[]; /* for sysctl */ | 16 | extern struct ctl_table epoll_table[]; /* for sysctl */ |
16 | /* ~832 bytes of stack space used max in sys_select/sys_poll before allocating | 17 | /* ~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 */ | |||
22 | #define WQUEUES_STACK_ALLOC (MAX_STACK_ALLOC - FRONTEND_STACK_ALLOC) | 23 | #define WQUEUES_STACK_ALLOC (MAX_STACK_ALLOC - FRONTEND_STACK_ALLOC) |
23 | #define N_INLINE_POLL_ENTRIES (WQUEUES_STACK_ALLOC / sizeof(struct poll_table_entry)) | 24 | #define N_INLINE_POLL_ENTRIES (WQUEUES_STACK_ALLOC / sizeof(struct poll_table_entry)) |
24 | 25 | ||
25 | #define DEFAULT_POLLMASK (POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM) | 26 | #define DEFAULT_POLLMASK (EPOLLIN | EPOLLOUT | EPOLLRDNORM | EPOLLWRNORM) |
26 | 27 | ||
27 | struct poll_table_struct; | 28 | struct poll_table_struct; |
28 | 29 | ||
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 @@ | |||
28 | #define EPOLL_CTL_MOD 3 | 28 | #define EPOLL_CTL_MOD 3 |
29 | 29 | ||
30 | /* Epoll event masks */ | 30 | /* Epoll event masks */ |
31 | #define EPOLLIN 0x00000001 | 31 | #define EPOLLIN (__force __poll_t)0x00000001 |
32 | #define EPOLLPRI 0x00000002 | 32 | #define EPOLLPRI (__force __poll_t)0x00000002 |
33 | #define EPOLLOUT 0x00000004 | 33 | #define EPOLLOUT (__force __poll_t)0x00000004 |
34 | #define EPOLLERR 0x00000008 | 34 | #define EPOLLERR (__force __poll_t)0x00000008 |
35 | #define EPOLLHUP 0x00000010 | 35 | #define EPOLLHUP (__force __poll_t)0x00000010 |
36 | #define EPOLLRDNORM 0x00000040 | 36 | #define EPOLLNVAL (__force __poll_t)0x00000020 |
37 | #define EPOLLRDBAND 0x00000080 | 37 | #define EPOLLRDNORM (__force __poll_t)0x00000040 |
38 | #define EPOLLWRNORM 0x00000100 | 38 | #define EPOLLRDBAND (__force __poll_t)0x00000080 |
39 | #define EPOLLWRBAND 0x00000200 | 39 | #define EPOLLWRNORM (__force __poll_t)0x00000100 |
40 | #define EPOLLMSG 0x00000400 | 40 | #define EPOLLWRBAND (__force __poll_t)0x00000200 |
41 | #define EPOLLRDHUP 0x00002000 | 41 | #define EPOLLMSG (__force __poll_t)0x00000400 |
42 | #define EPOLLRDHUP (__force __poll_t)0x00002000 | ||
42 | 43 | ||
43 | /* Set exclusive wakeup mode for the target file descriptor */ | 44 | /* Set exclusive wakeup mode for the target file descriptor */ |
44 | #define EPOLLEXCLUSIVE (1U << 28) | 45 | #define EPOLLEXCLUSIVE (__force __poll_t)(1U << 28) |
45 | 46 | ||
46 | /* | 47 | /* |
47 | * Request the handling of system wakeup events so as to prevent system suspends | 48 | * Request the handling of system wakeup events so as to prevent system suspends |
@@ -53,13 +54,13 @@ | |||
53 | * | 54 | * |
54 | * Requires CAP_BLOCK_SUSPEND | 55 | * Requires CAP_BLOCK_SUSPEND |
55 | */ | 56 | */ |
56 | #define EPOLLWAKEUP (1U << 29) | 57 | #define EPOLLWAKEUP (__force __poll_t)(1U << 29) |
57 | 58 | ||
58 | /* Set the One Shot behaviour for the target file descriptor */ | 59 | /* Set the One Shot behaviour for the target file descriptor */ |
59 | #define EPOLLONESHOT (1U << 30) | 60 | #define EPOLLONESHOT (__force __poll_t)(1U << 30) |
60 | 61 | ||
61 | /* Set the Edge Triggered behaviour for the target file descriptor */ | 62 | /* Set the Edge Triggered behaviour for the target file descriptor */ |
62 | #define EPOLLET (1U << 31) | 63 | #define EPOLLET (__force __poll_t)(1U << 31) |
63 | 64 | ||
64 | /* | 65 | /* |
65 | * On x86-64 make the 64bit structure have the same alignment as the | 66 | * On x86-64 make the 64bit structure have the same alignment as the |
@@ -74,7 +75,7 @@ | |||
74 | #endif | 75 | #endif |
75 | 76 | ||
76 | struct epoll_event { | 77 | struct epoll_event { |
77 | __u32 events; | 78 | __poll_t events; |
78 | __u64 data; | 79 | __u64 data; |
79 | } EPOLL_PACKED; | 80 | } EPOLL_PACKED; |
80 | 81 | ||
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: | |||
1141 | static __poll_t smc_accept_poll(struct sock *parent) | 1141 | static __poll_t smc_accept_poll(struct sock *parent) |
1142 | { | 1142 | { |
1143 | struct smc_sock *isk = smc_sk(parent); | 1143 | struct smc_sock *isk = smc_sk(parent); |
1144 | int mask = 0; | 1144 | __poll_t mask = 0; |
1145 | 1145 | ||
1146 | spin_lock(&isk->accept_q_lock); | 1146 | spin_lock(&isk->accept_q_lock); |
1147 | if (!list_empty(&isk->accept_q)) | 1147 | if (!list_empty(&isk->accept_q)) |