Hi Eric & Sami, Thanks for the reply and for the correction.
Our patch was only meant to report what we see on the devices: during a reboot the storage is already gone, a hash block read returns -EIO, and the device ends up restarting with "dm-verity device corrupted". It was indeed a stopgap and did not cover every case. We are worried that further changes from us would introduce new problems, and that is why we came here to ask for help. On 2/2 we agree with you: the comment and the commit message do not match what the code does, which is misleading. Mikulas has applied it by hand, so we will not touch it. If you want a version that applies cleanly, we can send it as an attachment. About the mail format: the footer at the bottom, and the missing whitespace in the patches, both come from our company mail server. It rewrites outbound text and appends that footer, and we cannot turn it off. Patch content will go as an attachment from now on. Thanks to you, Sami and Mikulas for the time on this. The root cause looks clear enough now, so we are not going to push these two patches further. They do not solve the underlying problem. We would rather have a complete fix from you or Sami. We have Android devices that reproduce this and can verify whatever you come up with. Sami, it looks like you and Eric see the fix differently. Could the two of you settle on a final approach together? We would rather follow one direction you both agree on than choose between them ourselves. Thanks, Weijiang Zhou -----邮件原件----- 发件人: Eric Biggers <[email protected]> 发送时间: 2026年11月13日 13:55 收件人: 周伟江 (Weijiang Zhou) <[email protected]> 抄送: [email protected]; Alasdair Kergon <[email protected]>; Mike Snitzer <[email protected]>; Mikulas Patocka <[email protected]>; Benjamin Marzinski <[email protected]>; Sami Tolvanen <[email protected]>; 金红宇 (Hongyu Jin) <[email protected]>; 吴祥禄 (Xianglu Wu) <[email protected]>; 吴周镜 (Justin Wu) <[email protected]> 主题: Re: [RFC PATCH 2/2] dm-verity: don't restart or panic on errors during system shutdown 注意: 这封邮件来自于外部。除非你确定邮件内容安全,否则不要点击任何链接和附件。 CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe. On Tue, Nov 10, 2026 at 01:06:21PM +0000, 周伟江 (Weijiang Zhou) wrote: > 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. verity_handle_err() is supposed to be called only on corruption. Just as established by patch 1, there is a bug where an I/O error is unnecessarily escalated to corruption. This patch might still be worthwhile, to be robust against hypothetical storage devices that return successful reads with incorrect data while the system is shutting down. Just the commit message and comments don't really match up with that. >+/* >+ * 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; >+} The above comment is misleading. This patch makes this function be called by verity_handle_err() which is for handling corruption. It also occurs *during* the verity work. > +/* > + * 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; Shouldn't this go earlier in the function? By the time we get here, verity_handle_err() has already recorded the corruption in struct dm_verity (where DM_TABLE_STATUS can read it) and sent a uevent to userspace notifying them of the corruption. That isn't very consistent with the idea that if verity_is_system_shutting_down() then corruption is not reliable and should not be reported. Side note: as Mikulas mentioned, your patches were also corrupted and do not apply. You also should not include email footers telling people to delete your emails, as they may do what you ask. - Eric ________________________________ This email (including its attachments) is intended only for the person or entity to which it is addressed and may contain information that is privileged, confidential or otherwise protected from disclosure. Unauthorized use, dissemination, distribution or copying of this email or the information herein or taking any action in reliance on the contents of this email or the information herein, by anyone other than the intended recipient, or an employee or agent responsible for delivering the message to the intended recipient, is strictly prohibited. If you are not the intended recipient, please do not read, copy, use or disclose any part of this e-mail to others. Please notify the sender immediately and permanently delete this e-mail and any attachments if you received it in error. Internet communications cannot be guaranteed to be timely, secure, error-free or virus-free. The sender does not accept liability for any errors or omissions. 本邮件及其附件具有保密性质,受法律保护不得泄露,仅发送给本邮件所指特定收件人。严禁非经授权使用、宣传、发布或复制本邮件或其内容。若非该特定收件人,请勿阅读、复制、 使用或披露本邮件的任何内容。若误收本邮件,请从系统中永久性删除本邮件及所有附件,并以回复邮件的方式即刻告知发件人。无法保证互联网通信及时、安全、无误或防毒。发件人对任何错漏均不承担责任。
