bcachefs: fix stack corruption
authorYuxuan Shui <yshuiv7@gmail.com>
Fri, 22 May 2020 14:50:05 +0000 (15:50 +0100)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:08:39 +0000 (17:08 -0400)
commit22d8a33d30d7a28d0dd972f36cc48b80f585d67b
tree36d60ba534da1928bb60d66a188a10b6f702c048
parenta1b0da4555c16bf274f705dc76c9b297f54bf6c8
bcachefs: fix stack corruption

When a bkey_on_stack is passed to bch_read_indirect_extent, there is no
guarantee that it will be big enough to hold the bkey. And
bch_read_indirect_extent is not aware of bkey_on_stack to call realloc
on it. This cause a stack corruption.

This commit makes bch_read_indirect_extent aware of bkey_on_stack so it
can call realloc when appropriate.

Tested-by: Yuxuan Shui <yshuiv7@gmail.com>
Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/fs-io.c
fs/bcachefs/fs.c
fs/bcachefs/io.c
fs/bcachefs/io.h