Skip to contentSkip to conversation

netlink: not trim skb for mmaped socket when dump

PATCH Applied Ken-ichirou MATSUZAWA 2 participants 2 messages Jan 29, 2016 – Jan 30, 2016

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 netlink: not trim skb for mmaped socket when dump

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)
---
 net/netlink/af_netlink.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
net/netlink/af_netlink.c +2 -1
index 81dc1bb..f1ffb34 100644
@@ -2831,7 +2831,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);
Signature · 1 line
1.7.10.4
maintainer Applied
#1 lore raw

From: Ken-ichirou MATSUZAWA <[email protected]>
Date: Fri, 29 Jan 2016 10:45:50 +0900

Quoted 7 lines

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)

Applied, thank you.