lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20150308013320.GG29656@ZenIV.linux.org.uk>
Date:	Sun, 8 Mar 2015 01:33:20 +0000
From:	Al Viro <viro@...IV.linux.org.uk>
To:	Linus Torvalds <torvalds@...ux-foundation.org>
Cc:	Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [RFC] ->poll() bugs

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@...iv.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).
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ