drivers: media: dvb-frontends/rtl2832: fix an out-of-bounds write error
authorJunlin Li <make24@iscas.ac.cn>
Tue, 2 Jul 2024 13:24:13 +0000 (21:24 +0800)
committerHans Verkuil <hverkuil-cisco@xs4all.nl>
Fri, 9 Aug 2024 05:56:38 +0000 (07:56 +0200)
Ensure index in rtl2832_pid_filter does not exceed 31 to prevent
out-of-bounds access.

dev->filters is a 32-bit value, so set_bit and clear_bit functions should
only operate on indices from 0 to 31. If index is 32, it will attempt to
access a non-existent 33rd bit, leading to out-of-bounds access.
Change the boundary check from index > 32 to index >= 32 to resolve this
issue.

Signed-off-by: Junlin Li <make24@iscas.ac.cn>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Fixes: 4b01e01a81b6 ("[media] rtl2832: implement PID filter")
[hverkuil: added fixes tag, rtl2830_pid_filter -> rtl2832_pid_filter in logmsg]

drivers/media/dvb-frontends/rtl2832.c

index acb5c57..3b4e46d 100644 (file)
@@ -983,7 +983,7 @@ static int rtl2832_pid_filter(struct dvb_frontend *fe, u8 index, u16 pid,
                index, pid, onoff, dev->slave_ts);
 
        /* skip invalid PIDs (0x2000) */
-       if (pid > 0x1fff || index > 32)
+       if (pid > 0x1fff || index >= 32)
                return 0;
 
        if (onoff)