]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
netlink: not trim skb for mmaped socket when dump
authorKen-ichirou MATSUZAWA <chamaken@gmail.com>
Fri, 29 Jan 2016 01:45:50 +0000 (10:45 +0900)
committerLuis Henriques <luis.henriques@canonical.com>
Thu, 25 Feb 2016 10:50:59 +0000 (10:50 +0000)
commit aa3a022094fac7f6e48050e139fa8a5a2e3265ce upstream.

We should not trim skb for mmaped socket since its buf size is fixed
and userspace will read as frame which data equals head. mmaped
socket will not call recvmsg, means max_recvmsg_len is 0,
skb_reserve was not called before commit: db65a3aaf29e.

Fixes: db65a3aaf29e (netlink: Trim skb to alloc size to avoid MSG_TRUNC)
Signed-off-by: Ken-ichirou MATSUZAWA <chamas@h4.dion.ne.jp>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
net/netlink/af_netlink.c

index 7e1ac5b5de0a67f1ab3b700e0feab7e92d0f1cac..46cac8e31a16cf335860897fc552ad11870927e0 100644 (file)
@@ -2740,7 +2740,8 @@ static int netlink_dump(struct sock *sk)
         * reasonable static buffer based on the expected largest dump of a
         * single netdev. The outcome is MSG_TRUNC error.
         */
-       skb_reserve(skb, skb_tailroom(skb) - alloc_size);
+       if (!netlink_rx_is_mmaped(sk))
+               skb_reserve(skb, skb_tailroom(skb) - alloc_size);
        netlink_skb_set_owner_r(skb, sk);
 
        len = cb->dump(skb, cb);