floppy: avoid stale cont use after BH is queued - #1041
Conversation
|
Upstream branch: 2d2338c |
c0cc428 to
23d8cf0
Compare
|
Upstream branch: 0d83957 |
261ec3d to
93a95a7
Compare
612ae31 to
863d43a
Compare
|
Upstream branch: 06cf618 |
93a95a7 to
95d2480
Compare
863d43a to
29ac21d
Compare
|
Upstream branch: d58772d |
95d2480 to
3ebae52
Compare
29ac21d to
ea2c39d
Compare
|
Upstream branch: f5bbbfe |
3ebae52 to
6b98cdb
Compare
ea2c39d to
4082a30
Compare
|
Upstream branch: 3d6d817 |
6b98cdb to
9c91495
Compare
4082a30 to
36bd7eb
Compare
|
Upstream branch: 3aa1dca |
9c91495 to
0c570ee
Compare
d89ab11 to
fdba928
Compare
|
Upstream branch: fd923b3 |
0c570ee to
1dfdc9f
Compare
fdba928 to
60442a3
Compare
|
Upstream branch: 8d3ae59 |
1dfdc9f to
6e93723
Compare
60442a3 to
3df366e
Compare
reset_fdc() arms do_floppy = reset_interrupt; the IRQ handler then queues that function via schedule_bh(). If unlock_fdc() or do_wakeup() clears cont before the work runs, reset_interrupt() dereferences a NULL cont and oopses. Example crash excerpt: [ 1070.468148] status=80 [ 1070.468152] fdc_busy=1 [ 1070.468158] cont= (null) [ 1070.468161] current_req= (null) [ 1070.468162] command_status=-1 [ 1070.468163] [ 1070.557051] floppy0: floppy timeout called [ 1070.557053] no cont in shutdown! [ 1070.557056] floppy0: floppy_shutdown: timeout handler died. [ 1074.419509] floppy0: FDC access conflict! [ 1074.419782] BUG: unable to handle kernel NULL pointer dereference at 0000000000000008 [ 1074.421969] PGD 0 P4D 0 [ 1074.422320] Oops: 0000 [#1] SMP NOPTI [ 1074.422648] CPU: 10 PID: 3269 Comm: kworker/u256:4 Kdump: loaded [ 1074.423830] Hardware name: inspur Standard PC (i440FX + PIIX, 1996), BIOS 0.0.0 02/06/2015 [ 1074.424284] Workqueue: floppy floppy_work_workfn [floppy] [ 1074.424757] RIP: 0010:reset_interrupt+0x3a/0xa0 [floppy] The same NULL deref has also been reported by syzbot on upstream. While a stale reset_interrupt() sits in result(), unlock_fdc() can also clear cont and let a new request install another continuation, so a plain !cont check after result() is not enough. Bump cont_seq when clearing cont, sample it in schedule_bh() as bh_seq, and use cont in reset_interrupt() only when the sequences still match. Reported-by: syzbot+619e27617b2abe6b9b72@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=619e27617b2abe6b9b72 Link: https://lore.kernel.org/linux-block/00000000000093c4d105f9aa34d6@google.com/ Link: https://lists.openwall.net/linux-kernel/2021/10/27/56 Assisted-by: Cursor:Composer Signed-off-by: Yang Xiuwei <yangxiuwei@kylinos.cn>
|
Upstream branch: bd5f485 |
6e93723 to
0764ce2
Compare
Pull request for series with
subject: floppy: avoid stale cont use after BH is queued
version: 2
url: https://patchwork.kernel.org/project/linux-block/list/?series=1138048