Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp3635438ybl; Sun, 12 Jan 2020 23:18:06 -0800 (PST) X-Google-Smtp-Source: APXvYqz8VKaNuKuOx81tdmRQbW1dEnBarqM5IheoD0u4of1AkG5iCof5/yJ5QTWLS4/pM66T8gwB X-Received: by 2002:a54:4e08:: with SMTP id a8mr12033102oiy.77.1578899885991; Sun, 12 Jan 2020 23:18:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578899885; cv=none; d=google.com; s=arc-20160816; b=fjMDsxWrIUAdax+wH8KvhbLM5K3ANdFtRjUGDo60zNfZr73rhJUsV6kJI5PfYXzLKB ik2TGHSoq/+3itnhAwoRdpErBWGrZnh9dpG7Kbb7mE+eRM7U46JQvzCQjBNFkGANSKF1 SMibW12UO6YLcnn6NqZyD+Nwpyjg0IV9VgdFoDPTQeZjBgcB/nXQEdhNBCuSOmdzDkV8 gmQlPCT1UnBnxunYXWDHv8m+lrG7HgEITPK1jauzI2PyAPjNFe0pEMfBbakZYNB6g1iH JdYe5bI24Zi/c6zvx0feggrXzPcZVh4x3xNMZrRXjz2QebK08HHiK7FMiPSIQOlNzOHu OJCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:message-id :in-reply-to:date:references:subject:cc:to:from:dmarc-filter :dkim-signature; bh=PHpcWydMf81SX9BI3zK7atci8ZDAip52kbaK4/vTAKM=; b=GrAb2ZjRWyCpvywXRVuvsxL116NORO2WlqtcW0aX0MWqNq07YeWCL0AIxROXF5SHQA Lx1Bqa3CmqAVa01Wf15saLr6khwikvtDn5z3mota6DuW8g6NxedcxcbZx/WnM8g2z/LH 226Rg5NoxijcsYuT0bwmD7ZwGmw1ABVhJ9fQU5xE22cNtNrdYrtCfnpDsXFvCH8fdga3 cv5WkHV/HB3pzKMzZSGv7MLDZ9Jas3wBIhP7u/4XAi9rFqDMECD71c5k805dRylll1xx 9eCv+VzBuMZrDzwluxtH6L6eso8bOoWZW4kiW1nUsnSmEcSB2AXKW7NVHiNYMhAiALDC MHhw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@mg.codeaurora.org header.s=smtp header.b="QmZW/qV5"; spf=pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v145si5468305oia.68.2020.01.12.23.17.43; Sun, 12 Jan 2020 23:18:05 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@mg.codeaurora.org header.s=smtp header.b="QmZW/qV5"; spf=pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728688AbgAMHRl (ORCPT + 99 others); Mon, 13 Jan 2020 02:17:41 -0500 Received: from mail25.static.mailgun.info ([104.130.122.25]:48756 "EHLO mail25.static.mailgun.info" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728665AbgAMHRl (ORCPT ); Mon, 13 Jan 2020 02:17:41 -0500 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1578899861; h=Content-Type: MIME-Version: Message-ID: In-Reply-To: Date: References: Subject: Cc: To: From: Sender; bh=PHpcWydMf81SX9BI3zK7atci8ZDAip52kbaK4/vTAKM=; b=QmZW/qV5NfimtI5ij1K4pQSrSdDmVImTvXzC6vCwnGs0kxtg1jJdv8ETFxYJVOloQeZWvN1z GeBy+odk178Ua9G+oTzg5Rt2+AUNxGHfN8P8itT3kgEB+sgB+gKDn7jBEXq9khOIySwR0R9p KfuwZBvGHqxrO6G16kLCBlSJ5eQ= X-Mailgun-Sending-Ip: 104.130.122.25 X-Mailgun-Sid: WyI3YTAwOSIsICJsaW51eC13aXJlbGVzc0B2Z2VyLmtlcm5lbC5vcmciLCAiYmU5ZTRhIl0= Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by mxa.mailgun.org with ESMTP id 5e1c1991.7f8189d6d6c0-smtp-out-n02; Mon, 13 Jan 2020 07:17:37 -0000 (UTC) Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 77C56C4479C; Mon, 13 Jan 2020 07:17:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=2.0 tests=ALL_TRUSTED,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.0 Received: from x230.qca.qualcomm.com (dsl-hkibng32-54f84f-238.dhcp.inet.fi [84.248.79.238]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: kvalo) by smtp.codeaurora.org (Postfix) with ESMTPSA id A0D18C433CB; Mon, 13 Jan 2020 07:17:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org A0D18C433CB Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=none smtp.mailfrom=kvalo@codeaurora.org From: Kalle Valo To: Jia-Ju Bai Cc: ath9k-devel@qca.qualcomm.com, davem@davemloft.net, linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] ath9k: Fix possible data races in ath_set_channel() References: <20200111171528.7053-1-baijiaju1990@gmail.com> Date: Mon, 13 Jan 2020 09:17:28 +0200 In-Reply-To: <20200111171528.7053-1-baijiaju1990@gmail.com> (Jia-Ju Bai's message of "Sun, 12 Jan 2020 01:15:28 +0800") Message-ID: <87a76rsu47.fsf@codeaurora.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Jia-Ju Bai writes: > The functions ath9k_config() and ath_ani_calibrate() may be concurrently > executed. > > A variable survey->filled is accessed with holding a spinlock > common->cc_lock, through: > ath_ani_calibrate() > spin_lock_irqsave(&common->cc_lock, flags); > ath_update_survey_stats() > ath_update_survey_nf() > survey->filled |= SURVEY_INFO_NOISE_DBM; > > The identical variables sc->cur_survey->filled and > sc->survey[pos].filled is accessed without holding this lock, through: > ath9k_config() > ath_chanctx_set_channel() > ath_set_channel() > sc->cur_survey->filled &= ~SURVEY_INFO_IN_USE; > sc->cur_survey->filled |= SURVEY_INFO_IN_USE; > else if (!(sc->survey[pos].filled & SURVEY_INFO_IN_USE)) > ath_update_survey_nf > survey->filled |= SURVEY_INFO_NOISE_DBM; > > Thus, possible data races may occur. > > To fix these data races, in ath_set_channel(), these variables are > accessed with holding the spinlock common->cc_lock. > > These data races are found by the runtime testing of our tool DILP-2. > > Signed-off-by: Jia-Ju Bai I need a detailed review from somone familiar with ath9k before I can consider applying this. -- https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches