Gao Xiang 118a8cf504 erofs: fix inconsistent per-file compression format
EROFS can select compression algorithms on a per-file basis, and each
per-file compression algorithm needs to be marked in the on-disk
superblock for initialization.

However, syzkaller can generate inconsistent crafted images that use
an unsupported algorithmtype for specific inodes, e.g. use MicroLZMA
algorithmtype even it's not set in `sbi->available_compr_algs`.  This
can lead to an unexpected "BUG: kernel NULL pointer dereference" if
the corresponding decompressor isn't built-in.

Fix this by checking against `sbi->available_compr_algs` for each
m_algorithmformat request.  Incorrect !erofs_sb_has_compr_cfgs preset
bitmap is now fixed together since it was harmless previously.

Reported-by: <bugreport@ubisectech.com>
Fixes: 8f89926290c4 ("erofs: get compression algorithms directly on mapping")
Fixes: 622ceaddb764 ("erofs: lzma compression support")
Reviewed-by: Yue Hu <huyue2@coolpad.com>
Link: https://lore.kernel.org/r/20240113150602.1471050-1-hsiangkao@linux.alibaba.com
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
2024-01-13 23:58:08 +08:00
..
2023-11-04 09:20:04 -10:00
2023-11-07 12:11:26 -08:00
2023-11-07 12:11:26 -08:00
2023-12-17 09:27:36 -08:00
2023-11-10 09:52:56 -08:00
2023-10-30 09:47:13 -10:00
2023-11-07 12:11:26 -08:00
2023-11-07 12:11:26 -08:00
2023-11-03 22:24:11 +09:00
2023-11-07 12:11:26 -08:00
2023-11-07 12:11:26 -08:00
2023-11-07 12:11:26 -08:00
2023-11-07 11:54:17 -08:00
2023-10-30 09:47:13 -10:00
2023-10-30 09:47:13 -10:00
2023-11-07 12:11:26 -08:00
2023-11-07 12:11:26 -08:00
2023-11-07 12:11:26 -08:00
2023-11-03 15:15:47 -10:00
2023-11-08 13:39:16 -08:00
2024-01-05 13:12:29 -08:00
2023-08-31 12:07:34 -05:00
2023-11-07 12:11:26 -08:00
2023-11-07 12:11:26 -08:00
2023-11-07 12:11:26 -08:00
2023-10-30 09:47:13 -10:00
2023-12-20 12:04:03 -08:00
2023-10-30 19:26:39 -10:00
2023-10-30 09:47:13 -10:00
\n
2023-11-02 08:19:51 -10:00
2023-12-13 11:14:09 -05:00
2023-11-25 08:57:09 -08:00
2023-10-30 19:28:19 -10:00
2023-10-30 19:28:19 -10:00
2023-06-26 09:50:21 -07:00
2023-05-17 09:16:59 +02:00
2023-08-21 13:46:25 -07:00
2023-10-30 09:14:19 -10:00
2023-10-19 11:02:47 +02:00
2023-08-28 11:04:18 -07:00
2023-08-19 12:12:12 +02:00
2023-10-22 17:08:07 -04:00
2023-10-30 09:14:19 -10:00
2023-05-19 04:30:22 +02:00
2023-05-19 04:30:22 +02:00
2023-08-15 08:32:45 +02:00
2023-11-07 11:46:31 -08:00