Skip to content

Commit 2bdef2b

Browse files
AstralBobgregkh
authored andcommitted
gfs2: bypass signal_our_withdraw if no journal
[ Upstream commit d5bf630 ] Before this patch, function signal_our_withdraw referenced the journal inode immediately. But corrupt file systems may have some invalid journals, in which case our attempt to read it in will withdraw and the resulting signal_our_withdraw would dereference the NULL value. This patch adds a check to signal_our_withdraw so that if the journal has not yet been initialized, it simply returns and does the old-style withdraw. Thanks, Andy Price, for his analysis. Reported-by: syzbot+50a8a9cf8127f2c6f5df@syzkaller.appspotmail.com Fixes: 601ef0d ("gfs2: Force withdraw to replay journals and wait for it to finish") Signed-off-by: Bob Peterson <rpeterso@redhat.com> Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent a602e83 commit 2bdef2b

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

‎fs/gfs2/util.c‎

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,17 +119,22 @@ void gfs2_freeze_unlock(struct gfs2_holder *freeze_gh)
119119
static void signal_our_withdraw(struct gfs2_sbd *sdp)
120120
{
121121
struct gfs2_glock *live_gl = sdp->sd_live_gh.gh_gl;
122-
struct inode *inode = sdp->sd_jdesc->jd_inode;
123-
struct gfs2_inode *ip = GFS2_I(inode);
124-
struct gfs2_glock *i_gl = ip->i_gl;
125-
u64 no_formal_ino = ip->i_no_formal_ino;
122+
struct inode *inode;
123+
struct gfs2_inode *ip;
124+
struct gfs2_glock *i_gl;
125+
u64 no_formal_ino;
126126
int log_write_allowed = test_bit(SDF_JOURNAL_LIVE, &sdp->sd_flags);
127127
int ret = 0;
128128
int tries;
129129

130-
if (test_bit(SDF_NORECOVERY, &sdp->sd_flags))
130+
if (test_bit(SDF_NORECOVERY, &sdp->sd_flags) || !sdp->sd_jdesc)
131131
return;
132132

133+
inode = sdp->sd_jdesc->jd_inode;
134+
ip = GFS2_I(inode);
135+
i_gl = ip->i_gl;
136+
no_formal_ino = ip->i_no_formal_ino;
137+
133138
/* Prevent any glock dq until withdraw recovery is complete */
134139
set_bit(SDF_WITHDRAW_RECOVERY, &sdp->sd_flags);
135140
/*

0 commit comments

Comments
 (0)