linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Yogesh Ashok Powar <yogeshp@marvell.com>
To: Johannes Berg <johannes@sipsolutions.net>
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: Fri, 17 Jun 2011 18:55:29 +0530	[thread overview]
Message-ID: <20110617132527.GA27436@hertz.marvell.com> (raw)
In-Reply-To: <d38dc36c1ab9a4bd819b9bcbbda181da@secure.sipsolutions.net>

On Thu, Jun 16, 2011 at 08:36:24AM -0700, Johannes Berg wrote:
> On Thu, 16 Jun 2011 15:57:08 +0530, Yogesh Ashok Powar wrote:
> > Following warning was observed after the commit
> > aac6af5534fade2b18682a0b9efad1a6c04c34c6
> >
> >>WARNING: at net/mac80211/wpa.c:397 ccmp_encrypt_skb+0xc4/0x1f0
> >
> > Consider a scenario where reserving skb tailroom is skipped
> > because software encryption is not enabled. SW encryption
> > can be disabled because of a) All the keys are hardware
> > planted b) No key has been created.  But, before actual
> > transmit if hardware encryption is disabled or software
> > encryption is started, there will not be enough tailroom
> > space to accommodate the sw crypto's MMIC or IV and
> > WARN_ON will be hit.
> >
> > This race between updations of hw keys and skipping & using
> > tailroom, is fixed by protecting critical regions (code
> > accessing crypto_tx_tailroom_needed_cnt and code from
> > tailroom skipping to skb_put for IV or MMIC) with the
> > spinlock.


> Haha, good joke. You've got to be kidding. NACK. No inserting spinlocks 
> into the TX/RX paths.
Using spinlocks in TX/RX path is not allowed because spinlocks will make
TX/RX path to block and its illegal to block while in an RCU read-side
critical section. I think, I got the joke here :(.


In my opinion, following should be the fix for the races explained above

a) The call synchronize_rcu() should be present before enabling sw
encryption :
	This will make pre-existing RCU readers in RCU readside critical
	section to complete. Or, SKBs which have already skipped
	tailroom to xmit before the end of synchronize_rcu's grace
	period.

b) Avoid tailroom skip check for RCU readside critical sections that begin
inside the grace period :
	This will make new entrants to mandatory allocating tailroom
	space irrespective of sw encryption (or hw encryption with
	generate IV/MMIC flags set) and hence avoid the WARN_ON.


Implementing first part is straight forward.
For later part, RCU readers must be aware of on going grace period. I am
currently not sure of any way to implement this. May be iff atomic read
is allowed inside RCU read-side critical sections, then before entering
the grace period, updater can set a atomic flag and unset it once done;
and RCU reader can check this atomic flag to avoid the
__tailroom skip check__.


Please suggest your opinion.

Thanks
Yogesh



  reply	other threads:[~2011-06-17 13:34 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 [this message]
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
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=20110617132527.GA27436@hertz.marvell.com \
    --to=yogeshp@marvell.com \
    --cc=andihartmann@01019freenet.de \
    --cc=johannes@sipsolutions.net \
    --cc=linux-wireless@vger.kernel.org \
    --cc=linville@tuxdriver.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).