[PATCH v4 0/5] liveupdate: serialization safety and race fixes

Pasha Tatashin posted 5 patches 1 week ago
There is a newer version of this series
kernel/kexec_core.c              |  8 ++++---
kernel/liveupdate/luo_file.c     |  5 +++--
kernel/liveupdate/luo_internal.h |  2 --
kernel/liveupdate/luo_session.c  | 38 ++++++++++++++++++++++++--------
4 files changed, 37 insertions(+), 16 deletions(-)
[PATCH v4 0/5] liveupdate: serialization safety and race fixes
Posted by Pasha Tatashin 1 week ago
This series addresses several issues related to the synchronization
between the reboot process and LUO session management.

Changes in v4:
- Addressed some comments from Sashiko:
- Reordered patches: "fix TOCTOU race" moved to #2.
- In "block session mutations during reboot" (#3):
  - Updated to use manual down_read()/up_read() in luo_session_create()
    to accommodate existing error labels and ensure consistent unlocking.
  - Added missing unlock of sh->rwsem in the success path of
    luo_session_serialize().

1. Skip LUO serialization for context-preserving kexec: A
preserve_context kexec returns to the current kernel, which is unrelated
to live update where state is passed to the next kernel. Skipping
serialization avoids unnecessary work and prevents sessions from being
left in a frozen state upon return.

2. Fix TOCTOU race in luo_session_retrieve(): Extend the rwsem lock
scope to prevent a session from being released between lookup and
mutex acquisition.

3. Block session mutations during reboot: During the reboot() syscall,
user processes may still be running concurrently and attempting to
mutate sessions. To prevent this, we introduce luo_session_serialize_rwsem.
All mutation operations (create, retrieve, release, ioctl) hold the
read lock. The serialization process holds the write lock indefinitely
on success, effectively freezing the subsystem.

4. Fix use-after-free in luo_file_unpreserve_files(): Reorder module_put()
to ensure the file handler module remains pinned while its operations
are being accessed during cleanup.

5. Remove unused ser field from struct luo_session: Clean up the
session structure by removing a field that was never utilized.

Tree: git.kernel.org/pub/scm/linux/kernel/git/tatashin/linux.git Branch:
luo-reboot-sync/v4

Pasha Tatashin (5):
  liveupdate: skip serialization for context-preserving kexec
  liveupdate: fix TOCTOU race in luo_session_retrieve()
  liveupdate: block session mutations during reboot
  liveupdate: fix u-a-f in luo_file_unpreserve_files() and
    luo_file_finish()
  liveupdate: Remove unused ser field from struct luo_session

 kernel/kexec_core.c              |  8 ++++---
 kernel/liveupdate/luo_file.c     |  5 +++--
 kernel/liveupdate/luo_internal.h |  2 --
 kernel/liveupdate/luo_session.c  | 38 ++++++++++++++++++++++++--------
 4 files changed, 37 insertions(+), 16 deletions(-)


base-commit: b1378127003b61930ce30064328640503ad3ef6d
-- 
2.53.0
Re: [PATCH v4 0/5] liveupdate: serialization safety and race fixes
Posted by Mike Rapoport 6 days, 21 hours ago
On Sun, May 17, 2026 at 07:26:45PM +0000, Pasha Tatashin wrote:
> This series addresses several issues related to the synchronization
> between the reboot process and LUO session management.
> 
> Tree: git.kernel.org/pub/scm/linux/kernel/git/tatashin/linux.git Branch:
> luo-reboot-sync/v4
> 
> Pasha Tatashin (5):
>   liveupdate: skip serialization for context-preserving kexec
>   liveupdate: fix TOCTOU race in luo_session_retrieve()
>   liveupdate: block session mutations during reboot
>   liveupdate: fix u-a-f in luo_file_unpreserve_files() and
>     luo_file_finish()
>   liveupdate: Remove unused ser field from struct luo_session

Acked-by: Mike Rapoport (Microsoft) <rppt@kernel.org>

for the series, with a small comment in patch 3/5

>  kernel/kexec_core.c              |  8 ++++---
>  kernel/liveupdate/luo_file.c     |  5 +++--
>  kernel/liveupdate/luo_internal.h |  2 --
>  kernel/liveupdate/luo_session.c  | 38 ++++++++++++++++++++++++--------
>  4 files changed, 37 insertions(+), 16 deletions(-)
> 
> 
> base-commit: b1378127003b61930ce30064328640503ad3ef6d
> -- 
> 2.53.0

-- 
Sincerely yours,
Mike.