All of lore.kernel.org
 help / color / mirror / Atom feed
From: Michal Kubecek <mkubecek@suse.cz>
To: David Miller <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>,
	netdev@vger.kernel.org
Cc: Jiri Pirko <jiri@resnulli.us>, Andrew Lunn <andrew@lunn.ch>,
	Florian Fainelli <f.fainelli@gmail.com>,
	John Linville <linville@tuxdriver.com>,
	Johannes Berg <johannes@sipsolutions.net>,
	Richard Cochran <richardcochran@gmail.com>,
	linux-kernel@vger.kernel.org
Subject: [PATCH net-next v3 01/12] ethtool: fix reference leak in ethnl_set_privflags()
Date: Sat, 28 Mar 2020 00:01:03 +0100 (CET)	[thread overview]
Message-ID: <1ae600976e0b11c556d35224da395b68700d91e6.1585349448.git.mkubecek@suse.cz> (raw)
In-Reply-To: <cover.1585349448.git.mkubecek@suse.cz>

Andrew noticed that some handlers for *_SET commands leak a netdev
reference if required ethtool_ops callbacks do not exist. One of them is
ethnl_set_privflags(), a simple reproducer would be e.g.

  ip link add veth1 type veth peer name veth2
  ethtool --set-priv-flags veth1 foo on
  ip link del veth1

Make sure dev_put() is called when ethtool_ops check fails.

Fixes: f265d799596a ("ethtool: set device private flags with PRIVFLAGS_SET request")
Reported-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
---
 net/ethtool/privflags.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/net/ethtool/privflags.c b/net/ethtool/privflags.c
index e8f03b33db9b..77447dceb109 100644
--- a/net/ethtool/privflags.c
+++ b/net/ethtool/privflags.c
@@ -175,9 +175,10 @@ int ethnl_set_privflags(struct sk_buff *skb, struct genl_info *info)
 		return ret;
 	dev = req_info.dev;
 	ops = dev->ethtool_ops;
+	ret = -EOPNOTSUPP;
 	if (!ops->get_priv_flags || !ops->set_priv_flags ||
 	    !ops->get_sset_count || !ops->get_strings)
-		return -EOPNOTSUPP;
+		goto out_dev;
 
 	rtnl_lock();
 	ret = ethnl_ops_begin(dev);
@@ -204,6 +205,7 @@ int ethnl_set_privflags(struct sk_buff *skb, struct genl_info *info)
 	ethnl_ops_complete(dev);
 out_rtnl:
 	rtnl_unlock();
+out_dev:
 	dev_put(dev);
 	return ret;
 }
-- 
2.25.1


  reply	other threads:[~2020-03-27 23:01 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-27 23:00 [PATCH net-next v3 00/12] ethtool netlink interface, part 4 Michal Kubecek
2020-03-27 23:01 ` Michal Kubecek [this message]
2020-03-27 23:01 ` [PATCH net-next v3 02/12] ethtool: provide coalescing parameters with COALESCE_GET request Michal Kubecek
2020-03-27 23:01 ` [PATCH net-next v3 03/12] ethtool: set coalescing parameters with COALESCE_SET request Michal Kubecek
2020-03-27 23:01 ` [PATCH net-next v3 04/12] ethtool: add COALESCE_NTF notification Michal Kubecek
2020-03-27 23:01 ` [PATCH net-next v3 05/12] ethtool: provide pause parameters with PAUSE_GET request Michal Kubecek
2020-03-27 23:01 ` [PATCH net-next v3 06/12] ethtool: set pause parameters with PAUSE_SET request Michal Kubecek
2020-03-27 23:01 ` [PATCH net-next v3 07/12] ethtool: add PAUSE_NTF notification Michal Kubecek
2020-03-27 23:01 ` [PATCH net-next v3 08/12] ethtool: provide EEE settings with EEE_GET request Michal Kubecek
2020-03-27 23:01 ` [PATCH net-next v3 09/12] ethtool: set EEE settings with EEE_SET request Michal Kubecek
2020-03-27 23:01 ` [PATCH net-next v3 10/12] ethtool: add EEE_NTF notification Michal Kubecek
2020-03-27 23:01 ` [PATCH net-next v3 11/12] ethtool: add timestamping related string sets Michal Kubecek
2020-03-27 23:01 ` [PATCH net-next v3 12/12] ethtool: provide timestamping information with TSINFO_GET request Michal Kubecek
2020-03-28 10:08 ` [PATCH net-next v3 00/12] ethtool netlink interface, part 4 Jiri Pirko
2020-03-30  5:33 ` David Miller

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=1ae600976e0b11c556d35224da395b68700d91e6.1585349448.git.mkubecek@suse.cz \
    --to=mkubecek@suse.cz \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=f.fainelli@gmail.com \
    --cc=jiri@resnulli.us \
    --cc=johannes@sipsolutions.net \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linville@tuxdriver.com \
    --cc=netdev@vger.kernel.org \
    --cc=richardcochran@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.