FAILED: patch "[PATCH] dm-verity: don't restart or panic on errors during system" failed to apply to 5.10-stable tree
Subsystems (2)
[email protected]
maintainerThe patch below does not apply to the 5.10-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.10.y
git checkout FETCH_HEAD
git cherry-pick -x 47930d1236d2988cdc580c10d3af21b6b02d7ece
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026112517-most-helium-cf76@gregkh' --subject-prefix 'PATCH 5.10.y' 'HEAD^..'
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 47930d1236d2988cdc580c10d3af21b6b02d7ece Mon Sep 17 00:00:00 2001
From: Weijiang Zhou <[email protected]>
Date: Wed, 11 Nov 2026 20:24:42 +0100
Subject: [PATCH] dm-verity: don't restart or panic on errors during system
shutdown
Commit 252bd1256396 ("dm verity: skip verity work if I/O error when system is shutting down") stopped I/O errors during shutdown from triggering a restart, since devices may legitimately be gone by then. Errors that reach verity_handle_err(), e.g. through a failed hash block read followed by a failed FEC attempt, are not covered and still call kernel_restart() or panic().
During a reboot that is both wrong (nothing is corrupt) and harmful: it races with the reboot already in progress and replaces its reason with "dm-verity device corrupted", which bootloaders such as Android's treat as a verity failure and switch the device to EIO mode.
Apply the same shutdown check in verity_handle_err(). Corruption is still logged, recorded in hash_failed and reported via uevent, and the I/O still fails.
drivers/md/dm-verity-target.c +18 -9
@@ -170,6 +170,15 @@ static void verity_hash_at_level(struct dm_verity *v, sector_t block, int level, *offset = idx << (v->hash_dev_block_bits - v->hash_per_block_bits); } +/* +* Skip verity work in response to I/O error when system is shutting down. +*/ +static inline bool verity_is_system_shutting_down (void ) +{ +return system_state ==SYSTEM_HALT || system_state ==SYSTEM_POWER_OFF + || system_state ==SYSTEM_RESTART ; +} +/* * Handle verification errors. */
@@ -219,6 +228,15 @@ static int verity_handle_err(struct dm_verity *v, enum verity_block_type type,if (v->mode ==DM_VERITY_MODE_LOGGING )return 0 ; +/* +* Devices may already be quiesced (e.g. UFS set offline by its +* shutdown hook), so a failure here does not imply corruption. Fail +* the I/O but do not restart or panic, which would also override the +* reboot reason of the shutdown already in progress. +*/ +if (verity_is_system_shutting_down ()) +return 1 ; +if (v->mode ==DM_VERITY_MODE_RESTART )kernel_restart ("dm-verity device corrupted" );
@@ -593,15 +611,6 @@ static int verity_verify_io(struct dm_verity_io *io)return r; } -/* -* Skip verity work in response to I/O error when system is shutting down. -*/ -static inline bool verity_is_system_shutting_down (void ) -{ -return system_state ==SYSTEM_HALT || system_state ==SYSTEM_POWER_OFF - || system_state ==SYSTEM_RESTART ; -} -static void restart_io_error (struct work_struct *w) {kernel_restart ("dm-verity device has I/O error" );
Sasha Levin
maintainerPATCH 1/1 dm-verity: don't restart or panic on errors during system shutdown
From: Weijiang Zhou <[email protected]>
[ Upstream commit 47930d1236d2988cdc580c10d3af21b6b02d7ece ]
Commit 252bd1256396 ("dm verity: skip verity work if I/O error when system is shutting down") stopped I/O errors during shutdown from triggering a restart, since devices may legitimately be gone by then. Errors that reach verity_handle_err(), e.g. through a failed hash block read followed by a failed FEC attempt, are not covered and still call kernel_restart() or panic().
During a reboot that is both wrong (nothing is corrupt) and harmful: it races with the reboot already in progress and replaces its reason with "dm-verity device corrupted", which bootloaders such as Android's treat as a verity failure and switch the device to EIO mode.
Apply the same shutdown check in verity_handle_err(). Corruption is still logged, recorded in hash_failed and reported via uevent, and the I/O still fails.
--- drivers/md/dm-verity-target.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-)
drivers/md/dm-verity-target.c +18 -9
@@ -207,6 +207,15 @@ static void verity_hash_at_level(struct dm_verity *v, sector_t block, int level, *offset = idx << (v->hash_dev_block_bits - v->hash_per_block_bits); } +/* +* Skip verity work in response to I/O error when system is shutting down. +*/ +static inline bool verity_is_system_shutting_down (void ) +{ +return system_state ==SYSTEM_HALT || system_state ==SYSTEM_POWER_OFF + || system_state ==SYSTEM_RESTART ; +} +/* * Handle verification errors. */
@@ -254,6 +263,15 @@ static int verity_handle_err(struct dm_verity *v, enum verity_block_type type,if (v->mode ==DM_VERITY_MODE_LOGGING )return 0 ; +/* +* Devices may already be quiesced (e.g. UFS set offline by its +* shutdown hook), so a failure here does not imply corruption. Fail +* the I/O but do not restart or panic, which would also override the +* reboot reason of the shutdown already in progress. +*/ +if (verity_is_system_shutting_down ()) +return 1 ; +if (v->mode ==DM_VERITY_MODE_RESTART )kernel_restart ("dm-verity device corrupted" );
@@ -548,15 +566,6 @@ static int verity_verify_io(struct dm_verity_io *io)return 0 ; } -/* -* Skip verity work in response to I/O error when system is shutting down. -*/ -static inline bool verity_is_system_shutting_down (void ) -{ -return system_state ==SYSTEM_HALT || system_state ==SYSTEM_POWER_OFF - || system_state ==SYSTEM_RESTART ; -} -/* * End one "io" structure with a given error. */
Signature · 1 line
2.53.0