mirror of
https://github.com/torvalds/linux.git
synced 2026-07-27 17:47:41 +02:00
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: 0153094d03 ("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>
This commit is contained in:
parent
5eff62b051
commit
d3ae9e7fdd
|
|
@ -463,12 +463,11 @@ int luo_session_retrieve(const char *name, struct file **filep)
|
|||
struct luo_session *it;
|
||||
int err;
|
||||
|
||||
scoped_guard(rwsem_read, &sh->rwsem) {
|
||||
list_for_each_entry(it, &sh->list, list) {
|
||||
if (!strncmp(it->name, name, sizeof(it->name))) {
|
||||
session = it;
|
||||
break;
|
||||
}
|
||||
guard(rwsem_read)(&sh->rwsem);
|
||||
list_for_each_entry(it, &sh->list, list) {
|
||||
if (!strncmp(it->name, name, sizeof(it->name))) {
|
||||
session = it;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user