diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2014-12-12 23:02:36 -0500 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2015-02-04 01:34:13 -0500 |
commit | a8866ff6a5bce7d0ec465a63bc482a85c09b0d39 (patch) | |
tree | ba7534a7245d5230860564bb1e936a22a1c97e0c /net/netlink/af_netlink.c | |
parent | 4c72c53be5e3c8cf319a020ea671ab0fc32ec96f (diff) |
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>
Diffstat (limited to 'net/netlink/af_netlink.c')
-rw-r--r-- | net/netlink/af_netlink.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c index a36777b7cfb6..4fd38a612ff6 100644 --- a/net/netlink/af_netlink.c +++ b/net/netlink/af_netlink.c | |||
@@ -2298,7 +2298,12 @@ static int netlink_sendmsg(struct kiocb *kiocb, struct socket *sock, | |||
2298 | goto out; | 2298 | goto out; |
2299 | } | 2299 | } |
2300 | 2300 | ||
2301 | /* It's a really convoluted way for userland to ask for mmaped | ||
2302 | * sendmsg(), but that's what we've got... | ||
2303 | */ | ||
2301 | if (netlink_tx_is_mmaped(sk) && | 2304 | if (netlink_tx_is_mmaped(sk) && |
2305 | msg->msg_iter.type == ITER_IOVEC && | ||
2306 | msg->msg_iter.nr_segs == 1 && | ||
2302 | msg->msg_iter.iov->iov_base == NULL) { | 2307 | msg->msg_iter.iov->iov_base == NULL) { |
2303 | err = netlink_mmap_sendmsg(sk, msg, dst_portid, dst_group, | 2308 | err = netlink_mmap_sendmsg(sk, msg, dst_portid, dst_group, |
2304 | &scm); | 2309 | &scm); |