Dāvis Mosāns
8df508b7a4
btrfs: prevent copying too big compressed lzo segment
...
commit 741b23a970a79d5d3a1db2d64fa2c7b375a4febb upstream.
Compressed length can be corrupted to be a lot larger than memory
we have allocated for buffer.
This will cause memcpy in copy_compressed_segment to write outside
of allocated memory.
This mostly results in stuck read syscall but sometimes when using
btrfs send can get #GP
kernel: general protection fault, probably for non-canonical address 0x841551d5c1000: 0000 [#1 ] PREEMPT SMP NOPTI
kernel: CPU: 17 PID: 264 Comm: kworker/u256:7 Tainted: P OE 5.17.0-rc2-1 #12
kernel: Workqueue: btrfs-endio btrfs_work_helper [btrfs]
kernel: RIP: 0010:lzo_decompress_bio (./include/linux/fortify-string.h:225 fs/btrfs/lzo.c:322 fs/btrfs/lzo.c:394) btrfs
Code starting with the faulting instruction
===========================================
0:* 48 8b 06 mov (%rsi),%rax <-- trapping instruction
3: 48 8d 79 08 lea 0x8(%rcx),%rdi
7: 48 83 e7 f8 and $0xfffffffffffffff8,%rdi
b: 48 89 01 mov %rax,(%rcx)
e: 44 89 f0 mov %r14d,%eax
11: 48 8b 54 06 f8 mov -0x8(%rsi,%rax,1),%rdx
kernel: RSP: 0018:ffffb110812efd50 EFLAGS: 00010212
kernel: RAX: 0000000000001000 RBX: 000000009ca264c8 RCX: ffff98996e6d8ff8
kernel: RDX: 0000000000000064 RSI: 000841551d5c1000 RDI: ffffffff9500435d
kernel: RBP: ffff989a3be856c0 R08: 0000000000000000 R09: 0000000000000000
kernel: R10: 0000000000000000 R11: 0000000000001000 R12: ffff98996e6d8000
kernel: R13: 0000000000000008 R14: 0000000000001000 R15: 000841551d5c1000
kernel: FS: 0000000000000000(0000) GS:ffff98a09d640000(0000) knlGS:0000000000000000
kernel: CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
kernel: CR2: 00001e9f984d9ea8 CR3: 000000014971a000 CR4: 00000000003506e0
kernel: Call Trace:
kernel: <TASK>
kernel: end_compressed_bio_read (fs/btrfs/compression.c:104 fs/btrfs/compression.c:1363 fs/btrfs/compression.c:323) btrfs
kernel: end_workqueue_fn (fs/btrfs/disk-io.c:1923) btrfs
kernel: btrfs_work_helper (fs/btrfs/async-thread.c:326) btrfs
kernel: process_one_work (./arch/x86/include/asm/jump_label.h:27 ./include/linux/jump_label.h:212 ./include/trace/events/workqueue.h:108 kernel/workqueue.c:2312)
kernel: worker_thread (./include/linux/list.h:292 kernel/workqueue.c:2455)
kernel: ? process_one_work (kernel/workqueue.c:2397)
kernel: kthread (kernel/kthread.c:377)
kernel: ? kthread_complete_and_exit (kernel/kthread.c:332)
kernel: ret_from_fork (arch/x86/entry/entry_64.S:301)
kernel: </TASK>
CC: stable@vger.kernel.org # 4.9+
Signed-off-by: Dāvis Mosāns <davispuh@gmail.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-03-02 11:48:07 +01:00
..
2022-02-08 18:34:04 +01:00
2021-06-29 10:53:48 -07:00
2021-06-29 10:53:48 -07:00
2021-12-22 09:32:45 +01:00
2021-10-20 21:09:02 -04:00
2021-08-19 09:02:55 +09:00
2021-06-29 10:53:48 -07:00
2022-03-02 11:48:07 +01:00
2021-08-27 13:34:02 +01:00
2022-02-01 17:27:14 +01:00
2022-02-23 12:03:14 +01:00
2022-03-02 11:48:02 +01:00
2021-11-18 19:16:11 +01:00
2022-01-27 11:03:55 +01:00
2022-02-01 17:27:01 +01:00
2022-01-27 11:04:23 +01:00
2021-06-29 10:53:48 -07:00
2021-12-01 09:04:50 +01:00
2021-11-18 19:15:52 +01:00
2021-09-22 13:05:23 +02:00
2022-02-08 18:34:13 +01:00
2022-01-27 11:05:30 +01:00
2021-09-02 12:32:12 -07:00
2021-10-04 22:13:12 +01:00
2022-01-27 11:05:08 +01:00
2022-02-16 12:56:18 +01:00
2021-07-15 10:13:49 -07:00
2021-07-01 11:06:06 -07:00
2021-08-26 22:28:02 +02:00
2021-07-27 11:00:36 +02:00
2021-07-23 17:43:28 -07:00
2021-12-01 09:04:44 +01:00
2021-11-12 15:05:50 +01:00
2022-02-01 17:27:05 +01:00
2022-01-27 11:04:49 +01:00
2021-11-18 19:16:48 +01:00
2021-10-04 10:27:18 +02:00
2022-02-23 12:03:18 +01:00
2022-02-05 12:38:57 +01:00
2021-06-29 10:53:48 -07:00
2021-12-29 12:28:59 +01:00
2022-02-23 12:03:15 +01:00
2021-10-04 22:02:17 +01:00
2022-02-16 12:56:06 +01:00
2021-09-08 12:55:35 -07:00
2022-02-05 12:38:59 +01:00
2021-07-03 11:30:04 -07:00
2021-10-15 09:58:11 -04:00
2022-02-01 17:27:05 +01:00
2021-06-29 10:53:48 -07:00
2022-01-20 09:13:13 +01:00
2022-02-05 12:38:59 +01:00
2022-02-23 12:03:02 +01:00
2021-11-25 09:48:42 +01:00
2021-09-21 08:36:48 -07:00
2022-02-23 12:03:06 +01:00
2021-06-29 10:53:48 -07:00
2021-09-03 15:33:47 -07:00
2021-12-14 10:57:12 +01:00
2021-08-16 10:50:32 -06:00
2021-08-06 13:05:28 +02:00
2021-06-29 10:53:48 -07:00
2022-03-02 11:48:05 +01:00
2022-01-27 11:05:07 +01:00
2022-02-01 17:27:00 +01:00
2021-08-19 09:02:55 +09:00
2021-09-27 11:26:21 -07:00
2021-09-22 10:56:34 -07:00
2022-01-11 15:35:16 +01:00
2021-12-22 09:32:48 +01:00
2021-12-14 10:57:22 +01:00
2021-11-25 09:48:46 +01:00
2021-08-18 22:08:24 +02:00
2021-09-05 10:15:05 -07:00
2021-09-03 18:42:01 +02:00
2021-10-03 14:02:58 -07:00
2021-06-29 10:53:50 -07:00
2021-09-24 16:13:35 -07:00
2021-09-08 11:50:27 -07:00
2021-09-02 10:07:29 -07:00
2021-08-31 11:13:35 -07:00
2021-09-03 09:58:10 -07:00
2021-09-06 07:20:56 -04:00
2021-09-09 13:25:49 -07:00
2021-11-25 09:49:06 +01:00
2021-09-03 10:08:28 -07:00
2022-01-16 09:12:42 +01:00
2021-08-23 01:25:40 -04:00
2022-01-20 09:13:14 +01:00
2021-09-07 16:07:47 -04:00
2021-09-03 10:08:28 -07:00
2021-11-25 09:49:08 +01:00
2021-09-07 08:39:40 -06:00
2022-03-02 11:47:56 +01:00
2021-12-22 09:32:51 +01:00
2021-08-29 07:55:55 -06:00
2021-08-31 11:06:32 -07:00
2021-09-12 10:10:21 -07:00
2021-07-25 22:33:03 -07:00
2021-10-18 20:22:03 -10:00
2021-06-29 10:53:48 -07:00
2021-09-07 11:21:48 -07:00
2021-09-12 10:10:21 -07:00
2022-02-01 17:27:15 +01:00
2022-01-05 12:42:39 +01:00
2021-11-18 19:17:17 +01:00
2021-09-07 11:03:45 -07:00
2021-08-18 22:08:24 +02:00
2021-08-24 07:52:45 -04:00
2021-08-23 06:15:36 -04:00
2022-01-29 10:58:25 +01:00
2021-07-19 17:18:48 -07:00
2021-12-14 10:57:15 +01:00
2021-08-17 11:47:43 +02:00
2022-02-23 12:03:05 +01:00
2021-08-10 17:57:22 +02:00
2021-10-18 20:22:02 -10:00