[PATCH v2 1/3] nvme-fabrics: bound reconnect_delay to avoid overflow
Martin George
martinus.gpy at gmail.com
Fri Nov 13 08:50:00 PST 2026
reconnect_delay is accepted up to INT_MAX, but every consumer computes
"reconnect_delay * HZ" in 32-bit (nvme-tcp, nvme-rdma, nvme-fc), so a
large value wraps into a short, bogus reconnect interval.
Reject values above INT_MAX / HZ in both the option parser and the
sysfs store.
Signed-off-by: Martin George <marting at netapp.com>
Reviewed-by: Laurence Oberman <loberman at redhat.com>
---
drivers/nvme/host/fabrics.c | 2 +-
drivers/nvme/host/sysfs.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/nvme/host/fabrics.c b/drivers/nvme/host/fabrics.c
index c262538523fb..25029978b978 100644
--- a/drivers/nvme/host/fabrics.c
+++ b/drivers/nvme/host/fabrics.c
@@ -893,7 +893,7 @@ static int nvmf_parse_options(struct nvmf_ctrl_options *opts,
ret = -EINVAL;
goto out;
}
- if (token <= 0) {
+ if (token <= 0 || token > INT_MAX / HZ) {
pr_err("Invalid reconnect_delay %d\n", token);
ret = -EINVAL;
goto out;
diff --git a/drivers/nvme/host/sysfs.c b/drivers/nvme/host/sysfs.c
index 9672ca3f74d2..8876d8db5401 100644
--- a/drivers/nvme/host/sysfs.c
+++ b/drivers/nvme/host/sysfs.c
@@ -632,7 +632,7 @@ static ssize_t nvme_ctrl_reconnect_delay_store(struct device *dev,
if (err)
return err;
- if (!v || v > INT_MAX)
+ if (!v || v > INT_MAX / HZ)
return -EINVAL;
ctrl->opts->reconnect_delay = v;
--
2.53.0
More information about the Linux-nvme
mailing list