bcachefs: Fix rare use after free in read path
authorKent Overstreet <kent.overstreet@gmail.com>
Sun, 25 Oct 2020 00:56:47 +0000 (20:56 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:08:45 +0000 (17:08 -0400)
commit13dcd4abcd8d4e177f4f75ea3f5c8838a8a8c3c3
tree10225ec9e40dec10e87c9344257b29840a93278b
parente00711d2cae7b8e178bb615c757260107b2d4872
bcachefs: Fix rare use after free in read path

If the bkey_on_stack_reassemble() call in __bch2_read_indirect_extent()
reallocates the buffer, k in bch2_read - which we pointed at the
bkey_on_stack buffer - will now point to a stale buffer. Whoops.

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