Skip to content

jfs: fix use-after-free races during unmount

Tristan Madani lkml stable 2 versions – New

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest2 patches 0 repliesNew
  2. v11 patch 0 repliesSuperseded

Changes in v2 from the cover letter

- Split into two patches (one per race)
- NEW: patch 2/2 adds atomic io_count to drain in-flight BIO completions before lbmLogShutdown frees lbufs

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2jfs: drain lazy commit queue during unmount to prevent use-after-freefs/jfs/jfs_txnmgr.c fs/jfs/jfs_txnmgr.h fs/jfs/jfs_umount.c+44 -00 replies
2/2jfs: wait for in-flight log I/O before freeing lbufs in lbmLogShutdownfs/jfs/jfs_logmgr.c fs/jfs/jfs_logmgr.h+14 -00 replies

Reviews trailers per patch

None of the 2 patches has a Reviewed-by or Acked-by.

Patch[email protected][email protected]
1/2T-b T-b
2/2

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v2 thread

Cover letter [PATCH v2 0/2] jfs: fix use-after-free races during unmount

From: Tristan Madani <[email protected]>

Two related UAF races exist in JFS unmount:

1. jfs_lazycommit accesses freed jfs_sb_info/jfs_log after unmount proceeds past jfs_flush_journal but before jfsCommit drains TxAnchor.unlock_queue.

2. lbmIODone (BIO completion in softirq) accesses freed lbuf fields after lbmLogShutdown frees all lbufs from the freelist.

V1 fixed only race #1. Syzbot testing showed that race #2 can still trigger independently. This V2 adds a second patch for the BIO completion race.

Changes since v1:
- Split into two patches (one per race)
- NEW: patch 2/2 adds atomic io_count to drain in-flight BIO completions before lbmLogShutdown frees lbufs

Tristan Madani (2):
jfs: drain lazy commit queue during unmount to prevent use-after-free
jfs: wait for in-flight log I/O before freeing lbufs in lbmLogShutdown

 fs/jfs/jfs_logmgr.c | 10 ++++++++++
 fs/jfs/jfs_logmgr.h |  2 ++
 fs/jfs/jfs_txnmgr.c | 35 +++++++++++++++++++++++++++++++++++
 fs/jfs/jfs_txnmgr.h |  1 +
 fs/jfs/jfs_umount.c  |  8 ++++++++
 5 files changed, 56 insertions(+)
Signature · 1 line
2.47.3