From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796388935; b=ApgXpBhKConO1prwhfeNgQ3qwi6GpqtIWyqKZ1bpsMF0YcEokuK8U7gBpedQnL640eAj kR44s2/nerl5ItwktDW4mtv5ImqgZxfVLm0+nG2+o1mMtHg8ydDzUwueo8e1p8i8D9i/S mK/T8CEnFE/ywe30mw57/96Lm9rLsAv/p8C2Hgcd+5gcgznmT5KGwMVk2jAsc+5CKB0xc oG4sk3rFABhZULHuNBGZ7S+vrcRaph5PeD8rsUYvhv3qzpPoL7Vlzb/zSa5k/8dHbem2U cJmKiUbjzpVOsuIm5odl9+C/cz/VjD7s/kBkAkYPY25p5H0sQLRMYCBibeVuArolPnA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796388935; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=BCd+LcCLy5KYelffxB8UYzl87weSBRLJ/BXxiIQMxfw=; b=vOj8ta5YkxvQVa3B8eaXsIgpOjVKIJokfTWQsDprEWT80DCtuhwk83+54qx5vnjqyiw/ W8IoSVRzNSdnRxdF58ADipp8uHms6QhY05nWaULe+9W0sjQ9cCEtlYCzN2uty7svtQFd4 nwOFX87Rqn3u4dpxJSj99ycmyCMcAgSRjdrRVHCaY38/HhbnBiNJ1AlYfTjkcG/CwveqI fyXmacpF0UDeTvwsPLiD+A5y6aSvp1FqY6xHtMzP0D6vt8NYb2A0kPMuZfPzknKSWEIUo 4IWpTun81HYbDXzsoID+RzUiF5iNt98MxoFukGx4O0CnqIJ/MqL2IHIuRsdhOSSDvmw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=N7UF9s96; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4066B606A32C; Fri, 4 Dec 2026 12:55:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=N7UF9s96 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 40ADE1F000C2; Fri, 4 Dec 2026 12:55:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796388934; bh=BCd+LcCLy5KYelffxB8UYzl87weSBRLJ/BXxiIQMxfw=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=N7UF9s96Mw6pPNLr3DR0SojFVJmFgusklRXlFnYZPR94ayCy6/ThrDTlMfd3mQIi5 hGF5YtoEObB7Ijrpkfd7SDLqO/VALeSW+G+G4R2Y52Tbai1Fd5VJ2FpOir2DVHg7SA NpZ+05pM5SQ3mzrmhWHHtFEJhsjtP3TImNNlQUDk= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Hongyu Jin , "weijiang.zhou" , Mikulas Patocka , Sasha Levin Subject: [PATCH 6.1 0754/1059] dm-verity: dont restart or panic on errors during system shutdown Date: Fri, 4 Dec 2026 19:04:45 +0900 Message-ID: <20261204100703.536753153@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100643.980430235@linuxfoundation.org> References: <20261204100643.980430235@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Weijiang Zhou [ 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. Signed-off-by: Hongyu Jin Signed-off-by: weijiang.zhou Signed-off-by: Mikulas Patocka Fixes: 252bd1256396 ("dm verity: skip verity work if I/O error when system is shutting down") Cc: stable@vger.kernel.org [ sashal: adjusted the final hunk's context, since the surrounding code in this tree differs (verity_verify_io returns 0 where mainline returns r, and the removed helper is followed by a different function). ] Signed-off-by: Sasha Levin --- drivers/md/dm-verity-target.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/drivers/md/dm-verity-target.c b/drivers/md/dm-verity-target.c index 3e582c1b544fe..ce72eed21d6c5 100644 --- a/drivers/md/dm-verity-target.c +++ b/drivers/md/dm-verity-target.c @@ -215,6 +215,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. */ @@ -262,6 +271,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"); @@ -656,15 +674,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. */ -- 2.53.0