public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
From: Eric Dumazet <eric.dumazet@gmail•com>
To: "David S . Miller" <davem@davemloft•net>,
	Jakub Kicinski <kuba@kernel•org>
Cc: netdev <netdev@vger•kernel.org>,
	Eric Dumazet <edumazet@google•com>,
	Eric Dumazet <eric.dumazet@gmail•com>,
	Vivien Didelot <vivien.didelot@gmail•com>,
	Nikolay Aleksandrov <nikolay@nvidia•com>
Subject: [PATCH net 2/2] net: bridge: fix under estimation in br_get_linkxstats_size()
Date: Mon,  4 Oct 2021 18:05:08 -0700	[thread overview]
Message-ID: <20211005010508.2194560-3-eric.dumazet@gmail.com> (raw)
In-Reply-To: <20211005010508.2194560-1-eric.dumazet@gmail.com>

From: Eric Dumazet <edumazet@google•com>

Commit de1799667b00 ("net: bridge: add STP xstats")
added an additional nla_reserve_64bit() in br_fill_linkxstats(),
but forgot to update br_get_linkxstats_size() accordingly.

This can trigger the following in rtnl_stats_get()

	WARN_ON(err == -EMSGSIZE);

Fixes: de1799667b00 ("net: bridge: add STP xstats")
Signed-off-by: Eric Dumazet <edumazet@google•com>
Cc: Vivien Didelot <vivien.didelot@gmail•com>
Cc: Nikolay Aleksandrov <nikolay@nvidia•com>
---
 net/bridge/br_netlink.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/net/bridge/br_netlink.c b/net/bridge/br_netlink.c
index 29b8f6373fb925d48ce876dcda7fccc10539240a..5c6c4305ed235891b2ed5c5a17eb8382f2aec1a0 100644
--- a/net/bridge/br_netlink.c
+++ b/net/bridge/br_netlink.c
@@ -1667,6 +1667,7 @@ static size_t br_get_linkxstats_size(const struct net_device *dev, int attr)
 
 	return numvls * nla_total_size(sizeof(struct bridge_vlan_xstats)) +
 	       nla_total_size_64bit(sizeof(struct br_mcast_stats)) +
+	       (p ? nla_total_size_64bit(sizeof(p->stp_xstats)) : 0) +
 	       nla_total_size(0);
 }
 
-- 
2.33.0.800.g4c38ced690-goog


  parent reply	other threads:[~2021-10-05  1:05 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-05  1:05 [PATCH net 0/2] net: bridge: br_get_linkxstats_size() fixes Eric Dumazet
2021-10-05  1:05 ` [PATCH net 1/2] net: bridge: use nla_total_size_64bit() in br_get_linkxstats_size() Eric Dumazet
2021-10-05  9:03   ` Nikolay Aleksandrov
2021-10-05  1:05 ` Eric Dumazet [this message]
2021-10-05  9:04   ` [PATCH net 2/2] net: bridge: fix under estimation " Nikolay Aleksandrov
2021-10-05 11:50 ` [PATCH net 0/2] net: bridge: br_get_linkxstats_size() fixes patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211005010508.2194560-3-eric.dumazet@gmail.com \
    --to=eric.dumazet@gmail$(echo .)com \
    --cc=davem@davemloft$(echo .)net \
    --cc=edumazet@google$(echo .)com \
    --cc=kuba@kernel$(echo .)org \
    --cc=netdev@vger$(echo .)kernel.org \
    --cc=nikolay@nvidia$(echo .)com \
    --cc=vivien.didelot@gmail$(echo .)com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox