Skip to content

Commit d343679

Browse files
edumazetdavem330
authored andcommitted
rtnetlink: fix if_nlmsg_stats_size() under estimation
rtnl_fill_statsinfo() is filling skb with one mandatory if_stats_msg structure. nlmsg_put(skb, pid, seq, type, sizeof(struct if_stats_msg), flags); But if_nlmsg_stats_size() never considered the needed storage. This bug did not show up because alloc_skb(X) allocates skb with extra tailroom, because of added alignments. This could very well be changed in the future to have deterministic behavior. Fixes: 10c9ead ("rtnetlink: add new RTM_GETSTATS message to dump link stats") Signed-off-by: Eric Dumazet <[email protected]> Cc: Roopa Prabhu <[email protected]> Acked-by: Roopa Prabhu <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent d4b111f commit d343679

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

net/core/rtnetlink.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5262,7 +5262,7 @@ static int rtnl_fill_statsinfo(struct sk_buff *skb, struct net_device *dev,
52625262
static size_t if_nlmsg_stats_size(const struct net_device *dev,
52635263
u32 filter_mask)
52645264
{
5265-
size_t size = 0;
5265+
size_t size = NLMSG_ALIGN(sizeof(struct if_stats_msg));
52665266

52675267
if (stats_attr_valid(filter_mask, IFLA_STATS_LINK_64, 0))
52685268
size += nla_total_size_64bit(sizeof(struct rtnl_link_stats64));

0 commit comments

Comments
 (0)