From patchwork Mon Mar 9 11:53:21 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eliad Peller X-Patchwork-Id: 5966481 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id BAFE1BF440 for ; Mon, 9 Mar 2015 11:53:34 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DFA6F201E4 for ; Mon, 9 Mar 2015 11:53:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A2C60201CE for ; Mon, 9 Mar 2015 11:53:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751599AbbCILxb (ORCPT ); Mon, 9 Mar 2015 07:53:31 -0400 Received: from mail-wi0-f170.google.com ([209.85.212.170]:39678 "EHLO mail-wi0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751560AbbCILxa (ORCPT ); Mon, 9 Mar 2015 07:53:30 -0400 Received: by wiwl15 with SMTP id l15so19400906wiw.4 for ; Mon, 09 Mar 2015 04:53:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=gQ3cbY0k+o9+v9m+LFkSFjxsq/5AxyKV4gi6q6d7ejA=; b=eHPR/5upUwMgMKhdlm5DSnkc+yQ5RddUFZY34C28lHCXPHLhYYh2/CMbGADc7OTWZZ BsTRSZLq3RB4O1AIWRC9+XufgWxjtwyP/j4WH2LEHPG80zBfm9INtTT7GhRfFtq3wORr f2LK4u8h08OySZOd8tYfBT6QT9ZTchpZgu5YUqTi0KoxLOyHYaxQnW0zpT3zvK17hylW 0asmHCmkRAWbyfw20HNC5r4qwBjosWqHR2njt6wGNBrmfp5ej8yartpUidPaY1veXo6f XLhHDbIjr0B5i0+e0WHgW1XPXW8Kk8Fl0mPV6b65EKXYejWcpUHOz48v+klAI5GgrboU raFg== X-Gm-Message-State: ALoCoQmge/FVFOTqfq4+ivyrMlqlWWuYLIiPsjEextqNMsoFbnlU1Nfq970Uf+pdqkWGB1Sk3Mhi X-Received: by 10.194.93.134 with SMTP id cu6mr56231039wjb.79.1425902008720; Mon, 09 Mar 2015 04:53:28 -0700 (PDT) Received: from localhost.localdomain ([89.139.55.99]) by mx.google.com with ESMTPSA id hv5sm27941962wjb.16.2015.03.09.04.53.27 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 09 Mar 2015 04:53:28 -0700 (PDT) From: Eliad Peller To: Johannes Berg Cc: Subject: [PATCH] mac80211: handle hw roc cancel vs. expiration race Date: Mon, 9 Mar 2015 13:53:21 +0200 Message-Id: <1425902001-3163-1-git-send-email-eliad@wizery.com> X-Mailer: git-send-email 1.8.5.2.229.g4448466.dirty Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP mac80211 handles roc expirations (indicated by ieee80211_remain_on_channel_expired()) with a separate work (hw_roc_done). If userspace asks to cancel the ongoing roc before hw_roc_done was scheduled, mac80211 will cancel the ongoing roc, while leaving the hw_roc_done work pending. This might end up in the next roc being cancelled by the stale work, causing mac80211 and the low-level driver to go out of sync. Fix it by cancelling hw_roc_done on roc cancel. Since hw_roc_done takes local->mtx, temporarily release it (before re-acquiring it and starting the next roc if needed). Signed-off-by: Eliad Peller --- net/mac80211/cfg.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c index dd4ff36..a80f7b3 100644 --- a/net/mac80211/cfg.c +++ b/net/mac80211/cfg.c @@ -2782,7 +2782,22 @@ static int ieee80211_cancel_roc(struct ieee80211_local *local, } list_del(&found->list); + mutex_unlock(&local->mtx); + + /* + * The driver might have already expired the ROC (by + * calling ieee80211_remain_on_channel_expired()), so + * cancel the pending roc_done work (otherwise, it might + * cancel the upcoming roc). + */ + cancel_work_sync(&local->hw_roc_done); + mutex_lock(&local->mtx); + /* + * We hold rtnl, so nothing should have been able to + * manipulate the roc_list during the temporary + * lock release. + */ if (found->started) ieee80211_start_next_roc(local); mutex_unlock(&local->mtx);