* FAILED: patch "[PATCH] nvme: reject invalid reconnect_delay sysfs values" failed to apply to 6.1-stable tree
@ 2026-12-02 13:51 gregkh
2026-12-03 13:16 ` [PATCH 6.1.y] nvme: reject invalid reconnect_delay sysfs values shao.mingyin
0 siblings, 1 reply; 3+ messages in thread
From: gregkh @ 2026-12-02 13:51 UTC (permalink / raw)
To: shao.mingyin, kbusch; +Cc: stable
The patch below does not apply to the 6.1-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 <stable@vger.kernel.org>.
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-6.1.y
git checkout FETCH_HEAD
git cherry-pick -x f92fe8dea19c743eb9e4d998ae0384344dd40091
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<stable@vger.kernel.org>' --in-reply-to '2026120240-olympics-conceded-8003@gregkh' --subject-prefix 'PATCH 6.1.y' 'HEAD^..'
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From f92fe8dea19c743eb9e4d998ae0384344dd40091 Mon Sep 17 00:00:00 2001
From: Shao Mingyin <shao.mingyin@zte.com.cn>
Date: Thu, 5 Nov 2026 21:58:07 +0800
Subject: [PATCH] nvme: reject invalid reconnect_delay sysfs values
nvme_ctrl_reconnect_delay_store() stores whatever kstrtou32() accepted
into opts->reconnect_delay without validating it. The nvme-fabrics
option parser refuses reconnect_delay values that are zero or negative,
and the rest of the driver relies on that: nvme_ctrl_loss_tmo_store()
computes
opts->max_reconnects = DIV_ROUND_UP(ctrl_loss_tmo,
opts->reconnect_delay);
Writing 0 to reconnect_delay and then a positive value to ctrl_loss_tmo
therefore divides by zero in the kernel. In addition, a value larger
than INT_MAX is truncated to a negative int in the assignment and
silently bypasses the checks done by the fabrics parser.
Reject zero and values that do not fit into the signed int field.
Fixes: 764075fdcb2f ("nvme: expose reconnect_delay and ctrl_loss_tmo via sysfs")
Cc: stable@vger.kernel.org
Signed-off-by: Shao Mingyin <shao.mingyin@zte.com.cn>
Signed-off-by: Keith Busch <kbusch@kernel.org>
diff --git a/drivers/nvme/host/sysfs.c b/drivers/nvme/host/sysfs.c
index 3724b5ce03a0..9672ca3f74d2 100644
--- a/drivers/nvme/host/sysfs.c
+++ b/drivers/nvme/host/sysfs.c
@@ -632,6 +632,9 @@ static ssize_t nvme_ctrl_reconnect_delay_store(struct device *dev,
if (err)
return err;
+ if (!v || v > INT_MAX)
+ return -EINVAL;
+
ctrl->opts->reconnect_delay = v;
return count;
}
^ permalink raw reply related [flat|nested] 3+ messages in thread* [PATCH 6.1.y] nvme: reject invalid reconnect_delay sysfs values
2026-12-02 13:51 FAILED: patch "[PATCH] nvme: reject invalid reconnect_delay sysfs values" failed to apply to 6.1-stable tree gregkh
@ 2026-12-03 13:16 ` shao.mingyin
2026-12-04 19:49 ` Sasha Levin
0 siblings, 1 reply; 3+ messages in thread
From: shao.mingyin @ 2026-12-03 13:16 UTC (permalink / raw)
To: stable; +Cc: kbusch
From: Shao Mingyin <shao.mingyin@zte.com.cn>
commit f92fe8dea19c743eb9e4d998ae0384344dd40091 upstream.
nvme_ctrl_reconnect_delay_store() stores whatever kstrtou32() accepted
into opts->reconnect_delay without validating it. The nvme-fabrics
option parser refuses reconnect_delay values that are zero or negative,
and the rest of the driver relies on that: nvme_ctrl_loss_tmo_store()
computes
opts->max_reconnects = DIV_ROUND_UP(ctrl_loss_tmo,
opts->reconnect_delay);
Writing 0 to reconnect_delay and then a positive value to ctrl_loss_tmo
therefore divides by zero in the kernel. In addition, a value larger
than INT_MAX is truncated to a negative int in the assignment and
silently bypasses the checks done by the fabrics parser.
Reject zero and values that do not fit into the signed int field.
This is a backport to 6.1.y, where the attribute is still defined in
drivers/nvme/host/core.c and drivers/nvme/host/sysfs.c does not exist.
The validation is unchanged.
Fixes: 764075fdcb2f ("nvme: expose reconnect_delay and ctrl_loss_tmo via sysfs")
Cc: stable@vger.kernel.org
Signed-off-by: Shao Mingyin <shao.mingyin@zte.com.cn>
Signed-off-by: Keith Busch <kbusch@kernel.org>
---
drivers/nvme/host/core.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index d3f4fd67a0..23952497d2 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -3781,6 +3781,9 @@ static ssize_t nvme_ctrl_reconnect_delay_store(struct device *dev,
if (err)
return err;
+ if (!v || v > INT_MAX)
+ return -EINVAL;
+
ctrl->opts->reconnect_delay = v;
return count;
}
--
2.27.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-12-04 19:50 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-02 13:51 FAILED: patch "[PATCH] nvme: reject invalid reconnect_delay sysfs values" failed to apply to 6.1-stable tree gregkh
2026-12-03 13:16 ` [PATCH 6.1.y] nvme: reject invalid reconnect_delay sysfs values shao.mingyin
2026-12-04 19:49 ` Sasha Levin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox