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=1796386077; b=bF5Sj5IjhpMFZPFwOTKL5+mWxCcPIrcOHbJprJwPjFZ4OSgrVSKj2tUK2Nx/37V1tXl4 D/8P58CmHPlnJQoaZyoeO8jD/TQaRLozwRZOOzRuOaUxdoVtDobUi+w1XABptvm3ra2PR vUZqywh52nejCsKEYRp3FfTUToXuDR9aSGJTDb7cDlWCqcCtndMWmXvXKr3KXJDK5LtY6 YmN7HM3ldFbip+7KoIzkowMnZPupJtpUayM6QIcVpf0FP/RWBjGD25wqlofJ1LQnMVv/U CPtLgHeKp2zpHw62gpiP7BKHCiq1sto1MuX3nqGbEjTRPCnqDLUsWDxeyA3L9oVJttg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796386077; 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=Jh2LVa0VGpSuAiSHjLstZw6ScHAtAFyQWSHmbshSSSw=; b=SDU9vd6YsmCQKEkUe/KkqZqQzQESh8aSe9eILOlmBW9Kuw5dFszjj9Plbarcwb0vdZE0 o7AV09/fZaV9E/piY41UL27WRdm1UK6rluJZYhbFZhrNMWHedv4gS6S0GaiIj9szIhPjv i42SM/dSzhlPY0FXNlmvD03ZUHlRFQ1EWk3LiZJGHgQpBZkF2WrLDDY1yW3ho2SI8tY2Q RpM4X8bHrykjtdaLwTVCmGhWM0clzzhf9MOob6n1nk6yTn6i1H+r70yEWVkhaacfUCqxC 1eLeYFOHY/9kn6AdouH0uDalPclhs7eZ6cLnNohY2VPl/bexI6k8X5ulEheKaJTKDHw== 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=w1Cnz+UV; 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 669B0606A32C; Fri, 4 Dec 2026 12:07:57 +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=w1Cnz+UV Received: by smtp.kernel.org (Postfix) with ESMTPSA id D4BC21F000CE; Fri, 4 Dec 2026 12:07:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796386077; bh=Jh2LVa0VGpSuAiSHjLstZw6ScHAtAFyQWSHmbshSSSw=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=w1Cnz+UVZDGAxC1oR1evUh+MFpZ9lboPAA5zlTgCcX+lcUCnY9aO+jRydZqexCSwc fYeZYh+o1nGHthYVS35aeX+r+PHPhM0jPo0WE89VVCRBaGfvtA9013BunwC8Wy9ezE 5K7v6SPCjH8LjEmfHzTWKlevtC1pOttPhI8sJC+k= 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.6 0818/1167] dm-verity: dont restart or panic on errors during system shutdown Date: Fri, 4 Dec 2026 19:04:05 +0900 Message-ID: <20261204100723.430858935@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100702.047403948@linuxfoundation.org> References: <20261204100702.047403948@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.6-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: Dropped the restart_io_error() context from the deletion hunk, which this tree lacks, so the old verity_is_system_shutting_down() copy was simply removed. ] 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 27ef5c0167cb6..7cc599ef87a4b 100644 --- a/drivers/md/dm-verity-target.c +++ b/drivers/md/dm-verity-target.c @@ -217,6 +217,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. */ @@ -266,6 +275,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"); @@ -668,15 +686,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