Whamcloud - gitweb
LU-8465 e2fsck: fix race in ext2fs_read_bitmaps() 65/40065/2
authorWang Shilong <wshilong@ddn.com>
Sun, 27 Sep 2020 05:01:13 +0000 (13:01 +0800)
committerWang Shilong <wshilong@whamcloud.com>
Mon, 28 Sep 2020 06:41:21 +0000 (06:41 +0000)
commit3b4ff5f207054b6f5507a986ad8522a08c2d8228
tree5d400279951fbc992f14241f34fece607eba33b8
parent2b281447e28f7cf0bfe3950b427b33e797b6bb64
LU-8465 e2fsck: fix race in ext2fs_read_bitmaps()

During corruption testing hiting following segfault:

Multiple threads triggered to read bitmaps
Signal (11) SIGSEGV si_code=SEGV_MAPERR fault addr=0x200
./e2fsck[0x4382ae]
/lib64/libpthread.so.0(+0x14b20)[0x7f5854d2fb20]
./e2fsck(ext2fs_rb_insert_color+0xc)[0x46ac0c]
./e2fsck[0x467bb4]
./e2fsck[0x467e6d]
./e2fsck[0x45ba95]
./e2fsck[0x45c124]
/lib64/libpthread.so.0(+0x94e2)[0x7f5854d244e2]
/lib64/libc.so.6(clone+0x43)[0x7f5854beb6c3]

Problem is @block_map might be set NULL if one of
thread exit, move such kind of cleanup operation
to main thread after all threads exit.

Another potential problem is e2fsck_read_bitmap()
could be called during pass1, this need be serialized,
serialize it in the pass1.

Signed-off-by: Wang Shilong <wshilong@ddn.com>
Change-Id: I6cf2f4a11f3cf04bfa70d1e1f8b97fbcc33b79dc
Reviewed-on: https://review.whamcloud.com/40065
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
e2fsck/pass1.c
lib/ext2fs/rw_bitmaps.c