Hi, > -----Original Message----- > From: Dmitry Antipov <dmantipov@xxxxxxxxx> > Sent: Friday, February 14, 2025 3:40 PM > To: Jens Axboe <axboe@xxxxxxxxx> > Cc: Jeff Moyer <jmoyer@xxxxxxxxxx>; io-uring@xxxxxxxxxxxxxxx; Dmitry > Antipov <dmantipov@xxxxxxxxx> > Subject: [PATCH] io_uring: avoid implicit conversion to ktime_t > > In 'io_get_ext_arg()', do not assume that 'min_wait_usec' of 'struct > io_uring_getevents_arg' (which is '__u32') multiplied by NSEC_PER_USEC may > be implicitly converted to 'ktime_t' but use the convenient 'us_to_ktime()' > helper instead. Compile tested only. > > Suggested-by: Jeff Moyer <jmoyer@xxxxxxxxxx> > Signed-off-by: Dmitry Antipov <dmantipov@xxxxxxxxx> > --- > I didn't add Fixes: as per Jeff's remark at https://lore.kernel.org/io- > uring/x49ed01lkso.fsf@xxxxxxxxxxxxxxxxxxxxxxxxxxx/T/#t; > if you think that it should be, most likely they are: > > aa00f67adc2c ("io_uring: add support for fixed wait regions") > 7ed9e09e2d13 ("io_uring: wire up min batch wake timeout") > --- > io_uring/io_uring.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/io_uring/io_uring.c b/io_uring/io_uring.c index > 7f2500aca95c..f73555e981fa 100644 > --- a/io_uring/io_uring.c > +++ b/io_uring/io_uring.c > @@ -3257,7 +3257,7 @@ static int io_get_ext_arg(struct io_ring_ctx *ctx, > unsigned flags, > > if (w->flags & ~IORING_REG_WAIT_TS) > return -EINVAL; > - ext_arg->min_time = READ_ONCE(w->min_wait_usec) * > NSEC_PER_USEC; > + ext_arg->min_time = us_to_ktime(READ_ONCE(w- > >min_wait_usec)); > ext_arg->sig = u64_to_user_ptr(READ_ONCE(w->sigmask)); > ext_arg->argsz = READ_ONCE(w->sigmask_sz); > if (w->flags & IORING_REG_WAIT_TS) { > @@ -3286,7 +3286,7 @@ static int io_get_ext_arg(struct io_ring_ctx *ctx, > unsigned flags, > if (copy_from_user(&arg, uarg, sizeof(arg))) > return -EFAULT; > #endif > - ext_arg->min_time = arg.min_wait_usec * NSEC_PER_USEC; > + ext_arg->min_time = us_to_ktime(arg.min_wait_usec); > ext_arg->sig = u64_to_user_ptr(arg.sigmask); > ext_arg->argsz = arg.sigmask_sz; > if (arg.ts) { > -- > 2.48.1 > > Reviewed-by: Li Zetao <lizetao1@xxxxxxxxxx> --- Li Zetao