Skip to content

Commit 291dcd3

Browse files
soleenrppt
authored andcommitted
liveupdate: fix u-a-f in luo_file_unpreserve_files() and luo_file_finish()
In luo_file_unpreserve_files() and luo_file_finish(), reorder module_put() and xa_erase() to ensure the file handler module remains pinned while its operations are being accessed. Specifically, luo_get_id() dereferences fh->ops->get_id, so the module reference must be held until after xa_erase() (which calls luo_get_id) completes. For luo_file_finish(), this requires moving the module_put() call out of the luo_file_finish_one() helper and into the main loop of luo_file_finish() itself. Fixes: 00d0b37 ("liveupdate: prevent double management of files") Acked-by: Mike Rapoport (Microsoft) <rppt@kernel.org> Reviewed-by: Pratyush Yadav (Google) <pratyush@kernel.org> Signed-off-by: Pasha Tatashin <pasha.tatashin@soleen.com> Link: https://patch.msgid.link/20260527202737.1345192-5-pasha.tatashin@soleen.com Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
1 parent bb1328b commit 291dcd3

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

kernel/liveupdate/luo_file.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -385,10 +385,11 @@ void luo_file_unpreserve_files(struct luo_file_set *file_set)
385385
args.private_data = luo_file->private_data;
386386
luo_file->fh->ops->unpreserve(&args);
387387
luo_flb_file_unpreserve(luo_file->fh);
388-
module_put(luo_file->fh->ops->owner);
389388

390389
xa_erase(&luo_preserved_files,
391390
luo_get_id(luo_file->fh, luo_file->file));
391+
module_put(luo_file->fh->ops->owner);
392+
392393
list_del(&luo_file->list);
393394
file_set->count--;
394395

@@ -677,7 +678,6 @@ static void luo_file_finish_one(struct luo_file_set *file_set,
677678

678679
luo_file->fh->ops->finish(&args);
679680
luo_flb_file_finish(luo_file->fh);
680-
module_put(luo_file->fh->ops->owner);
681681
}
682682

683683
/**
@@ -738,6 +738,7 @@ int luo_file_finish(struct luo_file_set *file_set)
738738
luo_get_id(luo_file->fh, luo_file->file));
739739
fput(luo_file->file);
740740
}
741+
module_put(luo_file->fh->ops->owner);
741742
list_del(&luo_file->list);
742743
file_set->count--;
743744
mutex_destroy(&luo_file->mutex);

0 commit comments

Comments
 (0)