Guoyu Huang
5de0b5247c
io_uring: Fix NULL pointer dereference in loop_rw_iter()
...
commit 2dd2111d0d383df104b144e0d1f6b5a00cb7cd88 upstream.
loop_rw_iter() does not check whether the file has a read or
write function. This can lead to NULL pointer dereference
when the user passes in a file descriptor that does not have
read or write function.
The crash log looks like this:
[ 99.834071] BUG: kernel NULL pointer dereference, address: 0000000000000000
[ 99.835364] #PF: supervisor instruction fetch in kernel mode
[ 99.836522] #PF: error_code(0x0010) - not-present page
[ 99.837771] PGD 8000000079d62067 P4D 8000000079d62067 PUD 79d8c067 PMD 0
[ 99.839649] Oops: 0010 [#2 ] SMP PTI
[ 99.840591] CPU: 1 PID: 333 Comm: io_wqe_worker-0 Tainted: G D 5.8.0 #2
[ 99.842622] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.13.0-1ubuntu1 04/01/2014
[ 99.845140] RIP: 0010:0x0
[ 99.845840] Code: Bad RIP value.
[ 99.846672] RSP: 0018:ffffa1c7c01ebc08 EFLAGS: 00010202
[ 99.848018] RAX: 0000000000000000 RBX: ffff92363bd67300 RCX: ffff92363d461208
[ 99.849854] RDX: 0000000000000010 RSI: 00007ffdbf696bb0 RDI: ffff92363bd67300
[ 99.851743] RBP: ffffa1c7c01ebc40 R08: 0000000000000000 R09: 0000000000000000
[ 99.853394] R10: ffffffff9ec692a0 R11: 0000000000000000 R12: 0000000000000010
[ 99.855148] R13: 0000000000000000 R14: ffff92363d461208 R15: ffffa1c7c01ebc68
[ 99.856914] FS: 0000000000000000(0000) GS:ffff92363dd00000(0000) knlGS:0000000000000000
[ 99.858651] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[ 99.860032] CR2: ffffffffffffffd6 CR3: 000000007ac66000 CR4: 00000000000006e0
[ 99.861979] Call Trace:
[ 99.862617] loop_rw_iter.part.0+0xad/0x110
[ 99.863838] io_write+0x2ae/0x380
[ 99.864644] ? kvm_sched_clock_read+0x11/0x20
[ 99.865595] ? sched_clock+0x9/0x10
[ 99.866453] ? sched_clock_cpu+0x11/0xb0
[ 99.867326] ? newidle_balance+0x1d4/0x3c0
[ 99.868283] io_issue_sqe+0xd8f/0x1340
[ 99.869216] ? __switch_to+0x7f/0x450
[ 99.870280] ? __switch_to_asm+0x42/0x70
[ 99.871254] ? __switch_to_asm+0x36/0x70
[ 99.872133] ? lock_timer_base+0x72/0xa0
[ 99.873155] ? switch_mm_irqs_off+0x1bf/0x420
[ 99.874152] io_wq_submit_work+0x64/0x180
[ 99.875192] ? kthread_use_mm+0x71/0x100
[ 99.876132] io_worker_handle_work+0x267/0x440
[ 99.877233] io_wqe_worker+0x297/0x350
[ 99.878145] kthread+0x112/0x150
[ 99.878849] ? __io_worker_unuse+0x100/0x100
[ 99.879935] ? kthread_park+0x90/0x90
[ 99.880874] ret_from_fork+0x22/0x30
[ 99.881679] Modules linked in:
[ 99.882493] CR2: 0000000000000000
[ 99.883324] ---[ end trace 4453745f4673190b ]---
[ 99.884289] RIP: 0010:0x0
[ 99.884837] Code: Bad RIP value.
[ 99.885492] RSP: 0018:ffffa1c7c01ebc08 EFLAGS: 00010202
[ 99.886851] RAX: 0000000000000000 RBX: ffff92363acd7f00 RCX: ffff92363d461608
[ 99.888561] RDX: 0000000000000010 RSI: 00007ffe040d9e10 RDI: ffff92363acd7f00
[ 99.890203] RBP: ffffa1c7c01ebc40 R08: 0000000000000000 R09: 0000000000000000
[ 99.891907] R10: ffffffff9ec692a0 R11: 0000000000000000 R12: 0000000000000010
[ 99.894106] R13: 0000000000000000 R14: ffff92363d461608 R15: ffffa1c7c01ebc68
[ 99.896079] FS: 0000000000000000(0000) GS:ffff92363dd00000(0000) knlGS:0000000000000000
[ 99.898017] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[ 99.899197] CR2: ffffffffffffffd6 CR3: 000000007ac66000 CR4: 00000000000006e0
Fixes: 32960613b7c3 ("io_uring: correctly handle non ->{read,write}_iter() file_operations")
Cc: stable@vger.kernel.org
Signed-off-by: Guoyu Huang <hgy5945@gmail.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-08-19 08:16:29 +02:00
..
2020-08-19 08:16:24 +02:00
2019-07-19 11:33:22 -07:00
2020-01-17 19:48:50 +01:00
2020-06-30 15:37:02 -04:00
2019-10-25 00:03:11 -04:00
2019-08-30 07:27:17 -07:00
2019-08-30 07:27:17 -07:00
2020-08-19 08:16:01 +02:00
2020-06-03 08:21:11 +02:00
2020-06-24 17:50:37 +02:00
2020-07-29 10:18:41 +02:00
2019-09-19 09:42:37 -07:00
2020-05-27 17:46:30 +02:00
2019-11-23 21:44:49 -05:00
2020-03-18 07:17:53 +01:00
2020-04-17 10:50:02 +02:00
2019-09-03 09:30:56 -04:00
2020-08-19 08:16:21 +02:00
2020-02-28 17:22:26 +01:00
2019-07-19 10:42:02 -07:00
2019-08-30 07:27:17 -07:00
2020-08-19 08:16:26 +02:00
2019-11-10 11:56:05 -05:00
2020-04-23 10:36:41 +02:00
2020-08-07 09:34:02 +02:00
2020-06-24 17:50:50 +02:00
2020-06-17 16:40:36 +02:00
2019-08-30 07:27:17 -07:00
2019-07-10 18:43:43 -07:00
2020-07-29 10:18:28 +02:00
2020-07-22 09:32:53 +02:00
2020-04-17 10:50:22 +02:00
2019-08-30 08:11:25 -07:00
2020-01-04 19:19:19 +01:00
2020-01-04 19:17:31 +01:00
2019-09-19 09:42:37 -07:00
2020-06-24 17:50:48 +02:00
2019-12-04 22:31:06 +01:00
2019-09-19 09:42:37 -07:00
2020-08-19 08:16:12 +02:00
2019-07-03 17:52:09 -04:00
2020-08-19 08:16:28 +02:00
2020-08-19 08:16:25 +02:00
2020-08-11 15:33:42 +02:00
2020-06-17 16:40:29 +02:00
2020-06-17 16:40:24 +02:00
2020-02-11 04:35:12 -08:00
2020-08-19 08:16:21 +02:00
2019-08-30 08:11:25 -07:00
2019-07-19 10:42:02 -07:00
2020-02-24 08:37:02 +01:00
2020-07-22 09:33:12 +02:00
2020-06-17 16:40:33 +02:00
2020-08-19 08:16:27 +02:00
2019-08-30 07:27:17 -07:00
2019-08-30 07:27:17 -07:00
2020-01-12 12:21:37 +01:00
2019-09-12 21:05:34 -04:00
2020-02-24 08:37:00 +01:00
2019-09-19 10:06:57 -07:00
2019-09-19 10:06:57 -07:00
2019-07-19 10:42:02 -07:00
2019-08-30 07:27:18 -07:00
2019-10-12 20:49:07 -04:00
2020-05-27 17:46:14 +02:00
2020-02-24 08:36:44 +01:00
2019-09-19 09:42:37 -07:00
2019-09-17 11:48:24 -04:00
2019-08-12 19:33:50 -07:00
2020-08-19 08:16:17 +02:00
2020-06-17 16:40:24 +02:00
2019-07-19 10:42:02 -07:00
2020-02-11 04:35:12 -08:00
2020-06-03 08:21:27 +02:00
2019-07-16 19:23:22 -07:00
2019-07-19 10:42:02 -07:00
2020-06-24 17:50:47 +02:00
2020-04-23 10:36:15 +02:00
2020-01-14 20:08:18 +01:00
2020-01-09 10:20:05 +01:00
2019-06-19 17:09:55 +02:00
2020-05-14 07:58:27 +02:00
2019-08-30 19:31:09 -04:00
2020-03-05 16:43:36 +01:00
2019-07-20 09:15:51 -07:00
2019-10-14 15:04:01 -07:00
2020-01-12 12:21:37 +01:00
2020-02-11 04:35:37 -08:00
2020-05-14 07:58:26 +02:00
2020-05-20 08:20:34 +02:00
2019-08-07 21:51:47 -04:00
2019-08-19 11:00:39 -04:00
2020-05-27 17:46:12 +02:00
2020-04-17 10:50:21 +02:00
2019-09-06 21:28:49 +02:00
2019-09-12 21:06:14 -04:00
2019-07-16 22:52:37 -04:00
2020-02-11 04:35:11 -08:00
2019-07-19 10:42:02 -07:00
2020-03-25 08:25:58 +01:00
2020-01-17 19:48:21 +01:00
2020-08-19 08:16:29 +02:00
2019-12-17 19:55:30 +01:00
2019-09-18 16:59:14 -07:00
2019-06-24 09:16:47 +10:00
2020-04-01 11:02:17 +02:00
2020-03-25 08:25:41 +01:00
2019-09-18 16:59:14 -07:00
2019-07-16 22:52:37 -04:00
2020-01-17 19:48:21 +01:00
2020-03-05 16:43:48 +01:00
2019-10-16 23:15:09 -04:00
2020-03-18 07:17:51 +01:00
2020-05-02 08:48:44 +02:00
2019-09-06 21:28:49 +02:00
2020-02-11 04:35:23 -08:00
2020-01-29 16:45:31 +01:00
2019-07-16 19:23:25 -07:00
2019-08-13 16:06:52 -07:00
2019-12-17 19:56:52 +01:00
2019-10-03 14:21:35 -07:00
2020-05-06 08:15:15 +02:00
2019-08-01 20:51:23 +02:00
2020-01-04 19:18:32 +01:00
2020-02-11 04:35:12 -08:00
2020-08-11 15:33:39 +02:00