* [PATCH net] rtnetlink: fix if_nlmsg_stats_size() under estimation
@ 2021-10-05 21:04 Eric Dumazet
2021-10-05 22:08 ` Roopa Prabhu
2021-10-06 14:20 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 3+ messages in thread
From: Eric Dumazet @ 2021-10-05 21:04 UTC (permalink / raw)
To: David S . Miller, Jakub Kicinski
Cc: netdev, Eric Dumazet, Eric Dumazet, Roopa Prabhu
From: Eric Dumazet <edumazet@google.com>
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: 10c9ead9f3c6 ("rtnetlink: add new RTM_GETSTATS message to dump link stats")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Roopa Prabhu <roopa@nvidia.com>
---
net/core/rtnetlink.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index 972c8cb303a514758278307cd9fcb974e37f2b96..8ccce85562a1da2a5285aebd19a6a4cb7d6a163e 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -5262,7 +5262,7 @@ static int rtnl_fill_statsinfo(struct sk_buff *skb, struct net_device *dev,
static size_t if_nlmsg_stats_size(const struct net_device *dev,
u32 filter_mask)
{
- size_t size = 0;
+ size_t size = NLMSG_ALIGN(sizeof(struct if_stats_msg));
if (stats_attr_valid(filter_mask, IFLA_STATS_LINK_64, 0))
size += nla_total_size_64bit(sizeof(struct rtnl_link_stats64));
--
2.33.0.800.g4c38ced690-goog
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH net] rtnetlink: fix if_nlmsg_stats_size() under estimation
2021-10-05 21:04 [PATCH net] rtnetlink: fix if_nlmsg_stats_size() under estimation Eric Dumazet
@ 2021-10-05 22:08 ` Roopa Prabhu
2021-10-06 14:20 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: Roopa Prabhu @ 2021-10-05 22:08 UTC (permalink / raw)
To: Eric Dumazet, David S . Miller, Jakub Kicinski; +Cc: netdev, Eric Dumazet
On 10/5/21 2:04 PM, Eric Dumazet wrote:
> From: Eric Dumazet <edumazet@google.com>
>
> 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: 10c9ead9f3c6 ("rtnetlink: add new RTM_GETSTATS message to dump link stats")
> Signed-off-by: Eric Dumazet <edumazet@google.com>
> Cc: Roopa Prabhu <roopa@nvidia.com>
> ---
Acked-by: Roopa Prabhu <roopa@nvidia.com>
don't know how i missed this. Thanks for the patch Eric.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net] rtnetlink: fix if_nlmsg_stats_size() under estimation
2021-10-05 21:04 [PATCH net] rtnetlink: fix if_nlmsg_stats_size() under estimation Eric Dumazet
2021-10-05 22:08 ` Roopa Prabhu
@ 2021-10-06 14:20 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-10-06 14:20 UTC (permalink / raw)
To: Eric Dumazet; +Cc: davem, kuba, netdev, edumazet, roopa
Hello:
This patch was applied to netdev/net.git (refs/heads/master):
On Tue, 5 Oct 2021 14:04:17 -0700 you wrote:
> From: Eric Dumazet <edumazet@google.com>
>
> 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.
>
> [...]
Here is the summary with links:
- [net] rtnetlink: fix if_nlmsg_stats_size() under estimation
https://git.kernel.org/netdev/net/c/d34367991933
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-10-06 14:20 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-05 21:04 [PATCH net] rtnetlink: fix if_nlmsg_stats_size() under estimation Eric Dumazet
2021-10-05 22:08 ` Roopa Prabhu
2021-10-06 14:20 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).