[PATCH v2 2/3] nvme-fabrics: bound keep_alive_tmo to avoid overflow
Martin George
martinus.gpy at gmail.com
Fri Nov 13 08:50:01 PST 2026
keep_alive_tmo (kato) is only checked for being negative, yet it is sent
to the controller as "kato * 1000" ms and used as "kato * HZ" jiffies for
the keep-alive timer; a large value overflows both.
Reject values above INT_MAX / 1000 so the millisecond form "kato * 1000"
stays within 32 bits. kato is unsigned, so the "kato * HZ" jiffies form
cannot wrap even on architectures where HZ exceeds 1000 (e.g. alpha).
This mirrors the target, which caps kato via NVMET_MAX_KATO.
Signed-off-by: Martin George <marting at netapp.com>
Reviewed-by: Laurence Oberman <loberman at redhat.com>
---
drivers/nvme/host/fabrics.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/nvme/host/fabrics.c b/drivers/nvme/host/fabrics.c
index 25029978b978..b4ca0f9fd703 100644
--- a/drivers/nvme/host/fabrics.c
+++ b/drivers/nvme/host/fabrics.c
@@ -837,7 +837,7 @@ static int nvmf_parse_options(struct nvmf_ctrl_options *opts,
goto out;
}
- if (token < 0) {
+ if (token < 0 || token > INT_MAX / 1000) {
pr_err("Invalid keep_alive_tmo %d\n", token);
ret = -EINVAL;
goto out;
--
2.53.0
More information about the Linux-nvme
mailing list