Files
linux/fs
Gao Xiang 8a0fa49a77 UPSTREAM: erofs: fix out-of-bound access when z_erofs_gbuf_growsize() partially fails
If z_erofs_gbuf_growsize() partially fails on a global buffer due to
memory allocation failure or fault injection (as reported by syzbot [1]),
new pages need to be freed by comparing to the existing pages to avoid
memory leaks.

However, the old gbuf->pages[] array may not be large enough, which can
lead to null-ptr-deref or out-of-bound access.

Fix this by checking against gbuf->nrpages in advance.

[1] https://lore.kernel.org/r/000000000000f7b96e062018c6e3@google.com

Bug: 361157912
Reported-by: syzbot+242ee56aaa9585553766@syzkaller.appspotmail.com
Fixes: d6db47e571dc ("erofs: do not use pagepool in z_erofs_gbuf_growsize()")
Cc: <stable@vger.kernel.org> # 6.10+
Reviewed-by: Chunhai Guo <guochunhai@vivo.com>
Reviewed-by: Sandeep Dhavale <dhavale@google.com>
Change-Id: I5d6c8f63959db4a7e5bbf14da9b4c9ba04322c8c
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Link: https://lore.kernel.org/r/20240820085619.1375963-1-hsiangkao@linux.alibaba.com
(cherry picked from commit 0005e01e1e875c5e27130c5e2ed0189749d1e08a)
Signed-off-by: Sandeep Dhavale <dhavale@google.com>
2024-09-03 19:40:13 +00:00
..
2024-07-24 09:24:58 +00:00
2024-08-12 08:40:51 +00:00
2024-02-05 20:12:58 +00:00
2022-09-24 07:00:00 +02:00
2024-06-12 11:03:04 +02:00
2024-08-12 08:40:51 +00:00
2023-09-18 09:57:37 +00:00
2023-09-13 09:43:05 +02:00
2022-09-11 20:26:07 -07:00
2024-02-23 09:12:45 +01:00
2024-05-16 17:29:02 +00:00
2023-09-23 11:11:10 +02:00
2022-09-24 07:00:00 +02:00
2022-08-20 11:34:33 -04:00
2024-03-26 18:20:28 -04:00
2023-08-30 16:11:10 +02:00
2023-06-28 10:19:08 +00:00
2023-06-28 10:19:08 +00:00
2024-04-16 15:01:11 +00:00
2023-09-13 19:32:45 +00:00
2023-01-04 11:29:01 +01:00
2023-09-13 19:32:45 +00:00