From: Al Viro <viro@ZenIV.linux.org.uk>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [RFC] ->poll() bugs
Date: Sun, 8 Mar 2015 01:33:20 +0000 [thread overview]
Message-ID: <20150308013320.GG29656@ZenIV.linux.org.uk> (raw)
In-Reply-To: <CA+55aFw0Le2=XfpwagPz6YMHMSncCwpThFx9hFaxhD+i5fEfkw@mail.gmail.com>
On Sat, Mar 07, 2015 at 12:53:14PM -0800, Linus Torvalds wrote:
> On Sat, Mar 7, 2015 at 12:44 PM, Al Viro <viro@zeniv.linux.org.uk> wrote:
> >
> > Most of the catch consists of ->poll() instances that return -E...; there's
> > also an unpleasant mess in net/9p/trans_fd.c and a braino in sunrpc
> > unexpectedly caught by the same annotations.
>
> Hmm. I do wonder if we should just *allow* ->poll() to return an
> error, and just turn it into "all bits set"?
Doable, but... we do have a bunch of ->poll() call sites (AFAICS, right
now it's
drivers/staging/comedi/drivers/serial2002.c:142:
drivers/vfio/pci/vfio_pci_intrs.c:191:
drivers/vhost/vhost.c:95:
fs/eventpoll.c:800:
fs/proc/inode.c:229:
fs/select.c:461:
fs/select.c:764:
mm/memcontrol.c:4285:
net/9p/trans_fd.c:249:
net/9p/trans_fd.c:254:
virt/kvm/eventfd.c:418:
) and while they could be turned into calls of a wrapper, I really don't
like returning negatives as a part of ->poll() calling conventions. I mean,
really - "you should return a bitmap of POLL... flags *or* -E...; doesn't
matter which error number it is, it'll be lost anyway"... It's OK to have the
caller(s) catch such bugs (and report them, IMO), but silently treating it
that way as a part of calling conventions...
Besides, that doesn't catch the bugs like one in net/9p; sparse annotations do.
> But if getting sparse to catch them all isn't *too* painful and the
> patch doesn't end up being horribly big, then I guess that's ok.
Getting sparse to catch them all is as trivial as
* introduce a __bitwise typedef __poll_t => unsigned int
* say that ->poll() (in file_operations, as well as in proto_ops,
tty_ldisc_ops and several in other subsystems) returns __poll_t
* switch the return type of instances from unsigned int to __poll_t
* do the same to local variable(s) (if any) used to hold the return
value to be.
Again, from cc(1) POV it's a no-op - unannotated foo_poll() will be just
fine as it is. The only place where I did something more fancy than
such type change actually had been buggy -
drivers/media/common/siano/smsdvb-debugfs.c:smsdvb_stats_poll() relied
upon smsdvb_stats_wait_read() never returning negatives and it needs
s/__poll_t rc/& = 0/ for correctness (fixed and folded).
prev parent reply other threads:[~2015-03-08 1:33 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-05 15:49 [RFC] ->poll() bugs Al Viro
2015-03-05 15:58 ` Al Viro
2015-03-07 20:44 ` Al Viro
2015-03-07 20:53 ` Linus Torvalds
2015-03-07 21:03 ` Al Viro
2015-03-07 21:08 ` [PATCH] sunrpc: fix braino in ->poll() Al Viro
2015-03-09 19:41 ` J. Bruce Fields
2015-03-08 1:33 ` Al Viro [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150308013320.GG29656@ZenIV.linux.org.uk \
--to=viro@zeniv.linux.org.uk \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox