All of lore.kernel.org
 help / color / mirror / Atom feed
From: Subash Abhinov Kasiviswanathan <subashab@codeaurora.org>
To: David Miller <davem@davemloft.net>
Cc: netdev@vger.kernel.org, fengguang.wu@intel.com, dcbw@redhat.com,
	jiri@resnulli.us, stephen@networkplumber.org,
	David.Laight@aculab.com, marcel@holtmann.org
Subject: Re: [PATCH net-next 3/3 v7] drivers: net: ethernet: qualcomm: rmnet: Initial implementation
Date: Thu, 24 Aug 2017 16:45:30 -0600	[thread overview]
Message-ID: <0a82b4c5349c3201c58a13f90b5ea758@codeaurora.org> (raw)
In-Reply-To: <20170824.121559.882635807428126397.davem@davemloft.net>

>> +
>> +CFLAGS_rmnet.o := -I$(src)
> 
> You do not need this CFLAGS rule, the local include files are included
> using "" double quotes so it uses the local directory always.

Hi David

I'll remove this.

>> +static void rmnet_free_later(struct work_struct *work)
>> +{
>> +	struct rmnet_free_work *fwork;
>> +
>> +	fwork = container_of(work, struct rmnet_free_work, work);
>> +
>> +	rtnl_lock();
>> +	rmnet_delink(fwork->rmnet_dev, NULL);
>> +	rtnl_unlock();
>> +
>> +	kfree(fwork);
>> +}
> 
> This is racy and doesn't work properly.
> 
> When you schedule this work, the RTNL mutex is dropped.  Meanwhile
> another request can come in the associate this device.
> 
> Your work function will still run and erroneously unlink the object.
> 
> Furthermore, during this time that the RTNL mutex is dropped, people
> will see the unassociated device in the lists.
> 
> You have to atomically remove the object from all possible locations
> which provide external visibility of that object, before the RTNL
> mutex is dropped.
> 
> So you can defer the freeing, but you cannot defer the unlink
> operation.

I had incorrectly assumed earlier that the check in rtnl_newlink for
NLM_F_EXCL would guard against the scenario of re-associating a
device which was unlinked.

> 
> You probably need to move to RCU as well in order for all of this to
> work properly since scans of the lists occur in the data path which
> is completely asynchronous and not protected by the RTNL mutex.

I'll remove all the rtnl locks and checks and switch to rcu and post
an update.

      reply	other threads:[~2017-08-24 22:45 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-21 22:36 [PATCH net-next 0/3 v7] Add support for rmnet driver Subash Abhinov Kasiviswanathan
2017-08-21 22:36 ` [PATCH net-next 1/3 v7] net: ether: Add support for multiplexing and aggregation type Subash Abhinov Kasiviswanathan
2017-08-22  1:02   ` Andrew Lunn
2017-08-22  5:27     ` Subash Abhinov Kasiviswanathan
2017-08-21 22:36 ` [PATCH net-next 2/3 v7] net: arp: Add support for raw IP device Subash Abhinov Kasiviswanathan
2017-08-21 22:36 ` [PATCH net-next 3/3 v7] drivers: net: ethernet: qualcomm: rmnet: Initial implementation Subash Abhinov Kasiviswanathan
2017-08-22  1:17   ` Andrew Lunn
2017-08-24 19:15   ` David Miller
2017-08-24 22:45     ` Subash Abhinov Kasiviswanathan [this message]

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=0a82b4c5349c3201c58a13f90b5ea758@codeaurora.org \
    --to=subashab@codeaurora.org \
    --cc=David.Laight@aculab.com \
    --cc=davem@davemloft.net \
    --cc=dcbw@redhat.com \
    --cc=fengguang.wu@intel.com \
    --cc=jiri@resnulli.us \
    --cc=marcel@holtmann.org \
    --cc=netdev@vger.kernel.org \
    --cc=stephen@networkplumber.org \
    /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.