Skip to content

Commit aa3a022

Browse files
chamakendavem330
authored andcommitted
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: db65a3a. Fixes: db65a3a (netlink: Trim skb to alloc size to avoid MSG_TRUNC) Signed-off-by: Ken-ichirou MATSUZAWA <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 7256eac commit aa3a022

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

net/netlink/af_netlink.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2831,7 +2831,8 @@ static int netlink_dump(struct sock *sk)
28312831
* reasonable static buffer based on the expected largest dump of a
28322832
* single netdev. The outcome is MSG_TRUNC error.
28332833
*/
2834-
skb_reserve(skb, skb_tailroom(skb) - alloc_size);
2834+
if (!netlink_rx_is_mmaped(sk))
2835+
skb_reserve(skb, skb_tailroom(skb) - alloc_size);
28352836
netlink_skb_set_owner_r(skb, sk);
28362837

28372838
len = cb->dump(skb, cb);

0 commit comments

Comments
 (0)