mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs.git
synced 2026-10-28 12:53:14 +01:00
dm-integrity: fix NULL pointer dereference when the 'R' flag is used
If the dm-integrity device has the SB_FLAG_DIRTY_BITMAP flag set and the
user activates the device in the 'R' mode, a crash in dm_integrity_resume
happens because the function attempts to read the journal containing the
bitmap.
This patch makes dm-integrity skip any writes to the device in
dm_integrity_resume if the device is activated in the 'R' mode.
Signed-off-by: Mikulas Patocka <[email protected]>
Fixes: 468dfca38b ("dm integrity: add a bitmap mode")
Cc: [email protected]
This commit is contained in:
1 parent
2ccb8878c1
commit
7d4d4f3b66
1 file changed
+5
@@ -3875,6 +3875,10 @@ static void dm_integrity_resume(struct dm_target *ti)
|
||||
r = sync_rw_sb(ic, REQ_OP_READ);
|
||||
if (r)
|
||||
dm_integrity_io_error(ic, "reading superblock", r);
|
||||
|
||||
if (ic->mode == 'R')
|
||||
goto skip_writes;
|
||||
|
||||
if ((ic->sb->flags & flags) != flags) {
|
||||
ic->sb->flags |= flags;
|
||||
r = sync_rw_sb(ic, REQ_OP_WRITE | REQ_FUA);
|
||||
@@ -3984,6 +3988,7 @@ static void dm_integrity_resume(struct dm_target *ti)
|
||||
}
|
||||
}
|
||||
|
||||
skip_writes:
|
||||
ic->reboot_notifier.notifier_call = dm_integrity_reboot;
|
||||
ic->reboot_notifier.next = NULL;
|
||||
ic->reboot_notifier.priority = INT_MAX - 1; /* be notified after md and before hardware drivers */
|
||||
|
||||
Reference in new issue
Block a user