Merge branch 'misc.poll' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs

Pull poll annotations from Al Viro:
 "This introduces a __bitwise type for POLL### bitmap, and propagates
  the annotations through the tree. Most of that stuff is as simple as
  'make ->poll() instances return __poll_t and do the same to local
  variables used to hold the future return value'.

  Some of the obvious brainos found in process are fixed (e.g. POLLIN
  misspelled as POLL_IN). At that point the amount of sparse warnings is
  low and most of them are for genuine bugs - e.g. ->poll() instance
  deciding to return -EINVAL instead of a bitmap. I hadn't touched those
  in this series - it's large enough as it is.

  Another problem it has caught was eventpoll() ABI mess; select.c and
  eventpoll.c assumed that corresponding POLL### and EPOLL### were
  equal. That's true for some, but not all of them - EPOLL### are
  arch-independent, but POLL### are not.

  The last commit in this series separates userland POLL### values from
  the (now arch-independent) kernel-side ones, converting between them
  in the few places where they are copied to/from userland. AFAICS, this
  is the least disruptive fix preserving poll(2) ABI and making epoll()
  work on all architectures.

  As it is, it's simply broken on sparc - try to give it EPOLLWRNORM and
  it will trigger only on what would've triggered EPOLLWRBAND on other
  architectures. EPOLLWRBAND and EPOLLRDHUP, OTOH, are never triggered
  at all on sparc. With this patch they should work consistently on all
  architectures"

* 'misc.poll' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (37 commits)
  make kernel-side POLL... arch-independent
  eventpoll: no need to mask the result of epi_item_poll() again
  eventpoll: constify struct epoll_event pointers
  debugging printk in sg_poll() uses %x to print POLL... bitmap
  annotate poll(2) guts
  9p: untangle ->poll() mess
  ->si_band gets POLL... bitmap stored into a user-visible long field
  ring_buffer_poll_wait() return value used as return value of ->poll()
  the rest of drivers/*: annotate ->poll() instances
  media: annotate ->poll() instances
  fs: annotate ->poll() instances
  ipc, kernel, mm: annotate ->poll() instances
  net: annotate ->poll() instances
  apparmor: annotate ->poll() instances
  tomoyo: annotate ->poll() instances
  sound: annotate ->poll() instances
  acpi: annotate ->poll() instances
  crypto: annotate ->poll() instances
  block: annotate ->poll() instances
  x86: annotate ->poll() instances
  ...
This commit is contained in:
Linus Torvalds
2018-01-30 17:58:07 -08:00
387 changed files with 928 additions and 810 deletions

View File

@@ -3,35 +3,49 @@
#define __ASM_GENERIC_POLL_H
/* These are specified by iBCS2 */
#define POLLIN 0x0001
#define POLLPRI 0x0002
#define POLLOUT 0x0004
#define POLLERR 0x0008
#define POLLHUP 0x0010
#define POLLNVAL 0x0020
#define POLLIN (__force __poll_t)0x0001
#define POLLPRI (__force __poll_t)0x0002
#define POLLOUT (__force __poll_t)0x0004
#define POLLERR (__force __poll_t)0x0008
#define POLLHUP (__force __poll_t)0x0010
#define POLLNVAL (__force __poll_t)0x0020
/* The rest seem to be more-or-less nonstandard. Check them! */
#define POLLRDNORM 0x0040
#define POLLRDBAND 0x0080
#define POLLRDNORM (__force __poll_t)0x0040
#define POLLRDBAND (__force __poll_t)0x0080
#ifndef POLLWRNORM
#define POLLWRNORM 0x0100
#define POLLWRNORM (__force __poll_t)0x0100
#endif
#ifndef POLLWRBAND
#define POLLWRBAND 0x0200
#define POLLWRBAND (__force __poll_t)0x0200
#endif
#ifndef POLLMSG
#define POLLMSG 0x0400
#define POLLMSG (__force __poll_t)0x0400
#endif
#ifndef POLLREMOVE
#define POLLREMOVE 0x1000
#define POLLREMOVE (__force __poll_t)0x1000
#endif
#ifndef POLLRDHUP
#define POLLRDHUP 0x2000
#define POLLRDHUP (__force __poll_t)0x2000
#endif
#define POLLFREE 0x4000 /* currently only for epoll */
#define POLLFREE (__force __poll_t)0x4000 /* currently only for epoll */
#define POLL_BUSY_LOOP 0x8000
#define POLL_BUSY_LOOP (__force __poll_t)0x8000
#ifdef __KERNEL__
#ifndef __ARCH_HAS_MANGLED_POLL
static inline __u16 mangle_poll(__poll_t val)
{
return (__force __u16)val;
}
static inline __poll_t demangle_poll(__u16 v)
{
return (__force __poll_t)v;
}
#endif
#endif
struct pollfd {
int fd;

View File

@@ -49,5 +49,11 @@ typedef __u32 __bitwise __wsum;
#define __aligned_be64 __be64 __attribute__((aligned(8)))
#define __aligned_le64 __le64 __attribute__((aligned(8)))
#ifdef __CHECK_POLL
typedef unsigned __bitwise __poll_t;
#else
typedef unsigned __poll_t;
#endif
#endif /* __ASSEMBLY__ */
#endif /* _UAPI_LINUX_TYPES_H */