Return-path: Received: from mail-ea0-f174.google.com ([209.85.215.174]:37974 "EHLO mail-ea0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752639Ab2JOPtR (ORCPT ); Mon, 15 Oct 2012 11:49:17 -0400 Received: by mail-ea0-f174.google.com with SMTP id c13so1206537eaa.19 for ; Mon, 15 Oct 2012 08:49:15 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <20121012121333.GA30816@redhat.com> References: <20120807102208.GA12589@redhat.com> <20121003143029.GF2259@redhat.com> <20121012121333.GA30816@redhat.com> From: Pedro Francisco Date: Mon, 15 Oct 2012 16:48:55 +0100 Message-ID: (sfid-20121015_174920_916147_B2D19B9C) Subject: Re: unloading WiFi modules is usually triggering kernel crash To: Stanislaw Gruszka Cc: ML linux-wireless , Johannes Berg Content-Type: multipart/mixed; boundary=047d7b6704cdcaf6a304cc1afa65 Sender: linux-wireless-owner@vger.kernel.org List-ID: --047d7b6704cdcaf6a304cc1afa65 Content-Type: text/plain; charset=ISO-8859-1 On Fri, Oct 12, 2012 at 1:13 PM, Stanislaw Gruszka wrote: > On Tue, Oct 09, 2012 at 10:14:40AM +0100, Pedro Francisco wrote: >> So, I'm guessing this means it is related to what you found on iwlwifi >> (even if I'm on iwlegacy)? > > Yes, this seems to be cfg80211 problem. I think crash happen because > cfg80211 is in disassociate state (i.e. has wdev->current_bss NULL) and > erroneously mac80211 stays in associate state. So while we unload > module cfg80211_mlme_down() we do not call ieee80211_deauth(). > > I think this state mishmash happens because wrong behaviour on > __cfg80211_mlme_deauth(). Below patch try to correct that. > Can you check if it prevent a crash? On my environment I can > not reproduce this problem reliably. > > Thanks > Stanislaw > > diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h > index ab78b53..9b99b60 100644 > --- a/include/net/cfg80211.h > +++ b/include/net/cfg80211.h > @@ -1218,6 +1218,7 @@ struct cfg80211_deauth_request { > const u8 *ie; > size_t ie_len; > u16 reason_code; > + bool local_state_change; > }; > > /** > diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c > index e714ed8..e510a33 100644 > --- a/net/mac80211/mlme.c > +++ b/net/mac80211/mlme.c > @@ -3549,6 +3549,7 @@ int ieee80211_mgd_deauth(struct ieee80211_sub_if_data *sdata, > { > struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; > u8 frame_buf[IEEE80211_DEAUTH_FRAME_LEN]; > + bool tx = !req->local_state_change; > > mutex_lock(&ifmgd->mtx); > > @@ -3565,12 +3566,12 @@ int ieee80211_mgd_deauth(struct ieee80211_sub_if_data *sdata, > if (ifmgd->associated && > ether_addr_equal(ifmgd->associated->bssid, req->bssid)) { > ieee80211_set_disassoc(sdata, IEEE80211_STYPE_DEAUTH, > - req->reason_code, true, frame_buf); > + req->reason_code, tx, frame_buf); > } else { > drv_mgd_prepare_tx(sdata->local, sdata); > ieee80211_send_deauth_disassoc(sdata, req->bssid, > IEEE80211_STYPE_DEAUTH, > - req->reason_code, true, > + req->reason_code, tx, > frame_buf); > } > > diff --git a/net/wireless/mlme.c b/net/wireless/mlme.c > index 3df195a..4954010 100644 > --- a/net/wireless/mlme.c > +++ b/net/wireless/mlme.c > @@ -457,21 +457,11 @@ int __cfg80211_mlme_deauth(struct cfg80211_registered_device *rdev, > .reason_code = reason, > .ie = ie, > .ie_len = ie_len, > + .local_state_change = local_state_change, > }; > > ASSERT_WDEV_LOCK(wdev); > > - if (local_state_change) { > - if (wdev->current_bss && > - ether_addr_equal(wdev->current_bss->pub.bssid, bssid)) { > - cfg80211_unhold_bss(wdev->current_bss); > - cfg80211_put_bss(&wdev->current_bss->pub); > - wdev->current_bss = NULL; > - } > - > - return 0; > - } > - > return rdev->ops->deauth(&rdev->wiphy, dev, &req); > } > I've been testing the patch since this morning (GMT), I can't reproduce any of the issues I referred on this thread (had to adapt the patch slightly, though). Seems to be fixed! Thank you for your help! -- Pedro Francisco --047d7b6704cdcaf6a304cc1afa65 Content-Type: application/octet-stream; name="mlme-timers-fedora-3.6.1-fc17-kernel.patch" Content-Disposition: attachment; filename="mlme-timers-fedora-3.6.1-fc17-kernel.patch" Content-Transfer-Encoding: base64 X-Attachment-Id: f_h8beflxp1 ZGlmZiAtLWdpdCBhL2luY2x1ZGUvbmV0L2NmZzgwMjExLmggYi9pbmNsdWRlL25ldC9jZmc4MDIx MS5oCmluZGV4IDNkMjU0ZTEuLmYxMDU1M2MgMTAwNjQ0Ci0tLSBhL2luY2x1ZGUvbmV0L2NmZzgw MjExLmgKKysrIGIvaW5jbHVkZS9uZXQvY2ZnODAyMTEuaApAQCAtMTIxNyw2ICsxMjE3LDcgQEAg c3RydWN0IGNmZzgwMjExX2RlYXV0aF9yZXF1ZXN0IHsKIAljb25zdCB1OCAqaWU7CiAJc2l6ZV90 IGllX2xlbjsKIAl1MTYgcmVhc29uX2NvZGU7CisJYm9vbCBsb2NhbF9zdGF0ZV9jaGFuZ2U7CiB9 OwogCiAvKioKZGlmZiAtLWdpdCBhL25ldC9tYWM4MDIxMS9tbG1lLmMgYi9uZXQvbWFjODAyMTEv bWxtZS5jCmluZGV4IGY3NmI4MzMuLmRhM2Y1ZTQgMTAwNjQ0Ci0tLSBhL25ldC9tYWM4MDIxMS9t bG1lLmMKKysrIGIvbmV0L21hYzgwMjExL21sbWUuYwpAQCAtMzQ1Nyw2ICszNDU3LDcgQEAgaW50 IGllZWU4MDIxMV9tZ2RfZGVhdXRoKHN0cnVjdCBpZWVlODAyMTFfc3ViX2lmX2RhdGEgKnNkYXRh LAogewogCXN0cnVjdCBpZWVlODAyMTFfaWZfbWFuYWdlZCAqaWZtZ2QgPSAmc2RhdGEtPnUubWdk OwogCXU4IGZyYW1lX2J1ZltERUFVVEhfRElTQVNTT0NfTEVOXTsKKwlib29sIHR4ID0gIXJlcS0+ bG9jYWxfc3RhdGVfY2hhbmdlOwogCiAJbXV0ZXhfbG9jaygmaWZtZ2QtPm10eCk7CiAKQEAgLTM0 NzMsMTEgKzM0NzQsMTEgQEAgaW50IGllZWU4MDIxMV9tZ2Rf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