[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CANn89i+NfBw7ZpL-DTDA3QGBK=neT2R7qKYn_pcvDmRAOkaUsQ@mail.gmail.com>
Date: Thu, 7 Jan 2021 12:18:28 +0100
From: Eric Dumazet <edumazet@...gle.com>
To: Vladimir Oltean <olteanv@...il.com>
Cc: "David S . Miller" <davem@...emloft.net>,
Jakub Kicinski <kuba@...nel.org>,
netdev <netdev@...r.kernel.org>, Andrew Lunn <andrew@...n.ch>,
Florian Fainelli <f.fainelli@...il.com>,
Cong Wang <xiyou.wangcong@...il.com>,
Stephen Hemminger <stephen@...workplumber.org>,
George McCollister <george.mccollister@...il.com>,
Oleksij Rempel <o.rempel@...gutronix.de>,
Jay Vosburgh <j.vosburgh@...il.com>,
Veaceslav Falico <vfalico@...il.com>,
Andy Gospodarek <andy@...yhouse.net>,
Arnd Bergmann <arnd@...db.de>, Taehee Yoo <ap420073@...il.com>,
Jiri Pirko <jiri@...lanox.com>, Florian Westphal <fw@...len.de>
Subject: Re: [PATCH v3 net-next 10/12] net: bonding: ensure .ndo_get_stats64
can sleep
On Thu, Jan 7, 2021 at 10:51 AM Vladimir Oltean <olteanv@...il.com> wrote:
>
> From: Vladimir Oltean <vladimir.oltean@....com>
>
>
-
> static void bond_get_stats(struct net_device *bond_dev,
> struct rtnl_link_stats64 *stats)
> {
> struct bonding *bond = netdev_priv(bond_dev);
> - struct rtnl_link_stats64 temp;
> - struct list_head *iter;
> - struct slave *slave;
> - int nest_level = 0;
> + struct rtnl_link_stats64 *dev_stats;
> + struct net_device **slaves;
> + int i, res, num_slaves;
>
> + res = bond_get_slave_arr(bond, &slaves, &num_slaves);
> + if (res) {
> + netdev_err(bond->dev,
> + "failed to allocate memory for slave array\n");
> + return;
> + }
>
What a mess really.
You chose to keep the assumption that ndo_get_stats() would not fail,
since we were providing the needed storage from callers.
If ndo_get_stats() are now allowed to sleep, and presumably allocate
memory, we need to make sure
we report potential errors back to the user.
I think your patch series is mostly good, but I would prefer not
hiding errors and always report them to user space.
And no, netdev_err() is not appropriate, we do not want tools to look
at syslog to guess something went wrong.
Last point about drivers having to go to slow path, talking to
firmware : Make sure that malicious/innocent users
reading /proc/net/dev from many threads in parallel wont brick these devices.
Maybe they implicitly _relied_ on the fact that firmware was gently
read every second and results were cached from a work queue or
something.
Thanks.
Powered by blists - more mailing lists