mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Eric Dumazet <eric.dumazet@gmail.com>
To: Ziyang Xuan <william.xuanziyang@huawei.com>,
	davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com,
	netdev@vger.kernel.org
Cc: edumazet@google.com, brianvv@google.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next v3 2/3] net: ipvlan: add net device refcount tracker
Date: Tue, 22 Mar 2022 07:01:01 -0700	[thread overview]
Message-ID: <55b5d052-7171-0da8-0dcd-38b107f52f52@gmail.com> (raw)
In-Reply-To: <185e45470629ad7a0aeef7a61b608d5cf13fcbf3.1647664114.git.william.xuanziyang@huawei.com>


On 3/19/22 02:53, Ziyang Xuan wrote:
> Add net device refcount tracker to ipvlan.


Just squash this to prior patch.


Ideally all new dev_hold()/dev_put() should be

dev_hold_track() and dev_put_track()


> Signed-off-by: Ziyang Xuan <william.xuanziyang@huawei.com>
> ---
>   drivers/net/ipvlan/ipvlan.h      | 1 +
>   drivers/net/ipvlan/ipvlan_main.c | 4 ++--
>   2 files changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/ipvlan/ipvlan.h b/drivers/net/ipvlan/ipvlan.h
> index 3837c897832e..6605199305b7 100644
> --- a/drivers/net/ipvlan/ipvlan.h
> +++ b/drivers/net/ipvlan/ipvlan.h
> @@ -64,6 +64,7 @@ struct ipvl_dev {
>   	struct list_head	pnode;
>   	struct ipvl_port	*port;
>   	struct net_device	*phy_dev;
> +	netdevice_tracker	dev_tracker;
>   	struct list_head	addrs;
>   	struct ipvl_pcpu_stats	__percpu *pcpu_stats;
>   	DECLARE_BITMAP(mac_filters, IPVLAN_MAC_FILTER_SIZE);
> diff --git a/drivers/net/ipvlan/ipvlan_main.c b/drivers/net/ipvlan/ipvlan_main.c
> index dcdc01403f22..be06f122092e 100644
> --- a/drivers/net/ipvlan/ipvlan_main.c
> +++ b/drivers/net/ipvlan/ipvlan_main.c
> @@ -160,7 +160,7 @@ static int ipvlan_init(struct net_device *dev)
>   	port->count += 1;
>   
>   	/* Get ipvlan's reference to phy_dev */
> -	dev_hold(phy_dev);
> +	dev_hold_track(phy_dev, &ipvlan->dev_tracker, GFP_KERNEL);
>   
>   	return 0;
>   }
> @@ -674,7 +674,7 @@ static void ipvlan_dev_free(struct net_device *dev)
>   	struct ipvl_dev *ipvlan = netdev_priv(dev);
>   
>   	/* Get rid of the ipvlan's reference to phy_dev */
> -	dev_put(ipvlan->phy_dev);
> +	dev_put_track(ipvlan->phy_dev, &ipvlan->dev_tracker);
>   }
>   
>   void ipvlan_link_setup(struct net_device *dev)

  reply	other threads:[~2022-03-22 14:01 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-19  9:52 [PATCH net-next v3 0/3] net: ipvlan: fix potential UAF problem for phy_dev Ziyang Xuan
2022-03-19  9:52 ` [PATCH net-next v3 1/3] " Ziyang Xuan
2022-03-22 14:03   ` Eric Dumazet
2022-03-19  9:53 ` [PATCH net-next v3 2/3] net: ipvlan: add net device refcount tracker Ziyang Xuan
2022-03-22 14:01   ` Eric Dumazet [this message]
2022-03-19  9:53 ` [PATCH net-next v3 3/3] net: ipvtap: fix error comments Ziyang Xuan
2022-03-22  9:15 ` [PATCH net-next v3 0/3] net: ipvlan: fix potential UAF problem for phy_dev Paolo Abeni

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=55b5d052-7171-0da8-0dcd-38b107f52f52@gmail.com \
    --to=eric.dumazet@gmail.com \
    --cc=brianvv@google.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=william.xuanziyang@huawei.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®