Ye Bin
0c98057be9
nbd: Fix use-after-free in pid_show
...
I got issue as follows:
[ 263.886511] BUG: KASAN: use-after-free in pid_show+0x11f/0x13f
[ 263.888359] Read of size 4 at addr ffff8880bf0648c0 by task cat/746
[ 263.890479] CPU: 0 PID: 746 Comm: cat Not tainted 4.19.90-dirty #140
[ 263.893162] Call Trace:
[ 263.893509] dump_stack+0x108/0x15f
[ 263.893999] print_address_description+0xa5/0x372
[ 263.894641] kasan_report.cold+0x236/0x2a8
[ 263.895696] __asan_report_load4_noabort+0x25/0x30
[ 263.896365] pid_show+0x11f/0x13f
[ 263.897422] dev_attr_show+0x48/0x90
[ 263.898361] sysfs_kf_seq_show+0x24d/0x4b0
[ 263.899479] kernfs_seq_show+0x14e/0x1b0
[ 263.900029] seq_read+0x43f/0x1150
[ 263.900499] kernfs_fop_read+0xc7/0x5a0
[ 263.903764] vfs_read+0x113/0x350
[ 263.904231] ksys_read+0x103/0x270
[ 263.905230] __x64_sys_read+0x77/0xc0
[ 263.906284] do_syscall_64+0x106/0x360
[ 263.906797] entry_SYSCALL_64_after_hwframe+0x44/0xa9
Reproduce this issue as follows:
1. nbd-server 8000 /tmp/disk
2. nbd-client localhost 8000 /dev/nbd1
3. cat /sys/block/nbd1/pid
Then trigger use-after-free in pid_show.
Reason is after do step '2', nbd-client progress is already exit. So
it's task_struct already freed.
To solve this issue, revert part of 6521d39a64b3's modify and remove
useless 'recv_task' member of nbd_device.
Fixes: 6521d39a64b3 ("nbd: Remove variable 'pid'")
Signed-off-by: Ye Bin <yebin10@huawei.com>
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Link: https://lore.kernel.org/r/20211020073959.2679255-1-yebin10@huawei.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
2021-10-20 08:09:56 -06:00
..
2021-10-16 08:45:46 -07:00
2021-09-14 09:02:13 +02:00
2021-10-14 12:22:47 +09:00
2021-10-17 17:17:28 -10:00
2021-09-01 08:44:42 -07:00
2021-10-20 08:09:56 -06:00
2021-08-19 17:08:31 +02:00
2021-10-17 17:17:28 -10:00
2021-10-18 14:41:37 -06:00
2021-09-12 11:44:58 -07:00
2021-10-13 11:44:42 -07:00
2021-09-03 11:11:54 -07:00
2021-09-21 17:53:54 +02:00
2021-09-17 12:05:04 -07:00
2021-09-07 12:38:59 -07:00
2021-09-24 15:58:41 +08:00
2021-09-09 11:48:27 -07:00
2021-09-09 11:39:57 -07:00
2021-09-08 11:50:26 -07:00
2021-09-09 11:07:47 -07:00
2021-09-07 12:42:21 +05:30
2021-10-14 11:46:03 +02:00
2021-09-11 09:47:33 -07:00
2021-10-17 17:30:49 -10:00
2021-09-27 14:00:41 -07:00
2021-10-06 13:04:04 +02:00
2021-10-18 06:17:01 -06:00
2021-09-27 10:00:43 +02:00
2021-09-15 17:18:56 -07:00
2021-10-02 05:14:11 -07:00
2021-09-14 09:03:16 +02:00
2021-10-04 21:56:20 +02:00
2021-10-17 17:10:00 -10:00
2021-09-27 14:49:49 -03:00
2021-10-17 16:57:06 -10:00
2021-09-13 15:49:55 +03:00
2021-10-13 21:28:44 +02:00
2021-09-27 17:38:49 +02:00
2021-09-22 14:44:25 +01:00
2021-10-09 13:42:51 +01:00
2021-08-20 11:00:08 +02:00
2021-09-14 13:23:22 -07:00
2021-08-31 22:57:45 -05:00
2021-09-14 11:22:26 +02:00
2021-10-18 14:50:35 -06:00
2021-10-08 11:57:54 -07:00
2021-09-01 08:44:42 -07:00
2021-09-07 12:38:59 -07:00
2021-10-15 10:54:02 +02:00
2021-10-18 06:17:02 -06:00
2021-10-18 06:17:01 -06:00
2021-10-14 18:21:39 -04:00
2021-09-23 12:53:06 +01:00
2021-09-07 13:05:02 -07:00
2021-10-18 06:17:36 -06:00
2021-10-19 12:41:09 -06:00
2021-10-13 15:09:58 +02:00
2021-10-06 11:12:28 +02:00
2021-08-30 19:25:42 +02:00
2021-09-09 12:44:31 +02:00
2021-09-02 13:16:00 -07:00
2021-10-16 09:00:46 -07:00
2021-09-20 12:43:34 +01:00
2021-09-08 12:55:35 -07:00
2021-10-08 11:57:54 -07:00
2021-10-11 16:39:25 +02:00
2021-08-30 11:47:32 -07:00
2021-08-25 20:12:16 +02:00
2021-10-07 09:50:31 -07:00
2021-09-02 22:27:46 +02:00
2021-09-17 13:16:38 +01:00
2021-09-01 15:25:28 -07:00
2021-09-14 10:20:19 +02:00
2021-10-18 06:17:36 -06:00
2021-10-18 14:40:40 -06:00
2021-09-01 08:44:42 -07:00
2021-10-17 17:17:28 -10:00
2021-09-01 10:29:29 -07:00
2021-10-14 13:32:19 +01:00
2021-10-17 17:10:00 -10:00
2021-10-18 06:17:02 -06:00
2021-10-12 13:24:39 +02:00
2021-09-21 15:17:11 +02:00
2021-10-06 17:53:49 -06:00
2021-10-17 17:06:31 -10:00
2021-10-15 15:04:02 +02:00
2021-09-14 18:10:43 -04:00
2021-09-23 14:12:36 -06:00
2021-10-17 18:17:19 -10:00
2021-10-06 11:12:28 +02:00
2021-10-13 08:35:36 -04:00
2021-09-27 11:57:19 -07:00
2021-10-08 12:55:23 -07:00
2021-10-07 16:51:26 +02:00
2021-08-14 15:54:09 -06:00