From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jia-Ju Bai Subject: Re: [PATCH] net: wireless: iwlegacy: Fix possible data races in il4965_send_rxon_assoc() Date: Thu, 4 Oct 2018 16:52:19 +0800 Message-ID: <988494cb-c121-697e-b502-ea4e7c601f47@gmail.com> References: <20181003140745.7650-1-baijiaju1990@gmail.com> <20181004075914.GB20523@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Cc: kvalo@codeaurora.org, davem@davemloft.net, linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org To: Stanislaw Gruszka Return-path: In-Reply-To: <20181004075914.GB20523@redhat.com> Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org List-Id: netdev.vger.kernel.org Thanks for your reply :) On 2018/10/4 15:59, Stanislaw Gruszka wrote: > On Wed, Oct 03, 2018 at 10:07:45PM +0800, Jia-Ju Bai wrote: >> 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. > Really ? I'm surprised by that, see below. My runtime testing shows that il4965_send_rxon_assoc() and il4965_configure_filter() are concurrently executed. But after seeing your reply, I need to carefully check whether my runtime testing is right, because I think you are right. In fact, I only monitored the iwl4965 driver, but did not monitor the iwlegacy driver, so I will do the testing again with monitoring the lwlegacy driver. > >> @@ -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 && > For 4965 driver il4965_send_rxon_assoc() is only called by > il_mac_bss_info_changed() and il4965_commit_rxon(). > > il_mac_bss_info_changed() acquire il->mutex and > callers of il4965_commit_rxon() acquire il->mutex > (but I did not check all of them). > > So I wonder how this patch did not cause the deadlock ? Oh, sorry, anyway, my patch will cause double locks... > > Anyway what can be done is adding: > > lockdep_assert_held(&il->mutex); > > il4965_commit_rxon() to check if we hold the mutex. I agree. Best wishes, Jia-Ju Bai