lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Fri, 23 Jul 2021 10:24:54 +0200
From:   Hans Verkuil <hverkuil@...all.nl>
To:     Krzysztof Hałasa <khalasa@...p.pl>
Cc:     Mauro Carvalho Chehab <mchehab@...nel.org>,
        linux-media@...r.kernel.org, lkml <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH REPOST] TDA1997x: replace video detection routine

Hi Krzysztof,

On 22/07/2021 08:43, Krzysztof Hałasa wrote:
> Also, I have spotted an interesting loop condition in
> drivers/media/v4l2-core/v4l2-dv-timings.c (dated 2013,
> d1c65ad6a44b0ff79d2f0bf726fa6fd9248991f4).
> It obviously works (unless the table grows to 600+ entries), but I guess
> I should make it "standard", shouldn't I?

Thanks for catching this!

I've posted a patch fixing it. Luckily it never broke anything, but it definitely
had to be fixed.

Regards,

	Hans

> 
> The first case is pretty normal:
> @@ -159,10 +161,10 @@ int v4l2_enum_dv_timings_cap(struct v4l2_enum_dv_timings *t,
>      u32 i, idx;
>  
>      memset(t->reserved, 0, sizeof(t->reserved));
> -    for (i = idx = 0; i < ARRAY_SIZE(timings); i++) {
> -        if (v4l2_dv_valid_timings(timings + i, cap) &&
> +    for (i = idx = 0; v4l2_dv_timings_presets[i].bt.width; i++) {
> +        if (v4l2_dv_valid_timings(v4l2_dv_timings_presets + i, cap) &&
>              idx++ == t->index) {
> -            t->timings = timings[i];
> +            t->timings = v4l2_dv_timings_presets[i];
>              return 0;
>          }
>      }
> 
> This is the interesting part:
> @@ -179,10 +181,10 @@ bool v4l2_find_dv_timings_cap(struct v4l2_dv_timings *t,
>      if (!v4l2_dv_valid_timings(t, cap))
>          return false;
>  
> -    for (i = 0; i < ARRAY_SIZE(timings); i++) {
> -        if (v4l2_dv_valid_timings(timings + i, cap) &&
> -            v4l2_match_dv_timings(t, timings + i, pclock_delta)) {
> -            *t = timings[i];
> +    for (i = 0; i < v4l2_dv_timings_presets[i].bt.width; i++) {
>                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> +        if (v4l2_dv_valid_timings(v4l2_dv_timings_presets + i, cap) &&
> +            v4l2_match_dv_timings(t, v4l2_dv_timings_presets + i, pclock_delta)) {
> +            *t = v4l2_dv_timings_presets[i];
>              return true;
>          }
>      }
> 

Powered by blists - more mailing lists