[PATCH v2 3/3] nvme-fabrics: bound fast_io_fail_tmo to avoid overflow

Martin George martinus.gpy at gmail.com
Fri Nov 13 08:50:02 PST 2026


fast_io_fail_tmo is accepted up to INT_MAX in both the option parser and
the sysfs store (only negatives are mapped to -1, "off"). It is then
scheduled as "fast_io_fail_tmo * HZ" in nvme_start_failfast_work(). As
the field is a signed int, a large value overflows that multiply and the
failfast work is queued with a bogus (effectively never-firing) delay.

Reject values above INT_MAX / HZ in both the parser and the sysfs store,
matching the reconnect_delay handling.

Suggested-by: Laurence Oberman <loberman at redhat.com>
Signed-off-by: Martin George <marting at netapp.com>
---
 drivers/nvme/host/fabrics.c | 6 +++++-
 drivers/nvme/host/sysfs.c   | 2 ++
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/nvme/host/fabrics.c b/drivers/nvme/host/fabrics.c
index b4ca0f9fd703..7da6fc344985 100644
--- a/drivers/nvme/host/fabrics.c
+++ b/drivers/nvme/host/fabrics.c
@@ -862,7 +862,11 @@ static int nvmf_parse_options(struct nvmf_ctrl_options *opts,
 				ret = -EINVAL;
 				goto out;
 			}
-
+			if (token > INT_MAX / HZ) {
+				pr_err("Invalid fast_io_fail_tmo %d\n", token);
+				ret = -EINVAL;
+				goto out;
+			}
 			if (token >= 0)
 				pr_warn("I/O fail on reconnect controller after %d sec\n",
 					token);
diff --git a/drivers/nvme/host/sysfs.c b/drivers/nvme/host/sysfs.c
index 8876d8db5401..dc59473f06f3 100644
--- a/drivers/nvme/host/sysfs.c
+++ b/drivers/nvme/host/sysfs.c
@@ -664,6 +664,8 @@ static ssize_t nvme_ctrl_fast_io_fail_tmo_store(struct device *dev,
 
 	if (fast_io_fail_tmo < 0)
 		opts->fast_io_fail_tmo = -1;
+	else if (fast_io_fail_tmo > INT_MAX / HZ)
+		return -EINVAL;
 	else
 		opts->fast_io_fail_tmo = fast_io_fail_tmo;
 	return count;
-- 
2.53.0




More information about the Linux-nvme mailing list