mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-08-03 15:55:38 +00:00
bcachefs: Fix lookup_inode_for_snapshot()
This fixes a use-after-free. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
parent
6b20d746ad
commit
20e6d9a8d4
1 changed files with 5 additions and 1 deletions
|
@ -682,6 +682,7 @@ found:
|
|||
|
||||
if (snapshot != i->snapshot && !is_whiteout) {
|
||||
struct inode_walker_entry new = *i;
|
||||
size_t pos;
|
||||
int ret;
|
||||
|
||||
new.snapshot = snapshot;
|
||||
|
@ -693,9 +694,12 @@ found:
|
|||
while (i > w->inodes.data && i[-1].snapshot > snapshot)
|
||||
--i;
|
||||
|
||||
ret = darray_insert_item(&w->inodes, i - w->inodes.data, new);
|
||||
pos = i - w->inodes.data;
|
||||
ret = darray_insert_item(&w->inodes, pos, new);
|
||||
if (ret)
|
||||
return ERR_PTR(ret);
|
||||
|
||||
i = w->inodes.data + pos;
|
||||
}
|
||||
|
||||
return i;
|
||||
|
|
Loading…
Add table
Reference in a new issue