[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250301111053.2661-1-v.shevtsov@mt-integration.ru>
Date: Sat, 1 Mar 2025 16:09:57 +0500
From: Vitaliy Shevtsov <v.shevtsov@...integration.ru>
To: Hans Verkuil <hverkuil@...all.nl>
CC: Vitaliy Shevtsov <v.shevtsov@...integration.ru>, Mauro Carvalho Chehab
<mchehab@...nel.org>, Jani Nikula <jani.nikula@...el.com>,
<linux-media@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
<lvc-project@...uxtesting.org>
Subject: [PATCH] media: cec: avoid wraparound in timer interval calculation
[Why]
The timer function code may have an integer wraparound issue. Since both
pin->tx_custom_low_usecs and pin->tx_custom_high_usecs can be set to up to
9999999 from the user space via cec_pin_error_inj_parse_line(), this may
cause usecs to be overflowed when adap->monitor_pin_cnt is zero and usecs
is multiplied by 1000.
[How]
Fix this by casting usecs to u64 when it is being converted from
microseconds to nanoseconds.
Found by Linux Verification Center (linuxtesting.org) with Svace.
Fixes: 865463fc03ed ("media: cec-pin: add error injection support")
Signed-off-by: Vitaliy Shevtsov <v.shevtsov@...integration.ru>
---
drivers/media/cec/core/cec-pin.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/media/cec/core/cec-pin.c b/drivers/media/cec/core/cec-pin.c
index a70451d99ebc..f15ed5c67a65 100644
--- a/drivers/media/cec/core/cec-pin.c
+++ b/drivers/media/cec/core/cec-pin.c
@@ -1021,7 +1021,7 @@ static enum hrtimer_restart cec_pin_timer(struct hrtimer *timer)
pin->wait_usecs = 0;
pin->timer_ts = ktime_add_us(ts, usecs);
hrtimer_forward_now(timer,
- ns_to_ktime(usecs * 1000));
+ ns_to_ktime((u64)usecs * 1000));
return HRTIMER_RESTART;
}
pin->wait_usecs = usecs - 100;
--
2.48.1
Powered by blists - more mailing lists