Skip to content

Commit d3ae9e7

Browse files
soleenrppt
authored andcommitted
liveupdate: fix TOCTOU race in luo_session_retrieve()
Extend the scope of the rwsem_read lock in luo_session_retrieve() to overlap with the acquisition of the session mutex. This prevents a concurrent thread from releasing and freeing the session between the lookup and the mutex lock. Fixes: 0153094 ("liveupdate: luo_session: add sessions support") 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-3-pasha.tatashin@soleen.com Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
1 parent 5eff62b commit d3ae9e7

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

kernel/liveupdate/luo_session.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -463,12 +463,11 @@ int luo_session_retrieve(const char *name, struct file **filep)
463463
struct luo_session *it;
464464
int err;
465465

466-
scoped_guard(rwsem_read, &sh->rwsem) {
467-
list_for_each_entry(it, &sh->list, list) {
468-
if (!strncmp(it->name, name, sizeof(it->name))) {
469-
session = it;
470-
break;
471-
}
466+
guard(rwsem_read)(&sh->rwsem);
467+
list_for_each_entry(it, &sh->list, list) {
468+
if (!strncmp(it->name, name, sizeof(it->name))) {
469+
session = it;
470+
break;
472471
}
473472
}
474473

0 commit comments

Comments
 (0)