From: Al Viro <viro@ZenIV.linux.org.uk>
To: David Miller <davem@davemloft.net>
Cc: kaber@trash.net, netdev@vger.kernel.org,
Dmitry Tarnyagin <dmitry.tarnyagin@lockless.no>
Subject: Re: [WTF?] random test in netlink_sendmsg()
Date: Sat, 13 Dec 2014 04:51:33 +0000 [thread overview]
Message-ID: <20141213045133.GI22149@ZenIV.linux.org.uk> (raw)
In-Reply-To: <20141213032500.GH22149@ZenIV.linux.org.uk>
On Sat, Dec 13, 2014 at 03:25:00AM +0000, Al Viro wrote:
> msg->msg_iter.type == KVEC_ITER &&
ITER_IOVEC, that is. And that way it even works... Are you OK with the
commit below?
netlink: make the check for "send from tx_ring" deterministic
As it is, zero msg_iovlen means that the first iovec in the kernel
array of iovecs is left uninitialized, so checking if its ->iov_base
is NULL is random. Since the real users of that thing are doing
sendto(fd, NULL, 0, ...), they are getting msg_iovlen = 1 and
msg_iov[0] = {NULL, 0}, which is what this test is trying to catch.
As suggested by davem, let's just check that msg_iovlen was 1 and
msg_iov[0].iov_base was NULL - _that_ is well-defined and it catches
what we want to catch.
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
---
diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
index cc9bcf0..5bcb58c 100644
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -2304,7 +2304,11 @@ static int netlink_sendmsg(struct kiocb *kiocb, struct socket *sock,
goto out;
}
+ /* It's a really convoluted way for userland to ask for mmaped
+ * sendmsg(), but that's what we've got... */
if (netlink_tx_is_mmaped(sk) &&
+ msg->msg_iter.type == ITER_IOVEC &&
+ msg->msg_iter.nr_segs == 1 &&
msg->msg_iter.iov->iov_base == NULL) {
err = netlink_mmap_sendmsg(sk, msg, dst_portid, dst_group,
siocb);
next prev parent reply other threads:[~2014-12-13 4:51 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-28 6:23 [WTF?] random test in netlink_sendmsg() Al Viro
2014-12-12 20:34 ` David Miller
2014-12-12 21:32 ` Al Viro
2014-12-12 21:50 ` Florian Westphal
2014-12-12 22:14 ` Al Viro
2014-12-12 22:20 ` Florian Westphal
2014-12-13 1:07 ` David Miller
2014-12-13 1:54 ` Al Viro
2014-12-13 2:33 ` David Miller
2014-12-13 3:25 ` Al Viro
2014-12-13 4:51 ` Al Viro [this message]
2014-12-14 4:38 ` David Miller
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=20141213045133.GI22149@ZenIV.linux.org.uk \
--to=viro@zeniv.linux.org.uk \
--cc=davem@davemloft.net \
--cc=dmitry.tarnyagin@lockless.no \
--cc=kaber@trash.net \
--cc=netdev@vger.kernel.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;
as well as URLs for NNTP newsgroup(s).