Centos-kernel-stream-9/fs
Lukas Czerner eff369565b jbd2: fix assertion 'jh->b_frozen_data == NULL' failure when journal aborted
Bugzilla: https://bugzilla.redhat.com/2145193
Tested: xfstests
Upstream Status: upstream

commit 4a734f0869f970b8a9b65062ea40b09a5da9dba8
Author: Zhihao Cheng <chengzhihao1@huawei.com>
    
    Following process will fail assertion 'jh->b_frozen_data == NULL' in
    jbd2_journal_dirty_metadata():
    
                       jbd2_journal_commit_transaction
    unlink(dir/a)
     jh->b_transaction = trans1
     jh->b_jlist = BJ_Metadata
                        journal->j_running_transaction = NULL
                        trans1->t_state = T_COMMIT
    unlink(dir/b)
     handle->h_trans = trans2
     do_get_write_access
      jh->b_modified = 0
      jh->b_frozen_data = frozen_buffer
      jh->b_next_transaction = trans2
     jbd2_journal_dirty_metadata
      is_handle_aborted
       is_journal_aborted // return false
    
               --> jbd2 abort <--
    
                         while (commit_transaction->t_buffers)
                          if (is_journal_aborted)
                           jbd2_journal_refile_buffer
                            __jbd2_journal_refile_buffer
                             WRITE_ONCE(jh->b_transaction,
    						jh->b_next_transaction)
                             WRITE_ONCE(jh->b_next_transaction, NULL)
                             __jbd2_journal_file_buffer(jh, BJ_Reserved)
            J_ASSERT_JH(jh, jh->b_frozen_data == NULL) // assertion failure !
    
    The reproducer (See detail in [Link]) reports:
     ------------[ cut here ]------------
     kernel BUG at fs/jbd2/transaction.c:1629!
     invalid opcode: 0000 [#1] PREEMPT SMP
     CPU: 2 PID: 584 Comm: unlink Tainted: G        W
     5.19.0-rc6-00115-g4a57a8400075-dirty #697
     RIP: 0010:jbd2_journal_dirty_metadata+0x3c5/0x470
     RSP: 0018:ffffc90000be7ce0 EFLAGS: 00010202
     Call Trace:
      <TASK>
      __ext4_handle_dirty_metadata+0xa0/0x290
      ext4_handle_dirty_dirblock+0x10c/0x1d0
      ext4_delete_entry+0x104/0x200
      __ext4_unlink+0x22b/0x360
      ext4_unlink+0x275/0x390
      vfs_unlink+0x20b/0x4c0
      do_unlinkat+0x42f/0x4c0
      __x64_sys_unlink+0x37/0x50
      do_syscall_64+0x35/0x80
    
    After journal aborting, __jbd2_journal_refile_buffer() is executed with
    holding @jh->b_state_lock, we can fix it by moving 'is_handle_aborted()'
    into the area protected by @jh->b_state_lock.
    
    Link: https://bugzilla.kernel.org/show_bug.cgi?id=216251
    Fixes: 470decc613 ("[PATCH] jbd2: initial copy of files from jbd")
    Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com>
    Link: https://lore.kernel.org/r/20220715125152.4022726-1-chengzhihao1@huawei.com
    Signed-off-by: Theodore Ts'o <tytso@mit.edu>
(cherry picked from commit 4a734f0869f970b8a9b65062ea40b09a5da9dba8)

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
2023-01-12 16:15:34 +01:00
..
9p netfs: Rename the netfs_io_request cleanup op and give it an op pointer 2022-08-29 11:10:17 -04:00
adfs fs: Convert __set_page_dirty_buffers to block_dirty_folio 2022-10-12 07:27:48 -04:00
affs fs: Convert __set_page_dirty_buffers to block_dirty_folio 2022-10-12 07:27:48 -04:00
afs afs: Convert afs_dir_set_page_dirty() to afs_dir_dirty_folio() 2022-10-12 07:27:48 -04:00
autofs
befs Merge: mm: Optimize list lru memory consumption 2022-05-09 09:48:03 +02:00
bfs fs: Convert __set_page_dirty_buffers to block_dirty_folio 2022-10-12 07:27:48 -04:00
btrfs Merge: iomap update to v5.16 2022-11-08 02:23:49 -05:00
cachefiles fs: get rid of the res2 iocb->ki_complete argument 2022-10-27 12:59:04 -04:00
ceph libceph: clean up ceph_osdc_start_request prototype 2022-12-12 13:37:08 +08:00
cifs Merge: cifs: fix NULL ptr dereference in refresh_mounts() 2023-01-10 15:03:59 +00:00
coda fs: Move many prototypes to pagemap.h 2022-07-10 10:44:17 -04:00
configfs fsnotify: fix fsnotify hooks in pseudo filesystems 2022-10-03 11:41:40 +02:00
cramfs
crypto fscrypt: remove fscrypt_operations::max_namelen 2023-01-12 13:59:48 +01:00
debugfs debugfs: add debugfs_lookup_and_remove() 2022-11-04 13:14:41 -04:00
devpts fsnotify: fix fsnotify hooks in pseudo filesystems 2022-10-03 11:41:40 +02:00
dlm Merge: fs: dlm: fix race in lowcomms 2022-12-09 16:16:36 +00:00
ecryptfs fs: Remove aops ->set_page_dirty 2022-10-12 07:27:48 -04:00
efivarfs
efs fs: allocate inode by using alloc_inode_sb() 2022-04-07 14:11:13 -04:00
erofs block: pass a block_device and opf to bio_alloc 2022-06-22 08:56:19 +08:00
exfat Merge: mm changes through v5.18 for 9.2 2022-10-23 19:49:41 +02:00
exportfs
ext2 Merge: mm changes through v5.18 for 9.2 2022-10-23 19:49:41 +02:00
ext4 ext4: block range must be validated before use in ext4_mb_clear_bb() 2023-01-12 16:15:34 +01:00
f2fs fscrypt: remove fscrypt_operations::max_namelen 2023-01-12 13:59:48 +01:00
fat fs: Convert __set_page_dirty_buffers to block_dirty_folio 2022-10-12 07:27:48 -04:00
freevxfs fs: allocate inode by using alloc_inode_sb() 2022-04-07 14:11:13 -04:00
fscache fscache: Convert fscache_set_page_dirty() to fscache_dirty_folio() 2022-10-12 07:27:48 -04:00
fuse Merge: fuse: add file_modified() to fallocate 2022-12-06 02:53:16 -05:00
gfs2 Merge: gfs2: Register fs after creating workqueues 2022-11-12 03:10:45 -05:00
hfs fs: Convert __set_page_dirty_buffers to block_dirty_folio 2022-10-12 07:27:48 -04:00
hfsplus Merge: mm changes through v5.18 for 9.2 2022-10-23 19:49:41 +02:00
hostfs fs: Convert trivial uses of __set_page_dirty_nobuffers to filemap_dirty_folio 2022-10-12 07:27:48 -04:00
hpfs fs: Convert __set_page_dirty_buffers to block_dirty_folio 2022-10-12 07:27:48 -04:00
hugetlbfs fs: Convert __set_page_dirty_no_writeback to noop_dirty_folio 2022-10-12 07:27:48 -04:00
iomap Merge: iomap update to v5.16 2022-11-08 02:23:49 -05:00
isofs fs/buffer: Combine two submit_bh() and ll_rw_block() arguments 2022-10-12 09:20:21 +08:00
jbd2 jbd2: fix assertion 'jh->b_frozen_data == NULL' failure when journal aborted 2023-01-12 16:15:34 +01:00
jffs2 exit: Rename complete_and_exit to kthread_complete_and_exit 2022-10-12 07:27:33 -04:00
jfs fs: Convert __set_page_dirty_buffers to block_dirty_folio 2022-10-12 07:27:48 -04:00
kernfs kernfs: remove redundant kernfs_rwsem declaration. 2022-12-13 15:45:02 -03:00
lockd NFSD: Move svc_serv_ops::svo_function into struct svc_serv 2022-09-26 09:34:15 -04:00
minix fs: Convert __set_page_dirty_buffers to block_dirty_folio 2022-10-12 07:27:48 -04:00
netfs netfs: Fix dodgy maths 2022-12-19 22:21:48 +08:00
nfs NFS: Allow very small rsize & wsize again 2022-12-21 09:50:14 -05:00
nfs_common
nfsd Merge: NFSD/SUNRPC - fix send buffer overflow 2022-12-14 15:16:50 +00:00
nilfs2 Merge: mm changes through v5.18 for 9.2 2022-10-23 19:49:41 +02:00
nls
notify inotify: show inotify mask flags in proc fdinfo 2022-10-03 11:41:41 +02:00
ntfs Merge: mm changes through v5.18 for 9.2 2022-10-23 19:49:41 +02:00
ocfs2 Merge: mm changes through v5.18 for 9.2 2022-10-23 19:49:41 +02:00
omfs fs: Convert __set_page_dirty_buffers to block_dirty_folio 2022-10-12 07:27:48 -04:00
openpromfs fs: allocate inode by using alloc_inode_sb() 2022-04-07 14:11:13 -04:00
orangefs fs: Convert trivial uses of __set_page_dirty_nobuffers to filemap_dirty_folio 2022-10-12 07:27:48 -04:00
overlayfs fs: get rid of the res2 iocb->ki_complete argument 2022-10-27 12:59:04 -04:00
proc vmcore: convert read_from_oldmem() to take an iov_iter 2022-11-16 03:47:02 -05:00
pstore pstore: Don't use semaphores in always-atomic-context code 2022-08-25 10:45:07 -06:00
qnx4 fs: allocate inode by using alloc_inode_sb() 2022-04-07 14:11:13 -04:00
qnx6 fs: allocate inode by using alloc_inode_sb() 2022-04-07 14:11:13 -04:00
quota quota: make dquot_quota_sync return errors from ->sync_fs 2022-05-09 10:04:04 +02:00
ramfs
reiserfs Merge: mm changes through v5.18 for 9.2 2022-10-23 19:49:41 +02:00
romfs fs: allocate inode by using alloc_inode_sb() 2022-04-07 14:11:13 -04:00
smbfs_common Add various fsctl structs 2022-11-02 06:03:46 +10:00
squashfs block: turn bio_kmalloc into a simple kmalloc wrapper 2022-06-22 08:58:00 +08:00
sysfs
sysv fs: Convert __set_page_dirty_buffers to block_dirty_folio 2022-10-12 07:27:48 -04:00
tracefs
ubifs fscrypt: remove fscrypt_operations::max_namelen 2023-01-12 13:59:48 +01:00
udf Merge: mm changes through v5.18 for 9.2 2022-10-23 19:49:41 +02:00
ufs Merge: mm changes through v5.18 for 9.2 2022-10-23 19:49:41 +02:00
unicode
vboxsf fs: Convert trivial uses of __set_page_dirty_nobuffers to filemap_dirty_folio 2022-10-12 07:27:48 -04:00
verity fs: Remove ->readpages address space operation 2022-10-12 07:28:04 -04:00
xfs Merge: XFS update to v5.16 2022-11-23 02:46:01 -05:00
zonefs Merge: mm changes through v5.18 for 9.2 2022-10-23 19:49:41 +02:00
Kconfig Merge: mm changes through v5.18 for 9.2 2022-10-23 19:49:41 +02:00
Kconfig.binfmt
Makefile cachefiles: Introduce rewritten driver 2022-08-22 12:31:34 -04:00
aio.c fs: get rid of the res2 iocb->ki_complete argument 2022-10-27 12:59:04 -04:00
anon_inodes.c fs: add anon_inode_getfile_secure() similar to anon_inode_getfd_secure() 2022-07-15 15:17:03 -04:00
attr.c vfs: Check the truncate maximum size in inode_newsize_ok() 2022-08-22 12:32:28 -04:00
bad_inode.c
binfmt_aout.c
binfmt_elf.c coredump: Limit coredumps to a single thread group 2022-10-12 07:27:25 -04:00
binfmt_elf_fdpic.c coredump: Limit coredumps to a single thread group 2022-10-12 07:27:25 -04:00
binfmt_flat.c
binfmt_misc.c
binfmt_script.c
buffer.c Merge: iomap update to v5.16 2022-11-08 02:23:49 -05:00
char_dev.c
compat_binfmt_elf.c
coredump.c signal: Remove the helper signal_group_exit 2022-10-12 07:27:36 -04:00
d_path.c
dax.c dax: fix missing writeprotect the pte entry 2022-11-08 10:11:36 -07:00
dcache.c fs/dcache: export d_same_name() helper 2022-12-12 13:35:11 +08:00
direct-io.c Merge: block: update with v6.1-rc2 2022-11-03 13:30:02 -04:00
drop_caches.c
eventfd.c
eventpoll.c
exec.c Merge: mm changes through v5.18 for 9.2 2022-10-23 19:49:41 +02:00
fcntl.c fs: remove fs.f_write_hint 2022-10-12 09:20:11 +08:00
fhandle.c
file.c
file_table.c SUNRPC: Ensure we flush any closed sockets before xs_xprt_free() 2022-07-07 12:21:26 -04:00
filesystems.c
fs-writeback.c writeback: avoid use-after-free after removing device 2022-11-08 10:11:41 -07:00
fs_context.c
fs_parser.c namei: Standardize callers of filename_lookup() 2022-11-08 09:30:48 -05:00
fs_pin.c
fs_struct.c
fs_types.c
fsopen.c
init.c
inode.c writeback: Fix inode->i_io_list not be protected by inode->i_lock error 2022-11-08 10:11:38 -07:00
internal.h io-uring: Make statx API stable 2022-11-08 09:31:48 -05:00
io-wq.c io-wq: use IO_WQ_ACCT_NR rather than hardcoded number 2022-11-08 09:17:48 -05:00
io-wq.h io_uring: stop using io_wq_work as an fd placeholder 2022-11-08 17:52:33 -05:00
io_uring.c io_uring: don't attempt to IOPOLL for MSG_RING requests 2022-11-08 17:52:39 -05:00
ioctl.c fs: allow cross-vfsmount reflink/dedupe 2022-11-23 12:44:03 +01:00
kernel_read_file.c fs/kernel_read_file: allow to read files up-to ssize_t 2022-11-16 03:47:02 -05:00
libfs.c fs: Convert __set_page_dirty_no_writeback to noop_dirty_folio 2022-10-12 07:27:48 -04:00
locks.c
mbcache.c mbcache: add functions to delete entry if unused 2023-01-12 16:15:33 +01:00
mount.h
mpage.c Merge: mm changes through v5.18 for 9.2 2022-10-23 19:49:41 +02:00
namei.c namei: Standardize callers of filename_lookup() 2022-11-08 09:30:48 -05:00
namespace.c fs: add is_idmapped_mnt() helper 2022-08-22 12:31:31 -04:00
no-block.c
nsfs.c
open.c fs: remove fs.f_write_hint 2022-10-12 09:20:11 +08:00
pipe.c pipe: Fix missing lock in pipe_resize_ring() 2022-11-15 14:29:36 +08:00
pnode.c
pnode.h
posix_acl.c
proc_namespace.c fs: add is_idmapped_mnt() helper 2022-08-22 12:31:31 -04:00
read_write.c vfs: fix copy_file_range() regression in cross-fs copies 2022-11-11 15:06:43 -05:00
readdir.c
remap_range.c fs: allow cross-vfsmount reflink/dedupe 2022-11-23 12:44:03 +01:00
select.c net: Don't include filter.h from net/sock.h 2022-07-13 10:49:16 +02:00
seq_file.c
signalfd.c signal: Requeue signals in the appropriate queue 2022-10-12 07:27:31 -04:00
splice.c mm: Convert remove_mapping() to take a folio 2022-07-10 10:44:17 -04:00
stack.c
stat.c io-uring: Make statx API stable 2022-11-08 09:31:48 -05:00
statfs.c
super.c mm: remove cleancache 2022-10-12 07:27:42 -04:00
sync.c vfs: make sync_filesystem return errors from ->sync_fs 2022-05-25 20:05:33 +02:00
timerfd.c
userfaultfd.c userfaultfd: provide properly masked address for huge-pages 2022-10-12 07:28:09 -04:00
utimes.c
xattr.c