original_kernel/fs/gfs2
Bob Peterson 504a10d9e4 gfs2: Don't deref jdesc in evict
On corrupt gfs2 file systems the evict code can try to reference the
journal descriptor structure, jdesc, after it has been freed and set to
NULL. The sequence of events is:

init_journal()
...
fail_jindex:
   gfs2_jindex_free(sdp); <------frees journals, sets jdesc = NULL
      if (gfs2_holder_initialized(&ji_gh))
         gfs2_glock_dq_uninit(&ji_gh);
fail:
   iput(sdp->sd_jindex); <--references jdesc in evict_linked_inode
      evict()
         gfs2_evict_inode()
            evict_linked_inode()
               ret = gfs2_trans_begin(sdp, 0, sdp->sd_jdesc->jd_blocks);
<------references the now freed/zeroed sd_jdesc pointer.

The call to gfs2_trans_begin is done because the truncate_inode_pages
call can cause gfs2 events that require a transaction, such as removing
journaled data (jdata) blocks from the journal.

This patch fixes the problem by adding a check for sdp->sd_jdesc to
function gfs2_evict_inode. In theory, this should only happen to corrupt
gfs2 file systems, when gfs2 detects the problem, reports it, then tries
to evict all the system inodes it has read in up to that point.

Reported-by: Yang Lan <lanyang0908@gmail.com>
Signed-off-by: Bob Peterson <rpeterso@redhat.com>
Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
2023-05-10 17:15:18 +02:00
..
Kconfig
Makefile
acl.c
acl.h
aops.c
aops.h
bmap.c gfs2: Eliminate gfs2_trim_blocks 2023-04-18 14:40:12 +02:00
bmap.h gfs2: Eliminate gfs2_trim_blocks 2023-04-18 14:40:12 +02:00
dentry.c Reinstate "GFS2: free disk inode which is deleted by remote node -V2" 2023-03-23 19:37:56 +01:00
dir.c
dir.h
export.c
file.c
gfs2.h
glock.c
glock.h
glops.c gfs2: gfs2_ail_empty_gl no log flush on error 2023-04-25 11:07:16 +02:00
glops.h
incore.h
inode.c gfs2: Remove ghs[] from gfs2_unlink 2023-03-27 14:42:16 +02:00
inode.h
lock_dlm.c
log.c
log.h
lops.c
lops.h
main.c
meta_io.c
meta_io.h
ops_fstype.c gfs2: Use gfs2_holder_initialized for jindex 2023-04-18 14:46:16 +02:00
quota.c
quota.h
recovery.c
recovery.h
rgrp.c
rgrp.h
super.c gfs2: Don't deref jdesc in evict 2023-05-10 17:15:18 +02:00
super.h
sys.c Driver core changes for 6.3-rc1 2023-02-24 12:58:55 -08:00
sys.h
trace_gfs2.h
trans.c
trans.h
util.c
util.h
xattr.c fs: drop unused posix acl handlers 2023-03-06 09:57:12 +01:00
xattr.h