* [PATCH] media: hdpvr: fix error value returns in hdpvr_read
@ 2022-06-14 17:50 Niels Dossche
0 siblings, 0 replies; only message in thread
From: Niels Dossche @ 2022-06-14 17:50 UTC (permalink / raw)
To: linux-media
Cc: linux-kernel, Hans Verkuil, Mauro Carvalho Chehab, Dongliang Mu,
Niels Dossche
Error return values are supposed to be negative in hdpvr_read. Most
error returns are currently handled via an unsigned integer "ret". When
setting a negative error value to "ret", the value actually becomes a
large positive value, because "ret" is unsigned. Later on, the "ret"
value is returned. But as ssize_t is a 64-bit signed number, the error
return value stays a large positive integer instead of a negative
integer. This can cause an error value to be interpreted as the read
size, which can cause a buffer overread for applications relying on the
returned size.
Fixes: 9aba42efe85b ("V4L/DVB (11096): V4L2 Driver for the Hauppauge HD PVR usb capture device")
Signed-off-by: Niels Dossche <dossche.niels@gmail.com>
---
Note:
I found this issue using my own-developed static analysis tool to find
inconsistent error return values. As I do not have the necessary
hardware to test, I could not test this patch. I only compile-tested
this on x86-64. I found this issue on v5.19-rc2.
I manually verified the issue report by looking at the code.
drivers/media/usb/hdpvr/hdpvr-video.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/media/usb/hdpvr/hdpvr-video.c b/drivers/media/usb/hdpvr/hdpvr-video.c
index 60e57e0f1927..fd7d2a9d0449 100644
--- a/drivers/media/usb/hdpvr/hdpvr-video.c
+++ b/drivers/media/usb/hdpvr/hdpvr-video.c
@@ -409,7 +409,7 @@ static ssize_t hdpvr_read(struct file *file, char __user *buffer, size_t count,
struct hdpvr_device *dev = video_drvdata(file);
struct hdpvr_buffer *buf = NULL;
struct urb *urb;
- unsigned int ret = 0;
+ int ret = 0;
int rem, cnt;
if (*pos)
--
2.36.1
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2022-06-14 17:50 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-14 17:50 [PATCH] media: hdpvr: fix error value returns in hdpvr_read Niels Dossche
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.