[PATCH 0/2] nvme-fabrics: bound reconnect_delay and keep_alive_tmo
Martin George
martinus.gpy at gmail.com
Fri Nov 13 07:16:52 PST 2026
On Fri, 2026-11-13 at 08:01 -0500, Laurence Oberman wrote:
> On Fri, 2026-11-13 at 15:39 +0530, Martin George wrote:
> > reconnect_delay and keep_alive_tmo (kato) are accepted in seconds
> > but
> > later multiplied by HZ (and, for kato, by 1000) in 32-bit
> > arithmetic,
> > so
> > large values overflow and yield bogus timers. Bound both at
> > parse/store
> > time so the conversions can't wrap.
> >
> > The target already does this for kato via NVMET_MAX_KATO, and the
> > host
> > recently fixed the same class for admin_timeout/io_timeout
> > (4a5aeebf1a00)
> > and partly for reconnect_delay (f92fe8dea19c).
> >
> > Martin George (2):
> > nvme-fabrics: bound reconnect_delay to avoid timer overflow
> > nvme-fabrics: bound keep_alive_tmo to avoid overflow
> >
> > drivers/nvme/host/fabrics.c | 4 ++--
> > drivers/nvme/host/sysfs.c | 2 +-
> > 2 files changed, 3 insertions(+), 3 deletions(-)
>
> For the series:
>
> Looks good
>
> Reviewed-by: Laurence Oberman <loberman at redhat.com>
>
> One thought: fast_io_fail_tmo looks like the same class -- it's
> scheduled as fast_io_fail_tmo * HZ in nvme_start_failfast_work() and
> isn't upper-bounded in the parser or sysfs store. Might be worth
> folding into this series.
>
Good catch. fast_io_fail_tmo seems to be arguably worse since it is a
signed int (so "* HZ" is signed overflow). I'll add a 3/3 patch
bounding it at INT_MAX / HZ in the parser and sysfs store.
> Minor nit on 2/2: "1000 >= HZ" doesn't hold on every arch (alpha
> allows HZ=1024/1200), though kato being unsigned keeps it safe here.
Right, I'll drop that wording. The bound should be fine (INT_MAX / 1000
keeps "kato * 1000" in range, and kato being unsigned keeps "kato * HZ"
from wrapping) - just a changelog reword, no code change.
Thanks for the review comments.
-Martin
More information about the Linux-nvme
mailing list