Commit 69c7b2f
committed
libceph: fix race between delayed_work() and ceph_monc_stop()
The way the delayed work is handled in ceph_monc_stop() is prone to
races with mon_fault() and possibly also finish_hunting(). Both of
these can requeue the delayed work which wouldn't be canceled by any of
the following code in case that happens after cancel_delayed_work_sync()
runs -- __close_session() doesn't mess with the delayed work in order
to avoid interfering with the hunting interval logic. This part was
missed in commit b5d9170 ("libceph: behave in mon_fault() if
cur_mon < 0") and use-after-free can still ensue on monc and objects
that hang off of it, with monc->auth and monc->monmap being
particularly susceptible to quickly being reused.
To fix this:
- clear monc->cur_mon and monc->hunting as part of closing the session
in ceph_monc_stop()
- bail from delayed_work() if monc->cur_mon is cleared, similar to how
it's done in mon_fault() and finish_hunting() (based on monc->hunting)
- call cancel_delayed_work_sync() after the session is closed
Cc: [email protected]
Link: https://tracker.ceph.com/issues/66857
Signed-off-by: Ilya Dryomov <[email protected]>
Reviewed-by: Xiubo Li <[email protected]>1 parent 256abd8 commit 69c7b2f
1 file changed
+12
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1085 | 1085 | | |
1086 | 1086 | | |
1087 | 1087 | | |
1088 | | - | |
1089 | 1088 | | |
| 1089 | + | |
| 1090 | + | |
| 1091 | + | |
| 1092 | + | |
| 1093 | + | |
1090 | 1094 | | |
1091 | 1095 | | |
1092 | 1096 | | |
1093 | 1097 | | |
1094 | 1098 | | |
| 1099 | + | |
| 1100 | + | |
1095 | 1101 | | |
1096 | 1102 | | |
1097 | 1103 | | |
| |||
1116 | 1122 | | |
1117 | 1123 | | |
1118 | 1124 | | |
| 1125 | + | |
| 1126 | + | |
1119 | 1127 | | |
1120 | 1128 | | |
1121 | 1129 | | |
| |||
1232 | 1240 | | |
1233 | 1241 | | |
1234 | 1242 | | |
1235 | | - | |
1236 | 1243 | | |
1237 | 1244 | | |
1238 | 1245 | | |
| 1246 | + | |
1239 | 1247 | | |
1240 | 1248 | | |
1241 | 1249 | | |
| 1250 | + | |
| 1251 | + | |
1242 | 1252 | | |
1243 | 1253 | | |
1244 | 1254 | | |
| |||
0 commit comments