Commit b15e431
jfs: Set the lbmDone flag at the end of lbmIODone
In lbmRead(), the I/O event waited for by wait_event() finishes before
it goes to sleep, and the lbmIODone() prematurely sets the flag to
lbmDONE, thus ending the wait. This causes wait_event() to return before
lbmREAD is cleared (because lbmDONE was set first), the premature return
of wait_event() leads to the release of lbuf before lbmIODone() returns,
thus triggering the use-after-free vulnerability reported in [1].
Moving the operation of setting the lbmDONE flag to after clearing lbmREAD
in lbmIODone() avoids the use-after-free vulnerability reported in [1].
[1]
BUG: KASAN: slab-use-after-free in rt_spin_lock+0x88/0x3e0 kernel/locking/spinlock_rt.c:56
Call Trace:
blk_update_request+0x57e/0xe60 block/blk-mq.c:1007
blk_mq_end_request+0x3e/0x70 block/blk-mq.c:1169
blk_complete_reqs block/blk-mq.c:1244 [inline]
blk_done_softirq+0x10a/0x160 block/blk-mq.c:1249
Allocated by task 6101:
lbmLogInit fs/jfs/jfs_logmgr.c:1821 [inline]
lmLogInit+0x3d0/0x19e0 fs/jfs/jfs_logmgr.c:1269
open_inline_log fs/jfs/jfs_logmgr.c:1175 [inline]
lmLogOpen+0x4e1/0xfa0 fs/jfs/jfs_logmgr.c:1069
jfs_mount_rw+0xe9/0x670 fs/jfs/jfs_mount.c:257
jfs_fill_super+0x754/0xd80 fs/jfs/super.c:532
Freed by task 6101:
kfree+0x1bd/0x900 mm/slub.c:6876
lbmLogShutdown fs/jfs/jfs_logmgr.c:1864 [inline]
lmLogInit+0x1137/0x19e0 fs/jfs/jfs_logmgr.c:1415
open_inline_log fs/jfs/jfs_logmgr.c:1175 [inline]
lmLogOpen+0x4e1/0xfa0 fs/jfs/jfs_logmgr.c:1069
jfs_mount_rw+0xe9/0x670 fs/jfs/jfs_mount.c:257
jfs_fill_super+0x754/0xd80 fs/jfs/super.c:532
Reported-by: syzbot+1d38eedcb25a3b5686a7@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=1d38eedcb25a3b5686a7
Signed-off-by: Edward Adam Davis <eadavis@qq.com>
Signed-off-by: Dave Kleikamp <dave.kleikamp@oracle.com>1 parent 3c778ec commit b15e431
1 file changed
Lines changed: 7 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2180 | 2180 | | |
2181 | 2181 | | |
2182 | 2182 | | |
2183 | | - | |
2184 | | - | |
2185 | 2183 | | |
2186 | 2184 | | |
2187 | 2185 | | |
| |||
2196 | 2194 | | |
2197 | 2195 | | |
2198 | 2196 | | |
2199 | | - | |
2200 | | - | |
2201 | 2197 | | |
2202 | 2198 | | |
2203 | 2199 | | |
2204 | | - | |
| 2200 | + | |
2205 | 2201 | | |
2206 | 2202 | | |
2207 | 2203 | | |
| |||
2225 | 2221 | | |
2226 | 2222 | | |
2227 | 2223 | | |
2228 | | - | |
2229 | | - | |
| 2224 | + | |
2230 | 2225 | | |
2231 | 2226 | | |
2232 | 2227 | | |
| |||
2278 | 2273 | | |
2279 | 2274 | | |
2280 | 2275 | | |
2281 | | - | |
2282 | | - | |
2283 | 2276 | | |
2284 | 2277 | | |
2285 | 2278 | | |
| |||
2290 | 2283 | | |
2291 | 2284 | | |
2292 | 2285 | | |
| 2286 | + | |
2293 | 2287 | | |
2294 | 2288 | | |
2295 | 2289 | | |
| |||
2302 | 2296 | | |
2303 | 2297 | | |
2304 | 2298 | | |
2305 | | - | |
2306 | | - | |
2307 | 2299 | | |
| 2300 | + | |
| 2301 | + | |
| 2302 | + | |
| 2303 | + | |
2308 | 2304 | | |
2309 | 2305 | | |
2310 | 2306 | | |
| |||
0 commit comments