Commit aebafc7
committed
net: mana: Fix accessing freed irq affinity_hint
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2168970
commit 18a0483
Author: Haiyang Zhang <haiyangz@microsoft.com>
Date: Mon Feb 6 13:28:49 2023 -0800
net: mana: Fix accessing freed irq affinity_hint
After calling irq_set_affinity_and_hint(), the cpumask pointer is
saved in desc->affinity_hint, and will be used later when reading
/proc/irq/<num>/affinity_hint. So the cpumask variable needs to be
persistent. Otherwise, we are accessing freed memory when reading
the affinity_hint file.
Also, need to clear affinity_hint before free_irq(), otherwise there
is a one-time warning and stack trace during module unloading:
[ 243.948687] WARNING: CPU: 10 PID: 1589 at kernel/irq/manage.c:1913 free_irq+0x318/0x360
...
[ 243.948753] Call Trace:
[ 243.948754] <TASK>
[ 243.948760] mana_gd_remove_irqs+0x78/0xc0 [mana]
[ 243.948767] mana_gd_remove+0x3e/0x80 [mana]
[ 243.948773] pci_device_remove+0x3d/0xb0
[ 243.948778] device_remove+0x46/0x70
[ 243.948782] device_release_driver_internal+0x1fe/0x280
[ 243.948785] driver_detach+0x4e/0xa0
[ 243.948787] bus_remove_driver+0x70/0xf0
[ 243.948789] driver_unregister+0x35/0x60
[ 243.948792] pci_unregister_driver+0x44/0x90
[ 243.948794] mana_driver_exit+0x14/0x3fe [mana]
[ 243.948800] __do_sys_delete_module.constprop.0+0x185/0x2f0
To fix the bug, use the persistent mask, cpumask_of(cpu#), and set
affinity_hint to NULL before freeing the IRQ, as required by free_irq().
Cc: stable@vger.kernel.org
Fixes: 71fa688 ("net: mana: Assign interrupts to CPUs based on NUMA nodes")
Signed-off-by: Haiyang Zhang <haiyangz@microsoft.com>
Reviewed-by: Michael Kelley <mikelley@microsoft.com>
Reviewed-by: Leon Romanovsky <leonro@nvidia.com>
Link: https://lore.kernel.org/r/1675718929-19565-1-git-send-email-haiyangz@microsoft.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>1 parent 10c04c9 commit aebafc7
1 file changed
+11
-26
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1207 | 1207 | | |
1208 | 1208 | | |
1209 | 1209 | | |
1210 | | - | |
1211 | | - | |
1212 | | - | |
| 1210 | + | |
1213 | 1211 | | |
1214 | 1212 | | |
1215 | 1213 | | |
| |||
1230 | 1228 | | |
1231 | 1229 | | |
1232 | 1230 | | |
1233 | | - | |
1234 | | - | |
1235 | | - | |
1236 | | - | |
1237 | | - | |
1238 | | - | |
1239 | | - | |
1240 | | - | |
1241 | | - | |
1242 | | - | |
1243 | | - | |
1244 | | - | |
1245 | | - | |
1246 | 1231 | | |
1247 | | - | |
1248 | 1232 | | |
1249 | 1233 | | |
1250 | 1234 | | |
1251 | 1235 | | |
1252 | 1236 | | |
1253 | 1237 | | |
1254 | 1238 | | |
1255 | | - | |
| 1239 | + | |
1256 | 1240 | | |
1257 | 1241 | | |
1258 | 1242 | | |
1259 | 1243 | | |
1260 | | - | |
1261 | | - | |
1262 | | - | |
| 1244 | + | |
| 1245 | + | |
| 1246 | + | |
| 1247 | + | |
1263 | 1248 | | |
1264 | | - | |
1265 | | - | |
1266 | 1249 | | |
1267 | 1250 | | |
1268 | 1251 | | |
| |||
1273 | 1256 | | |
1274 | 1257 | | |
1275 | 1258 | | |
1276 | | - | |
1277 | | - | |
1278 | | - | |
1279 | 1259 | | |
1280 | 1260 | | |
1281 | 1261 | | |
1282 | 1262 | | |
| 1263 | + | |
| 1264 | + | |
1283 | 1265 | | |
1284 | 1266 | | |
1285 | 1267 | | |
| |||
1307 | 1289 | | |
1308 | 1290 | | |
1309 | 1291 | | |
| 1292 | + | |
| 1293 | + | |
| 1294 | + | |
1310 | 1295 | | |
1311 | 1296 | | |
1312 | 1297 | | |
| |||
0 commit comments