From: Jia-Ju Bai <hidden> Date: 2018-10-03 14:08:00
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 <redacted>
---
drivers/net/wireless/intel/iwlegacy/4965.c | 4 ++++
1 file changed, 4 insertions(+)
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 ?
Anyway what can be done is adding:
lockdep_assert_held(&il->mutex);
il4965_commit_rxon() to check if we hold the mutex.
Thanks
Stanislaw
From: Jia-Ju Bai <hidden> Date: 2018-10-04 08:52:28
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:
quoted
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.
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.
On Thu, Oct 04, 2018 at 04:52:19PM +0800, Jia-Ju Bai wrote:
On 2018/10/4 15:59, Stanislaw Gruszka wrote:
quoted
On Wed, Oct 03, 2018 at 10:07:45PM +0800, Jia-Ju Bai wrote:
quoted
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.
<snip>
quoted
So I wonder how this patch did not cause the deadlock ?
Oh, sorry, anyway, my patch will cause double locks...
So how those runtime test were performend such you didn't
notice this ?
quoted
Anyway what can be done is adding:
lockdep_assert_held(&il->mutex);
il4965_commit_rxon() to check if we hold the mutex.
From: Jia-Ju Bai <hidden> Date: 2018-10-05 13:43:03
On 2018/10/5 15:54, Stanislaw Gruszka wrote:
On Thu, Oct 04, 2018 at 04:52:19PM +0800, Jia-Ju Bai wrote:
quoted
On 2018/10/4 15:59, Stanislaw Gruszka wrote:
quoted
On Wed, Oct 03, 2018 at 10:07:45PM +0800, Jia-Ju Bai wrote:
quoted
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.
<snip>
quoted
quoted
So I wonder how this patch did not cause the deadlock ?
Oh, sorry, anyway, my patch will cause double locks...
So how those runtime test were performend such you didn't
notice this ?
I write a tool to perform runtime testing.
This tool records the lock status during driver execution.
Some calls to mutex_lock() are in common.c that I did not handle, so the
corresponding lock status was not recorded by my tool, causing this
false positive.
Now I have handled common.c, and this false positive is not reported any
more.
Actually, I get several new reports.
I will send you these reports to you later, and hope you can have a
look, thanks in advance :)
quoted
quoted
Anyway what can be done is adding:
lockdep_assert_held(&il->mutex);
il4965_commit_rxon() to check if we hold the mutex.