Dāvis Mosāns
741b23a970
btrfs: prevent copying too big compressed lzo segment
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>
2022-02-15 19:59:09 +01:00
..
2021-11-10 21:16:56 +00:00
2021-06-29 10:53:48 -07:00
2021-10-18 14:43:22 -06:00
2021-12-16 09:10:13 -08: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-02-15 19:59:09 +01:00
2021-11-01 10:17:11 -07:00
2021-12-01 17:08:27 +01:00
2021-12-17 19:16:49 -06:00
2021-11-09 10:02:51 -08:00
2021-08-25 07:58:49 +02:00
2021-10-18 14:43:22 -06:00
2021-10-25 19:11:50 -07:00
2021-09-21 09:09:06 +02:00
2021-09-01 11:29:14 -05:00
2021-06-29 10:53:48 -07:00
2021-04-12 15:04:29 +02:00
2021-11-23 14:58:16 +08:00
2021-11-01 07:49:21 +09:00
2021-09-22 13:05:23 +02:00
2021-11-10 17:05:37 -08:00
2021-11-13 15:32:30 -08:00
2021-11-01 10:25:27 -07:00
2021-10-04 22:13:12 +01:00
2021-11-25 14:05:18 +01:00
2021-12-02 12:41:10 +01:00
2021-11-09 10:11:53 -08:00
2021-11-09 10:11:53 -08:00
2021-08-26 22:28:02 +02:00
2021-10-18 12:28:53 -07:00
2021-11-09 10:02:48 -08:00
2021-11-24 10:15:47 -08:00
2021-10-19 12:51:02 +02:00
2021-08-30 23:36:50 -04:00
2021-08-18 22:08:24 +02:00
2021-11-03 09:23:25 -07:00
2021-10-18 09:43:37 +02:00
2021-12-17 19:19:45 -06:00
2021-11-10 16:45:54 -08:00
2021-06-29 10:53:48 -07:00
2021-12-07 15:47:09 +00:00
2021-11-27 10:33:55 -08:00
2021-10-04 22:02:17 +01:00
2021-12-18 17:11:06 -05:00
2021-11-09 10:11:53 -08:00
2021-10-27 12:53:45 +02:00
2021-11-27 14:34:41 -08:00
2021-11-02 12:25:03 -07:00
2021-11-10 16:15:54 -08:00
2021-06-29 10:53:48 -07:00
2021-11-09 10:34:06 -08:00
2021-11-09 10:51:12 -08:00
2021-11-20 10:35:55 -08:00
2021-11-21 09:44:19 -08:00
2021-09-21 08:36:48 -07:00
2021-11-06 16:40:48 -07:00
2021-11-09 10:11:53 -08:00
2021-11-06 16:40:48 -07:00
2021-12-07 22:38:03 -06:00
2021-11-08 16:55:21 -08:00
2021-10-05 16:35:05 +02:00
2021-11-09 10:02:52 -08:00
2021-12-08 08:06:40 -05:00
2021-09-20 19:32:33 -07:00
2021-11-09 12:53:58 +01:00
2021-08-19 09:02:55 +09:00
2021-05-02 00:43:35 +09:00
2021-09-27 11:26:21 -07:00
2021-09-22 10:56:34 -07:00
2021-12-07 10:17:29 -08:00
2021-12-17 16:56:35 +09:00
2021-12-09 10:52:55 -08:00
2021-09-19 22:35:37 -04:00
2021-11-17 09:26:09 +01:00
2021-08-18 22:08:24 +02:00
2021-09-05 10:15:05 -07:00
2021-10-08 12:06:02 -05:00
2021-11-09 10:11:53 -08:00
2021-06-29 10:53:50 -07:00
2021-10-18 14:43:22 -06:00
2021-10-08 12:06:02 -05:00
2021-11-06 13:30:32 -07:00
2021-08-31 11:13:35 -07:00
2021-04-15 22:36:45 -04:00
2021-10-25 10:36:24 -06: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-10 16:15:54 -08:00
2021-09-03 10:08:28 -07:00
2021-04-07 13:56:43 -04:00
2021-12-13 10:55:30 -08:00
2021-08-23 01:25:40 -04:00
2021-09-03 09:58:12 -07:00
2021-09-07 16:07:47 -04:00
2021-11-01 17:29:10 -07:00
2021-11-17 10:36:35 -05:00
2021-11-09 10:11:53 -08:00
2021-12-22 20:34:32 -07:00
2021-12-13 09:04:01 -07:00
2021-10-19 05:49:54 -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-11-03 15:43:08 +01:00
2021-10-19 14:11:39 -04:00
2021-09-12 10:10:21 -07:00
2021-11-01 09:06:53 -07:00
2021-12-30 15:12:13 -08:00
2021-11-06 14:08:17 -07:00
2021-09-07 11:03:45 -07:00
2021-11-06 13:30:32 -07:00
2021-10-26 12:20:50 -04:00
2021-04-17 11:39:49 -07:00
2021-08-23 06:15:36 -04:00
2021-09-07 11:26:23 -07:00
2021-11-09 10:02:52 -08:00
2021-12-09 10:49:56 -08:00
2021-08-17 11:47:43 +02:00
2021-11-06 13:30:34 -07:00
2021-10-22 08:36:55 -06:00
2021-08-10 17:57:22 +02:00
2021-10-18 20:22:02 -10:00
2021-03-23 11:20:26 +01:00