Commit 33f016b
dpll: fix NULL deref in dpll_device_ops() during teardown race
When the last owner of a dpll device unregisters while a foreign driver
still holds a pin on it via dpll_pin_on_pin_register(), the dpll object
stays alive with an empty registration list. A pin notification queued
before the unregister (e.g. ice reacting to zl3073x_i2c removal) then
walks pin->dpll_refs into dpll_device_ops(), which trips the WARN_ON and
dereferences the missing registration. dpll_lock cannot help because the
notification work was queued before the unregistering driver took the
lock.
Treat the empty registration list as a legitimate transient state. Make
dpll_priv() and dpll_device_ops() return NULL in that case and make
every pin netlink path that resolves a device from a pin skip such
dplls. dpll_cmd_pin_get_one() picks a ref with a live registration and
returns -ENODEV when there is none, the pin dumpit skips such a pin
instead of aborting the dump, dpll_msg_add_pin_dplls() and the
frequency, esync, reference sync and phase adjust set paths skip dead
refs, and dpll_pin_parent_device_set() validates the parent with
dpll_device_get_by_id(). dpll_pin_register() is the last caller that
dereferenced the device ops without a check, so move its frequency
monitor validation under dpll_lock and tolerate a missing registration
there as well.
The empty registration list is equivalent to a cleared DPLL_REGISTERED
mark, both transitions happen under dpll_lock in dpll_device_register()
and dpll_device_unregister(). A pin notification for a pin whose dplls
are all gone is now dropped with -ENODEV instead of crashing, all
callers in the core ignore that return value.
WARNING: drivers/dpll/dpll_core.c:1092 at dpll_device_ops+0x24/0x40,
CPU#83: kworker/u576:3/23471
Modules linked in: ... ice ... zl3073x_i2c(-) ... zl3073x ...
Workqueue: ice_dpll_wq ice_dpll_pin_notify_work [ice]
RIP: 0010:dpll_device_ops+0x24/0x40
Call Trace:
<TASK>
dpll_cmd_pin_get_one+0x336/0x520
dpll_pin_event_send+0x82/0x140
dpll_pin_on_pin_unregister+0xbb/0x160
ice_dpll_pin_notify_work+0x1bc/0x1f0 [ice]
process_one_work+0x19e/0x370
worker_thread+0x1a6/0x310
kthread+0xe4/0x120
ret_from_fork+0x1a1/0x270
ret_from_fork_asm+0x1a/0x30
</TASK>
---[ end trace 0000000000000000 ]---
BUG: kernel NULL pointer dereference, address: 0000000000000010
#PF: supervisor read access in kernel mode
#PF: error_code(0x0000) - not-present page
Fixes: 9431063 ("dpll: core: Add DPLL framework base functions")
Signed-off-by: Petr Oros <poros@redhat.com>
Tested-by: Ivan Vecera <ivecera@redhat.com>
Reviewed-by: Vadim Fedorenko <vadim.fedorenko@linux.dev>
Link: https://patch.msgid.link/20260813140817.1051388-1-poros@redhat.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>1 parent 1e3d24f commit 33f016b
2 files changed
Lines changed: 67 additions & 16 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
876 | 876 | | |
877 | 877 | | |
878 | 878 | | |
| 879 | + | |
879 | 880 | | |
880 | 881 | | |
881 | 882 | | |
882 | 883 | | |
883 | 884 | | |
884 | | - | |
885 | | - | |
886 | | - | |
887 | 885 | | |
888 | 886 | | |
889 | 887 | | |
890 | 888 | | |
891 | 889 | | |
| 890 | + | |
| 891 | + | |
| 892 | + | |
| 893 | + | |
| 894 | + | |
| 895 | + | |
| 896 | + | |
| 897 | + | |
892 | 898 | | |
893 | 899 | | |
894 | 900 | | |
| |||
1081 | 1087 | | |
1082 | 1088 | | |
1083 | 1089 | | |
1084 | | - | |
1085 | | - | |
1086 | | - | |
1087 | | - | |
1088 | | - | |
1089 | | - | |
| 1090 | + | |
| 1091 | + | |
1090 | 1092 | | |
1091 | 1093 | | |
1092 | 1094 | | |
1093 | 1095 | | |
1094 | 1096 | | |
1095 | 1097 | | |
1096 | 1098 | | |
| 1099 | + | |
| 1100 | + | |
1097 | 1101 | | |
1098 | 1102 | | |
1099 | 1103 | | |
| |||
1102 | 1106 | | |
1103 | 1107 | | |
1104 | 1108 | | |
| 1109 | + | |
| 1110 | + | |
1105 | 1111 | | |
1106 | 1112 | | |
1107 | 1113 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
69 | 85 | | |
70 | 86 | | |
71 | 87 | | |
| |||
656 | 672 | | |
657 | 673 | | |
658 | 674 | | |
| 675 | + | |
| 676 | + | |
659 | 677 | | |
660 | 678 | | |
661 | 679 | | |
| |||
700 | 718 | | |
701 | 719 | | |
702 | 720 | | |
| 721 | + | |
| 722 | + | |
703 | 723 | | |
704 | | - | |
705 | | - | |
| 724 | + | |
706 | 725 | | |
707 | 726 | | |
708 | 727 | | |
| |||
1091 | 1110 | | |
1092 | 1111 | | |
1093 | 1112 | | |
| 1113 | + | |
| 1114 | + | |
1094 | 1115 | | |
1095 | 1116 | | |
1096 | 1117 | | |
| |||
1101 | 1122 | | |
1102 | 1123 | | |
1103 | 1124 | | |
1104 | | - | |
| 1125 | + | |
1105 | 1126 | | |
1106 | 1127 | | |
1107 | 1128 | | |
| |||
1117 | 1138 | | |
1118 | 1139 | | |
1119 | 1140 | | |
| 1141 | + | |
| 1142 | + | |
1120 | 1143 | | |
1121 | 1144 | | |
1122 | 1145 | | |
| |||
1138 | 1161 | | |
1139 | 1162 | | |
1140 | 1163 | | |
| 1164 | + | |
| 1165 | + | |
1141 | 1166 | | |
1142 | 1167 | | |
1143 | 1168 | | |
| |||
1163 | 1188 | | |
1164 | 1189 | | |
1165 | 1190 | | |
| 1191 | + | |
| 1192 | + | |
1166 | 1193 | | |
1167 | 1194 | | |
1168 | 1195 | | |
| |||
1173 | 1200 | | |
1174 | 1201 | | |
1175 | 1202 | | |
1176 | | - | |
| 1203 | + | |
1177 | 1204 | | |
1178 | 1205 | | |
1179 | 1206 | | |
| |||
1199 | 1226 | | |
1200 | 1227 | | |
1201 | 1228 | | |
| 1229 | + | |
| 1230 | + | |
1202 | 1231 | | |
1203 | 1232 | | |
1204 | 1233 | | |
| |||
1224 | 1253 | | |
1225 | 1254 | | |
1226 | 1255 | | |
| 1256 | + | |
| 1257 | + | |
1227 | 1258 | | |
1228 | 1259 | | |
1229 | 1260 | | |
| |||
1262 | 1293 | | |
1263 | 1294 | | |
1264 | 1295 | | |
1265 | | - | |
| 1296 | + | |
1266 | 1297 | | |
1267 | 1298 | | |
1268 | 1299 | | |
| |||
1283 | 1314 | | |
1284 | 1315 | | |
1285 | 1316 | | |
| 1317 | + | |
| 1318 | + | |
1286 | 1319 | | |
1287 | 1320 | | |
1288 | 1321 | | |
| |||
1307 | 1340 | | |
1308 | 1341 | | |
1309 | 1342 | | |
| 1343 | + | |
| 1344 | + | |
1310 | 1345 | | |
1311 | 1346 | | |
1312 | 1347 | | |
| |||
1500 | 1535 | | |
1501 | 1536 | | |
1502 | 1537 | | |
| 1538 | + | |
| 1539 | + | |
1503 | 1540 | | |
1504 | 1541 | | |
1505 | 1542 | | |
| |||
1509 | 1546 | | |
1510 | 1547 | | |
1511 | 1548 | | |
1512 | | - | |
| 1549 | + | |
1513 | 1550 | | |
1514 | 1551 | | |
1515 | 1552 | | |
| |||
1526 | 1563 | | |
1527 | 1564 | | |
1528 | 1565 | | |
| 1566 | + | |
| 1567 | + | |
1529 | 1568 | | |
1530 | 1569 | | |
1531 | 1570 | | |
| |||
1550 | 1589 | | |
1551 | 1590 | | |
1552 | 1591 | | |
| 1592 | + | |
| 1593 | + | |
1553 | 1594 | | |
1554 | 1595 | | |
1555 | 1596 | | |
| |||
1581 | 1622 | | |
1582 | 1623 | | |
1583 | 1624 | | |
1584 | | - | |
| 1625 | + | |
1585 | 1626 | | |
1586 | 1627 | | |
1587 | 1628 | | |
| |||
1873 | 1914 | | |
1874 | 1915 | | |
1875 | 1916 | | |
| 1917 | + | |
| 1918 | + | |
| 1919 | + | |
| 1920 | + | |
1876 | 1921 | | |
1877 | 1922 | | |
1878 | 1923 | | |
| |||
0 commit comments