Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp2645887imm; Wed, 3 Oct 2018 07:08:34 -0700 (PDT) X-Google-Smtp-Source: ACcGV60CICpLRCHLsLy1HGRqO+TWo1LVj4p6KOy2o0/94tTYuiYpg4iaSX3KdZSU1za75ErELQ8R X-Received: by 2002:a63:920b:: with SMTP id o11-v6mr1515324pgd.141.1538575714051; Wed, 03 Oct 2018 07:08:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538575714; cv=none; d=google.com; s=arc-20160816; b=cbB7cdBDqvEuOoM/UQqVicYXtR8Z++LGhPJ3vkcUvm6Yu/9BaJYs9FYl9Ym3zRiXzC 6VPgagDCPHqIguC0vpKbunIm7XN0xG4bTPOhlV44Oi7ysnbFANo73hlKTh4G/9dY4aja 5nP0ZlSaQyxEoJabWbNukmH6TIGCB0IQ5iS2Gz2Qf8Z2DFaC6fl/RgWb+nIQx3EPZwHl us7lPmBfAS0datQbEDy/s5yusjo7U4+4trIlXxMVH+lImBEcn7oQJ6CX+EnvjDwBzuz5 oB7FojaWCL6peDE+yzg/0W6X1YvmwbeoNaBX5DuTcI1Q/4/EL/FwG7adaKfOa0bu/utP jMiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=/Z+rc/V0/D/CPK7OCB5tr9qDXZNzXfoCHcN9lstMRH0=; b=svbZPZcQlpdBlOj9IXsQszjAoCW1v9I2YGmM5lbRiJWasKUqM6f/xCL8S68YIwyg4+ 32T55lDZa3ZSKoR18k+iV+WjgQZrRP3ceKafxzfXu7eANfw07zlwtpC5sVM63vA+Mgfd SYkQ2Xrr9a5yHnLU/BymQTk7H1XBj3er0d9KsyC+q+jZiL2UrbuoXxg5HczoNkCvPeIZ A6XvBuOyOA9EPjuftCK89BWWW5v1GcRtBkhM+0OI/EP5WYOtMIQANfNQ3h2Kr+6oNmoz mrt1hs9iSXMNMwsfkYvbSNDiDzjWYcI3abYqiAinlWp0Hj3iPnnKpVGJ2cylZnHYHWf9 c29A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=FII94jDg; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l91-v6si1832759plb.315.2018.10.03.07.08.18; Wed, 03 Oct 2018 07:08:34 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=FII94jDg; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726862AbeJCU4b (ORCPT + 99 others); Wed, 3 Oct 2018 16:56:31 -0400 Received: from mail-pl1-f194.google.com ([209.85.214.194]:45982 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726543AbeJCU4a (ORCPT ); Wed, 3 Oct 2018 16:56:30 -0400 Received: by mail-pl1-f194.google.com with SMTP id y15-v6so3540743plr.12; Wed, 03 Oct 2018 07:07:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=/Z+rc/V0/D/CPK7OCB5tr9qDXZNzXfoCHcN9lstMRH0=; b=FII94jDg+ir8FJ3Q5F+jSO/5mbwPmldlEpa87xVeENO8hiQMMI9iAWv5bTZw8IT/GD Xg2srs+lbcSUqTWVq+uco/xWicnWzv+kjcSnXnEF43PZDHsJEmgpUQ6LImZ3Y9SwcW+G CZFCRqoBCzySBXjQzPplRPrY20y7cqCPIWoNMavoJkcvPajXyjdfmp6joho8D0IyerS8 V05fMvV4G7IJKMPcxa5wZem5dXaFqk0g5oJnIFXFFq0FvdhmqwjHMgG8QaIxG+BctjTr Bl1VM9opXqCKZdqiZn8UAj6DUOC/qemfaIgdBbwydzYAXM77Eo+V8X+EhMNq3JTev94M h+dw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=/Z+rc/V0/D/CPK7OCB5tr9qDXZNzXfoCHcN9lstMRH0=; b=cx57BcVzKNGQFnfW5zLdu5VlD0UwIjTM/qJW9K5oDTl3tLu/GnezrY8a8Vykzuzjug DQS04iimbQIpWBYxvSpbfsNFRxxpR1DZr9/vmGfz5ZItSiYavjqsCTaIJZShl8J+nZkv MU64TGtSR8NmMiOC17Y651EGVPvfCBcEB6bw2RhWwLxPo/m36plYsOC0hgjZ0j6a4glY UShmaZgKuVqu8M1LUWwM0pZb2IcdFT3IyO3uxyCBUtpntJo59wQDBfj1SB1Qb6KGr8HW Km9k42s4TiKkGiStinWzxXl+bsUtwt02WA2Ro1dlES/jlEL1qFlNkjXNAsCm3AeK4x6K bpuw== X-Gm-Message-State: ABuFfog0TukZ7MCUFlqEDUSVvFhp147EwRQcisOeyaYLrNKqVIjU5oZj AgnByq21Ipw4hpsH6Tdyzms= X-Received: by 2002:a17:902:4d45:: with SMTP id o5-v6mr1818537plh.42.1538575677412; Wed, 03 Oct 2018 07:07:57 -0700 (PDT) Received: from localhost.localdomain ([2402:f000:1:4414:4910:e0f1:49f2:a6db]) by smtp.gmail.com with ESMTPSA id 76-v6sm4343684pfk.134.2018.10.03.07.07.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Oct 2018 07:07:56 -0700 (PDT) From: Jia-Ju Bai To: sgruszka@redhat.com, kvalo@codeaurora.org, davem@davemloft.net Cc: linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Jia-Ju Bai Subject: [PATCH] net: wireless: iwlegacy: Fix possible data races in il4965_send_rxon_assoc() Date: Wed, 3 Oct 2018 22:07:45 +0800 Message-Id: <20181003140745.7650-1-baijiaju1990@gmail.com> X-Mailer: git-send-email 2.17.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org CPU0: il4965_configure_filter mutex_lock() line 6183: il->staging.filter_flags &= ... [WRITE] line 6184: il->staging.filter_flags |= ... [WRITE] CPU1: il4965_send_rxon_assoc line 1301: rxon1->filter_flags, rxon1->filter_flags [READ] line 1314: il->staging.filter_flags [READ] The WRITE operations in CPU0 are performed with holding a mutex lock, but the READ operations in CPU1 are performed without holding this lock, so there may exist data races. These possible races are detected by a runtime testing. To fix these races, the mutex lock is used in il4965_send_rxon_assoc() to protect the data. Signed-off-by: Jia-Ju Bai --- drivers/net/wireless/intel/iwlegacy/4965.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/net/wireless/intel/iwlegacy/4965.c b/drivers/net/wireless/intel/iwlegacy/4965.c index c3c638ed0ed7..45342777a5f1 100644 --- a/drivers/net/wireless/intel/iwlegacy/4965.c +++ b/drivers/net/wireless/intel/iwlegacy/4965.c @@ -1297,6 +1297,7 @@ il4965_send_rxon_assoc(struct il_priv *il) const struct il_rxon_cmd *rxon1 = &il->staging; const struct il_rxon_cmd *rxon2 = &il->active; + mutex_lock(&il->mutex); if (rxon1->flags == rxon2->flags && rxon1->filter_flags == rxon2->filter_flags && rxon1->cck_basic_rates == rxon2->cck_basic_rates && @@ -1307,6 +1308,7 @@ il4965_send_rxon_assoc(struct il_priv *il) rxon1->rx_chain == rxon2->rx_chain && rxon1->ofdm_basic_rates == rxon2->ofdm_basic_rates) { D_INFO("Using current RXON_ASSOC. Not resending.\n"); + mutex_unlock(&il->mutex); return 0; } @@ -1321,6 +1323,8 @@ il4965_send_rxon_assoc(struct il_priv *il) il->staging.ofdm_ht_dual_stream_basic_rates; rxon_assoc.rx_chain_select_flags = il->staging.rx_chain; + mutex_unlock(&il->mutex); + ret = il_send_cmd_pdu_async(il, C_RXON_ASSOC, sizeof(rxon_assoc), &rxon_assoc, NULL); -- 2.17.0