Commit c24248e
wifi: rtw89: avoid possible TX wait initialization race
The value of skb_data->wait indicates whether skb is passed on to the
core mac80211 stack or released by the driver itself. Make sure that by
the time skb is added to txwd queue and becomes visible to the completing
side, it has already allocated and initialized TX wait related data (in
case it's needed).
This is found by code review and addresses a possible race scenario
described below:
Waiting thread Completing thread
rtw89_core_send_nullfunc()
rtw89_core_tx_write_link()
...
rtw89_pci_txwd_submit()
skb_data->wait = NULL
/* add skb to the queue */
skb_queue_tail(&txwd->queue, skb)
/* another thread (e.g. rtw89_ops_tx) performs TX kick off for the same queue */
rtw89_pci_napi_poll()
...
rtw89_pci_release_txwd_skb()
/* get skb from the queue */
skb_unlink(skb, &txwd->queue)
rtw89_pci_tx_status()
rtw89_core_tx_wait_complete()
/* use incorrect skb_data->wait */
rtw89_core_tx_kick_off_and_wait()
/* assign skb_data->wait but too late */
Found by Linux Verification Center (linuxtesting.org).
Fixes: 1ae5ca6 ("wifi: rtw89: add function to wait for completion of TX skbs")
Cc: [email protected]
Signed-off-by: Fedor Pchelkin <[email protected]>
Acked-by: Ping-Ke Shih <[email protected]>
Signed-off-by: Ping-Ke Shih <[email protected]>
Link: https://patch.msgid.link/[email protected]1 parent 3e31a6b commit c24248e
3 files changed
+24
-20
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1153 | 1153 | | |
1154 | 1154 | | |
1155 | 1155 | | |
1156 | | - | |
| 1156 | + | |
| 1157 | + | |
1157 | 1158 | | |
1158 | | - | |
1159 | | - | |
1160 | 1159 | | |
1161 | 1160 | | |
1162 | 1161 | | |
1163 | 1162 | | |
1164 | 1163 | | |
1165 | | - | |
1166 | | - | |
1167 | | - | |
1168 | | - | |
1169 | | - | |
1170 | | - | |
1171 | | - | |
1172 | | - | |
1173 | | - | |
1174 | | - | |
1175 | 1164 | | |
1176 | 1165 | | |
1177 | 1166 | | |
| |||
1234 | 1223 | | |
1235 | 1224 | | |
1236 | 1225 | | |
1237 | | - | |
| 1226 | + | |
| 1227 | + | |
1238 | 1228 | | |
1239 | 1229 | | |
1240 | 1230 | | |
| 1231 | + | |
1241 | 1232 | | |
1242 | 1233 | | |
1243 | 1234 | | |
| |||
1254 | 1245 | | |
1255 | 1246 | | |
1256 | 1247 | | |
| 1248 | + | |
| 1249 | + | |
1257 | 1250 | | |
1258 | 1251 | | |
1259 | 1252 | | |
| |||
1290 | 1283 | | |
1291 | 1284 | | |
1292 | 1285 | | |
1293 | | - | |
| 1286 | + | |
| 1287 | + | |
1294 | 1288 | | |
1295 | 1289 | | |
1296 | 1290 | | |
| |||
3928 | 3922 | | |
3929 | 3923 | | |
3930 | 3924 | | |
| 3925 | + | |
3931 | 3926 | | |
3932 | 3927 | | |
3933 | 3928 | | |
| |||
3937 | 3932 | | |
3938 | 3933 | | |
3939 | 3934 | | |
| 3935 | + | |
| 3936 | + | |
| 3937 | + | |
| 3938 | + | |
| 3939 | + | |
| 3940 | + | |
3940 | 3941 | | |
3941 | 3942 | | |
3942 | 3943 | | |
| |||
3951 | 3952 | | |
3952 | 3953 | | |
3953 | 3954 | | |
| 3955 | + | |
| 3956 | + | |
3954 | 3957 | | |
3955 | 3958 | | |
3956 | 3959 | | |
| |||
3961 | 3964 | | |
3962 | 3965 | | |
3963 | 3966 | | |
3964 | | - | |
| 3967 | + | |
| 3968 | + | |
3965 | 3969 | | |
3966 | 3970 | | |
3967 | 3971 | | |
| |||
3970 | 3974 | | |
3971 | 3975 | | |
3972 | 3976 | | |
3973 | | - | |
| 3977 | + | |
3974 | 3978 | | |
3975 | 3979 | | |
3976 | 3980 | | |
| 3981 | + | |
3977 | 3982 | | |
3978 | 3983 | | |
3979 | 3984 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7476 | 7476 | | |
7477 | 7477 | | |
7478 | 7478 | | |
7479 | | - | |
| 7479 | + | |
| 7480 | + | |
7480 | 7481 | | |
7481 | 7482 | | |
7482 | 7483 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1494 | 1494 | | |
1495 | 1495 | | |
1496 | 1496 | | |
1497 | | - | |
1498 | 1497 | | |
1499 | 1498 | | |
1500 | 1499 | | |
| |||
1510 | 1509 | | |
1511 | 1510 | | |
1512 | 1511 | | |
1513 | | - | |
1514 | 1512 | | |
1515 | 1513 | | |
1516 | 1514 | | |
| |||
0 commit comments