Skip to contentSkip to conversation

iwlwifi: iwl-dbg: Use del_timer_sync() before freeing

PATCH In review Guenter Roeck 4 participants 5 messages Apr 11, 2022 – Apr 23, 2022

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iwlwifi: iwl-dbg: Use del_timer_sync() before freeing

In Chrome OS, a large number of crashes is observed due to corrupted timer lists. Steven Rostedt pointed out that this usually happens when a timer is freed while still active, and that the problem is often triggered by code calling del_timer() instead of del_timer_sync() just before freeing.

Steven also identified the iwlwifi driver as one of the possible culprits since it does exactly that.

Cc Steven Rostedt <[email protected]>
Cc Johannes Berg <[email protected]>
Cc Gregory Greenman <[email protected]>
Fixes 60e8abd9d3e91 ("iwlwifi: dbg_ini: add periodic trigger new API support")

---
v1 (from RFC):
Removed Shahar S Matityahu from Cc: and added Gregory Greenman. No functional change.

I thought about the need to add a mutex to protect the timer list, but I convinced myself that it is not necessary because the code adding the timer list and the code removing it should never be never executed in parallel.

 drivers/net/wireless/intel/iwlwifi/iwl-dbg-tlv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/intel/iwlwifi/iwl-dbg-tlv.c +1 -1
index 866a33f49915..3237d4b528b5 100644
@@ -371,7 +371,7 @@ void iwl_dbg_tlv_del_timers(struct iwl_trans *trans)
 	struct iwl_dbg_tlv_timer_node *node, *tmp;
 
 	list_for_each_entry_safe(node, tmp, timer_list, list) {
-		del_timer(&node->timer);
+		del_timer_sync(&node->timer);
 		list_del(&node->list);
 		kfree(node);
 	}
Signature · 1 line
2.35.1
Acked-by on v1 1/1
#1 lore raw
Quoted 42 lines · Guenter Roeck

In Chrome OS, a large number of crashes is observed due to corrupted timer
lists. Steven Rostedt pointed out that this usually happens when a timer
is freed while still active, and that the problem is often triggered by code calling del_timer() instead of del_timer_sync() just before freeing.

Steven also identified the iwlwifi driver as one of the possible culprits
since it does exactly that.

Cc Steven Rostedt <[email protected]>
Cc Johannes Berg <[email protected]>
Cc Gregory Greenman <[email protected]>
Fixes 60e8abd9d3e91 ("iwlwifi: dbg_ini: add periodic trigger new API

support")

---
v1 (from RFC):
    Removed Shahar S Matityahu from Cc: and added Gregory Greenman. No functional change.

I thought about the need to add a mutex to protect the timer list, but
I convinced myself that it is not necessary because the code adding the timer list and the code removing it should never be never executed
in parallel.

 drivers/net/wireless/intel/iwlwifi/iwl-dbg-tlv.c | 2 +-

 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/intel/iwlwifi/iwl-dbg-tlv.c +0 -0
index 866a33f49915..3237d4b528b5 100644
@@ -371,7 +371,7 @@ void iwl_dbg_tlv_del_timers(struct iwl_trans
 *trans)
         struct iwl_dbg_tlv_timer_node *node, *tmp;
Quoted 7 lines


        list_for_each_entry_safe(node, tmp, timer_list, list) { -               del_timer(&node->timer);
+               del_timer_sync(&node->timer); list_del(&node->list);
                kfree(node);
        }

Hi Kalle,

Can you please pick it up to wireless-drivers for the next rc? It is an important fix.
Luca has already assigned it to you in patchwork.

Thanks!

Tested-by
#2 lore raw
Quoted 55 lines · Gregory
Quoted 48 lines · Guenter Roeck

In Chrome OS, a large number of crashes is observed due to corrupted timer
lists. Steven Rostedt pointed out that this usually happens when a timer
is freed while still active, and that the problem is often triggered by code calling del_timer() instead of del_timer_sync() just before freeing.

Steven also identified the iwlwifi driver as one of the possible culprits
since it does exactly that.

Cc Steven Rostedt <[email protected]>
Cc Johannes Berg <[email protected]>
Cc Gregory Greenman <[email protected]>
Fixes 60e8abd9d3e91 ("iwlwifi: dbg_ini: add periodic trigger new API

support")

---
v1 (from RFC):
Removed Shahar S Matityahu from Cc: and added Gregory Greenman. No functional change.

I thought about the need to add a mutex to protect the timer list, but
I convinced myself that it is not necessary because the code adding the timer list and the code removing it should never be never executed
in parallel.

 drivers/net/wireless/intel/iwlwifi/iwl-dbg-tlv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/intel/iwlwifi/iwl-dbg-tlv.c +1 -1
index 866a33f49915..3237d4b528b5 100644
@@ -371,7 +371,7 @@ void iwl_dbg_tlv_del_timers(struct iwl_trans
 *trans)
        struct iwl_dbg_tlv_timer_node *node, *tmp;
 
        list_for_each_entry_safe(node, tmp, timer_list, list) {
-               del_timer(&node->timer);
+               del_timer_sync(&node->timer);
                list_del(&node->list);
                kfree(node);
Quoted 1 line
        }

Hi Kalle,

Quoted 7 lines

Can you please pick it up to wireless-drivers for the next rc? It is an important fix.
Luca has already assigned it to you in patchwork.

Thanks!

I have tested this on top of Linux v5.17.3-rc1.

Feel free to add my...

Debian LLVM-14

- Sedat -

#3 lore raw
Quoted 63 lines · Sedat Dilek
Quoted 61 lines · Gregory
Quoted 48 lines · Guenter Roeck

In Chrome OS, a large number of crashes is observed due to corrupted timer
lists. Steven Rostedt pointed out that this usually happens when a timer
is freed while still active, and that the problem is often triggered by code calling del_timer() instead of del_timer_sync() just before freeing.

Steven also identified the iwlwifi driver as one of the possible culprits
since it does exactly that.

Cc Steven Rostedt <[email protected]>
Cc Johannes Berg <[email protected]>
Cc Gregory Greenman <[email protected]>
Fixes 60e8abd9d3e91 ("iwlwifi: dbg_ini: add periodic trigger new API

support")

---
v1 (from RFC):
Removed Shahar S Matityahu from Cc: and added Gregory Greenman. No functional change.

I thought about the need to add a mutex to protect the timer list, but
I convinced myself that it is not necessary because the code adding the timer list and the code removing it should never be never executed
in parallel.

 drivers/net/wireless/intel/iwlwifi/iwl-dbg-tlv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/intel/iwlwifi/iwl-dbg-tlv.c +1 -1
index 866a33f49915..3237d4b528b5 100644
@@ -371,7 +371,7 @@ void iwl_dbg_tlv_del_timers(struct iwl_trans
 *trans)
        struct iwl_dbg_tlv_timer_node *node, *tmp;
 
        list_for_each_entry_safe(node, tmp, timer_list, list) {
-               del_timer(&node->timer);
+               del_timer_sync(&node->timer);
                list_del(&node->list);
                kfree(node);
Quoted 1 line
        }

Hi Kalle,

Can you please pick it up to wireless-drivers for the next rc? It is an important fix.
Luca has already assigned it to you in patchwork.

Thanks!

Quoted 8 lines
Quoted 1 line

I have tested this on top of Linux v5.17.3-rc1.

Feel free to add my...

Debian LLVM-14

Please keep the Tested-by in one line, otherwise patchwork cannot parse it correctly. I fixed this manually during commit.

Signature · 3 lines
https://patchwork.kernel.org/project/linux-wireless/list/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
#4 lore raw
In reply to Guenter Roeck
Quoted 9 lines · Guenter Roeck

In Chrome OS, a large number of crashes is observed due to corrupted timer lists. Steven Rostedt pointed out that this usually happens when a timer is freed while still active, and that the problem is often triggered by code calling del_timer() instead of del_timer_sync() just before freeing.

Steven also identified the iwlwifi driver as one of the possible culprits since it does exactly that.

Quoted 8 lines
Cc Steven Rostedt <[email protected]>
Cc Johannes Berg <[email protected]>
Cc Gregory Greenman <[email protected]>
Fixes 60e8abd9d3e91 ("iwlwifi: dbg_ini: add periodic trigger new API support")

Patch applied to wireless.git, thanks.

7635a1ad8d92 iwlwifi: iwl-dbg: Use del_timer_sync() before freeing

Signature · 3 lines
https://patchwork.kernel.org/project/linux-wireless/patch/[email protected]/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches