Yang Yang
90ada91f46
jffs2: check the validity of dstlen in jffs2_zlib_compress()
...
KASAN reports a BUG when download file in jffs2 filesystem.It is
because when dstlen == 1, cpage_out will write array out of bounds.
Actually, data will not be compressed in jffs2_zlib_compress() if
data's length less than 4.
[ 393.799778] BUG: KASAN: slab-out-of-bounds in jffs2_rtime_compress+0x214/0x2f0 at addr ffff800062e3b281
[ 393.809166] Write of size 1 by task tftp/2918
[ 393.813526] CPU: 3 PID: 2918 Comm: tftp Tainted: G B 4.9.115-rt93-EMBSYS-CGEL-6.1.R6-dirty #1
[ 393.823173] Hardware name: LS1043A RDB Board (DT)
[ 393.827870] Call trace:
[ 393.830322] [<ffff20000808c700>] dump_backtrace+0x0/0x2f0
[ 393.835721] [<ffff20000808ca04>] show_stack+0x14/0x20
[ 393.840774] [<ffff2000086ef700>] dump_stack+0x90/0xb0
[ 393.845829] [<ffff20000827b19c>] kasan_object_err+0x24/0x80
[ 393.851402] [<ffff20000827b404>] kasan_report_error+0x1b4/0x4d8
[ 393.857323] [<ffff20000827bae8>] kasan_report+0x38/0x40
[ 393.862548] [<ffff200008279d44>] __asan_store1+0x4c/0x58
[ 393.867859] [<ffff2000084ce2ec>] jffs2_rtime_compress+0x214/0x2f0
[ 393.873955] [<ffff2000084bb3b0>] jffs2_selected_compress+0x178/0x2a0
[ 393.880308] [<ffff2000084bb530>] jffs2_compress+0x58/0x478
[ 393.885796] [<ffff2000084c5b34>] jffs2_write_inode_range+0x13c/0x450
[ 393.892150] [<ffff2000084be0b8>] jffs2_write_end+0x2a8/0x4a0
[ 393.897811] [<ffff2000081f3008>] generic_perform_write+0x1c0/0x280
[ 393.903990] [<ffff2000081f5074>] __generic_file_write_iter+0x1c4/0x228
[ 393.910517] [<ffff2000081f5210>] generic_file_write_iter+0x138/0x288
[ 393.916870] [<ffff20000829ec1c>] __vfs_write+0x1b4/0x238
[ 393.922181] [<ffff20000829ff00>] vfs_write+0xd0/0x238
[ 393.927232] [<ffff2000082a1ba8>] SyS_write+0xa0/0x110
[ 393.932283] [<ffff20000808429c>] __sys_trace_return+0x0/0x4
[ 393.937851] Object at ffff800062e3b280, in cache kmalloc-64 size: 64
[ 393.944197] Allocated:
[ 393.946552] PID = 2918
[ 393.948913] save_stack_trace_tsk+0x0/0x220
[ 393.953096] save_stack_trace+0x18/0x20
[ 393.956932] kasan_kmalloc+0xd8/0x188
[ 393.960594] __kmalloc+0x144/0x238
[ 393.963994] jffs2_selected_compress+0x48/0x2a0
[ 393.968524] jffs2_compress+0x58/0x478
[ 393.972273] jffs2_write_inode_range+0x13c/0x450
[ 393.976889] jffs2_write_end+0x2a8/0x4a0
[ 393.980810] generic_perform_write+0x1c0/0x280
[ 393.985251] __generic_file_write_iter+0x1c4/0x228
[ 393.990040] generic_file_write_iter+0x138/0x288
[ 393.994655] __vfs_write+0x1b4/0x238
[ 393.998228] vfs_write+0xd0/0x238
[ 394.001543] SyS_write+0xa0/0x110
[ 394.004856] __sys_trace_return+0x0/0x4
[ 394.008684] Freed:
[ 394.010691] PID = 2918
[ 394.013051] save_stack_trace_tsk+0x0/0x220
[ 394.017233] save_stack_trace+0x18/0x20
[ 394.021069] kasan_slab_free+0x88/0x188
[ 394.024902] kfree+0x6c/0x1d8
[ 394.027868] jffs2_sum_write_sumnode+0x2c4/0x880
[ 394.032486] jffs2_do_reserve_space+0x198/0x598
[ 394.037016] jffs2_reserve_space+0x3f8/0x4d8
[ 394.041286] jffs2_write_inode_range+0xf0/0x450
[ 394.045816] jffs2_write_end+0x2a8/0x4a0
[ 394.049737] generic_perform_write+0x1c0/0x280
[ 394.054179] __generic_file_write_iter+0x1c4/0x228
[ 394.058968] generic_file_write_iter+0x138/0x288
[ 394.063583] __vfs_write+0x1b4/0x238
[ 394.067157] vfs_write+0xd0/0x238
[ 394.070470] SyS_write+0xa0/0x110
[ 394.073783] __sys_trace_return+0x0/0x4
[ 394.077612] Memory state around the buggy address:
[ 394.082404] ffff800062e3b180: 00 00 00 00 00 00 00 00 fc fc fc fc fc fc fc fc
[ 394.089623] ffff800062e3b200: 00 00 00 00 00 00 00 00 fc fc fc fc fc fc fc fc
[ 394.096842] >ffff800062e3b280: 01 fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
[ 394.104056] ^
[ 394.107283] ffff800062e3b300: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
[ 394.114502] ffff800062e3b380: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
[ 394.121718] ==================================================================
Signed-off-by: Yang Yang <yang.yang29@zte.com.cn>
Signed-off-by: Richard Weinberger <richard@nod.at>
2021-02-12 21:53:23 +01:00
..
2020-12-21 10:28:02 -08:00
2020-10-24 12:26:05 -07:00
2020-10-24 12:26:05 -07:00
2021-01-29 21:38:11 -08:00
2020-12-10 12:42:59 -06:00
2020-09-18 16:45:50 -04:00
2020-12-15 22:46:18 -08:00
2021-01-29 13:54:40 -08:00
2021-01-20 11:33:51 -08:00
2021-01-04 17:31:32 +01:00
2021-02-05 13:17:48 -06:00
2020-05-05 09:22:21 -06:00
2020-11-14 10:22:45 +01:00
2020-09-18 16:45:50 -04:00
2020-12-17 11:18:00 -08:00
2020-10-30 08:37:39 +01:00
2020-11-10 12:14:20 -06:00
2021-01-26 01:47:14 +00:00
2020-11-25 16:55:02 +01:00
2020-09-18 16:45:50 -04:00
2020-12-10 11:07:40 +08:00
2020-12-22 12:31:17 +09:00
2020-12-09 09:39:38 -05:00
2020-11-23 10:36:53 +01:00
2021-01-15 14:54:24 -08:00
2020-12-17 11:18:00 -08:00
2020-09-18 16:45:50 -04:00
2020-06-03 16:27:18 -07:00
2020-12-10 15:33:14 +01:00
2020-12-03 17:04:41 +01:00
2020-10-29 17:22:59 -05:00
2020-10-29 17:22:59 -05:00
2020-12-21 21:42:29 -05:00
2020-09-18 16:45:50 -04:00
2021-02-05 11:03:47 -08:00
2020-12-02 18:28:05 -08:00
2020-10-29 17:22:59 -05:00
2020-12-17 13:30:45 -05:00
2021-02-12 21:53:23 +01:00
2020-11-13 16:03:07 -06:00
2021-01-21 18:30:28 +01:00
2020-12-16 07:57:37 -05:00
2020-09-18 16:45:50 -04:00
2021-01-24 20:52:31 -05:00
2020-12-09 09:38:34 -05:00
2021-01-12 08:54:14 -05:00
2020-12-15 22:46:17 -08:00
2020-06-14 01:57:21 +09:00
2020-12-28 11:58:59 +01:00
2020-12-15 12:13:37 -08:00
2020-12-15 12:13:37 -08:00
2020-09-22 23:39:45 -04:00
2020-12-16 16:14:08 -05:00
2021-01-28 10:22:48 +01:00
2021-01-24 10:34:53 -08:00
2020-12-17 13:22:17 -08:00
2020-09-18 16:45:50 -04:00
2020-09-18 16:45:50 -04:00
2020-12-17 11:00:37 -08:00
2020-10-16 11:11:22 -07:00
2020-11-26 16:57:28 +01:00
2020-10-24 12:26:05 -07:00
2020-10-24 12:26:05 -07:00
2020-10-02 12:02:30 +02:00
2020-09-18 16:45:50 -04:00
2021-02-12 21:53:23 +01:00
2021-01-18 12:06:33 +01:00
2020-10-24 12:26:05 -07:00
2020-09-10 14:03:31 -07:00
2020-10-15 15:11:56 -07:00
2020-12-14 12:18:19 -08:00
2020-12-18 12:50:18 -08:00
2021-01-04 09:06:42 +09:00
2020-12-15 12:53:37 -08:00
2020-06-03 23:16:55 -04:00
2020-05-07 16:55:47 -05:00
2020-10-16 11:11:21 -07:00
2020-12-15 19:29:43 -08:00
2020-06-04 19:18:29 -07:00
2020-08-24 08:49:13 +10:00
2020-06-04 19:18:29 -07:00
2020-06-04 19:18:29 -07:00
2021-01-27 09:14:12 -07:00
2020-12-16 12:57:51 -08:00
2020-05-14 16:44:23 +02:00
2020-10-26 13:46:47 +01:00
2020-12-15 19:29:43 -08:00
2020-10-14 14:54:45 -07:00
2020-12-15 22:46:19 -08:00
2020-12-10 17:33:17 -05:00
2020-10-15 15:03:10 -07:00
2020-04-27 02:07:40 -04:00
2020-11-15 09:49:10 -05:00
2020-12-19 11:18:38 -08:00
2020-12-16 12:10:40 -08:00
2020-11-05 07:44:15 -05:00
2020-10-25 20:02:08 -04:00
2020-12-30 19:36:54 -07:00
2020-04-10 15:36:22 -07:00
2020-08-23 17:36:59 -05:00
2020-10-13 18:38:27 -07:00
2020-07-29 16:14:27 +02:00
2021-01-13 17:26:21 +01:00
2020-08-23 17:36:59 -05:00
2020-08-04 21:02:38 -04:00
2020-12-25 10:54:29 -08:00
2020-12-16 12:57:51 -08:00
2021-02-04 12:42:58 -07:00
2020-12-20 10:47:42 -07:00
2020-12-20 10:47:42 -07:00
2020-07-31 08:16:01 +02:00
2020-08-07 11:33:24 -07:00
2020-06-14 01:57:21 +09:00
2020-10-05 13:37:04 +02:00
2020-12-17 11:18:00 -08:00
2020-12-15 19:29:43 -08:00
2020-10-23 11:33:41 -07:00
2020-08-19 14:14:19 +02:00
2020-06-02 10:59:07 -07:00
2020-12-25 10:54:29 -08:00
2021-01-04 15:31:58 -05:00
2020-05-13 11:41:22 +02:00
2020-12-15 19:29:43 -08:00
2021-01-25 12:32:26 -08:00
2020-04-27 10:37:14 -04:00
2020-12-10 17:33:17 -05:00
2020-06-08 11:04:19 -07:00
2020-12-27 12:00:36 -08:00
2020-10-23 11:33:41 -07:00
2020-07-31 08:16:00 +02:00
2020-12-14 15:26:13 +01:00
2021-01-08 11:06:29 -08:00
2020-11-15 22:12:53 -05:00
2020-08-23 17:36:59 -05:00
2020-10-24 12:40:18 -07:00
2020-09-26 22:55:05 -04:00
2020-12-01 14:53:39 -07:00
2020-12-01 14:53:39 -07:00
2020-06-09 15:40:50 -07:00
2020-12-15 12:13:46 -08:00
2020-07-31 08:16:01 +02:00
2020-12-14 15:26:13 +01:00