linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Johannes Berg <johannes@sipsolutions.net>
To: Yogesh Powar <yogeshp@marvell.com>
Cc: "linux-wireless@vger.kernel.org" <linux-wireless@vger.kernel.org>,
	"John W. Linville" <linville@tuxdriver.com>,
	Andreas Hartmann <andihartmann@01019freenet.de>
Subject: RE: [PATCH 2/2] mac80211: Fixing Races for skipping tailroom reservation
Date: Mon, 20 Jun 2011 19:29:40 +0200	[thread overview]
Message-ID: <1308590980.4322.19.camel@jlt3.sipsolutions.net> (raw)
In-Reply-To: <7DDF37406E10F0438561DBB78326DF3902F5D190E2@SC-VEXCH1.marvell.com>

On Mon, 2011-06-20 at 09:49 -0700, Yogesh Powar wrote:
> >No, they're not, the mutex trickery seems completely pointless, and the
> >conditional (on _is_locked no less) locking is horrible.
> Ok.
> 
> Will spend some more time on exploring solutions using rcu primitives only
> (synchronize_net or something similar).
> 
> If nothing  of only-RCU is feasible then, I think, we need to resize the skb if it has
> already skipped the tailroom instead of WARN_ON. This will come in to picuture
> only during the race cases. But this wont get rid of race.

Ahrg, seriously, just analyse the situation for once. Do I really need
to do that?

There are two race cases, during transitions:
 1) need to resize -> no need to (key moved to HW)
 2) no need to resize -> need to (new key, ...)

The first is uninteresting, it's fine if the race happens and the skb is
still resized even if it didn't need to.

The second one is what's causing issues. But the race happens like this:
  - counter is 0
	- skb goes through tx start, no tailroom allocated
  - key added, counter > 0
	- key lookup while TX processing is successful

So ... how can you solve it? Clearly, the locking attempts you made were
pretty useless. But now that we understand the race, can we fix it? I
think we can, by doing something like this:

	counter++;
	/* flush packets being processed */
	synchronize_net();
	/* do whatever causes the key to be found by sw crypto */

That should be it. The only overhead is a little bit in control paths
for key settings which are delayed a bit by synchronize_net(), but who
cares, we don't change keys every packet.

Of course you need to encapsulate that code into a small function and
write comments about why it's necessary and how it works.

Was that so hard? :-)

johannes


  reply	other threads:[~2011-06-20 17:29 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-16 10:21 [PATCH 0/2] mac80211: Fixing races for hw crypto skipping tailroom Yogesh Ashok Powar
2011-06-16 10:25 ` [PATCH 1/2] Revert "Revert "mac80211: Skip tailroom reservation for full HW-crypto devices"" Yogesh Ashok Powar
2011-06-16 10:27 ` [PATCH 2/2] mac80211: Fixing Races for skipping tailroom reservation Yogesh Ashok Powar
2011-06-16 15:36   ` Johannes Berg
2011-06-17 13:25     ` Yogesh Ashok Powar
2011-06-17 17:24       ` Johannes Berg
2011-06-20 14:30         ` Yogesh Ashok Powar
2011-06-20 15:29           ` Johannes Berg
2011-06-20 16:49             ` Yogesh Powar
2011-06-20 17:29               ` Johannes Berg [this message]
2011-06-21 13:03                 ` Yogesh Ashok Powar
2011-06-21 13:43                   ` Johannes Berg
2011-06-21 14:10                     ` Yogesh Ashok Powar
2011-06-21 14:40                       ` Johannes Berg
2011-06-21 16:33                         ` Yogesh Ashok Powar
2011-06-21 17:44                           ` Andreas Hartmann
2011-06-22  7:17                           ` Yogesh Ashok Powar
2011-06-22 12:31                             ` Yogesh Ashok Powar
2011-06-22 12:49                               ` Johannes Berg
2011-06-22 12:58                                 ` Yogesh Ashok Powar
2011-06-22 13:12                                   ` Johannes Berg
2011-06-23 11:52                                     ` Yogesh Powar
2011-06-24  9:04                                     ` yogeshp
2011-06-25 13:07                                       ` Johannes Berg
2011-06-27  6:02                                         ` [PATCH] nl80211: use netlink consistent dump feature for BSS dumps Walter Goldens

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=1308590980.4322.19.camel@jlt3.sipsolutions.net \
    --to=johannes@sipsolutions.net \
    --cc=andihartmann@01019freenet.de \
    --cc=linux-wireless@vger.kernel.org \
    --cc=linville@tuxdriver.com \
    --cc=yogeshp@marvell.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;
as well as URLs for NNTP newsgroup(s).