Commit 1dfd062
ksmbd: fix use-after-free by using call_rcu() for oplock_info
ksmbd currently frees oplock_info immediately using kfree(), even
though it is accessed under RCU read-side critical sections in places
like opinfo_get() and proc_show_files().
Since there is no RCU grace period delay between nullifying the pointer
and freeing the memory, a reader can still access oplock_info
structure after it has been freed. This can leads to a use-after-free
especially in opinfo_get() where atomic_inc_not_zero() is called on
already freed memory.
Fix this by switching to deferred freeing using call_rcu().
Fixes: 18b4fac ("ksmbd: fix use-after-free in smb_break_all_levII_oplock()")
Cc: [email protected]
Signed-off-by: Namjae Jeon <[email protected]>
Signed-off-by: Steve French <[email protected]>1 parent 4095501 commit 1dfd062
2 files changed
Lines changed: 24 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
120 | 120 | | |
121 | 121 | | |
122 | 122 | | |
123 | | - | |
| 123 | + | |
124 | 124 | | |
125 | 125 | | |
126 | 126 | | |
| |||
129 | 129 | | |
130 | 130 | | |
131 | 131 | | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
132 | 144 | | |
133 | 145 | | |
134 | 146 | | |
| |||
176 | 188 | | |
177 | 189 | | |
178 | 190 | | |
179 | | - | |
| 191 | + | |
180 | 192 | | |
181 | | - | |
| 193 | + | |
182 | 194 | | |
183 | 195 | | |
184 | 196 | | |
| |||
1277 | 1289 | | |
1278 | 1290 | | |
1279 | 1291 | | |
1280 | | - | |
1281 | | - | |
1282 | | - | |
1283 | 1292 | | |
1284 | | - | |
| 1293 | + | |
| 1294 | + | |
1285 | 1295 | | |
1286 | 1296 | | |
1287 | 1297 | | |
1288 | 1298 | | |
1289 | 1299 | | |
1290 | 1300 | | |
| 1301 | + | |
| 1302 | + | |
| 1303 | + | |
1291 | 1304 | | |
1292 | 1305 | | |
1293 | | - | |
| 1306 | + | |
1294 | 1307 | | |
1295 | 1308 | | |
1296 | 1309 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
72 | | - | |
73 | | - | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
74 | 75 | | |
75 | 76 | | |
76 | 77 | | |
| |||
0 commit comments