Re: [PATCH V2] ocfs2: prevent release journal inode after journal shutdown

From: Joseph Qi
Date: Wed Aug 20 2025 - 01:52:12 EST




On 2025/8/19 21:41, Edward Adam Davis wrote:
> Before calling ocfs2_delete_osb(), ocfs2_journal_shutdown() has already
> been executed in ocfs2_dismount_volume(), so osb->journal must be NULL.
> Therefore, the following calltrace will inevitably fail when it reaches
> jbd2_journal_release_jbd_inode().
>
> ocfs2_dismount_volume()->
> ocfs2_delete_osb()->
> ocfs2_free_slot_info()->
> __ocfs2_free_slot_info()->
> evict()->
> ocfs2_evict_inode()->
> ocfs2_clear_inode()->
> jbd2_journal_release_jbd_inode(osb->journal->j_journal,
>
> Adding osb->journal checks will prevent null-ptr-deref during the above
> execution path.
>
> Reported-by: syzbot+47d8cb2f2cc1517e515a@xxxxxxxxxxxxxxxxxxxxxxxxx
> Closes: https://syzkaller.appspot.com/bug?extid=47d8cb2f2cc1517e515a
> Tested-by: syzbot+47d8cb2f2cc1517e515a@xxxxxxxxxxxxxxxxxxxxxxxxx
> Signed-off-by: Edward Adam Davis <eadavis@xxxxxx>

Reviewed-by: Joseph Qi <joseph.qi@xxxxxxxxxxxxxxxxx>
> ---
> V1 -> V2: Corrected typos and comments.
>
> fs/ocfs2/inode.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/fs/ocfs2/inode.c b/fs/ocfs2/inode.c
> index 14bf440ea4df..6c4f78f473fb 100644
> --- a/fs/ocfs2/inode.c
> +++ b/fs/ocfs2/inode.c
> @@ -1281,6 +1281,9 @@ static void ocfs2_clear_inode(struct inode *inode)
> * the journal is flushed before journal shutdown. Thus it is safe to
> * have inodes get cleaned up after journal shutdown.
> */
> + if (!osb->journal)
> + return;
> +
> jbd2_journal_release_jbd_inode(osb->journal->j_journal,
> &oi->ip_jinode);
> }