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  linux-cve-announce  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]
Message-ID: <871qgulv10.fsf@minerva.mail-host-address-is-not-set>
Date:   Wed, 26 Jul 2023 14:25:15 +0200
From:   Javier Martinez Canillas <javierm@...hat.com>
To:     Geert Uytterhoeven <geert@...ux-m68k.org>
Cc:     linux-kernel@...r.kernel.org,
        Thomas Zimmermann <tzimmermann@...e.de>,
        Daniel Vetter <daniel.vetter@...ll.ch>,
        Maxime Ripard <mripard@...nel.org>,
        Daniel Vetter <daniel@...ll.ch>,
        David Airlie <airlied@...il.com>,
        dri-devel@...ts.freedesktop.org
Subject: Re: [PATCH v5 2/2] drm/ssd130x: Allocate buffer in the plane's
 .atomic_check() callback

Geert Uytterhoeven <geert@...ux-m68k.org> writes:

> Hi Javier,
>
> On Wed, Jul 26, 2023 at 12:55 PM Javier Martinez Canillas
> <javierm@...hat.com> wrote:
>> Drivers are not allowed to fail after drm_atomic_helper_swap_state() has
>> been called and the new atomic state is stored into the current sw state.
>>
>> Since the struct ssd130x_device .data_array is allocated in the encoder's
>> .atomic_enable callback, the operation can fail and this is after the new
>> state has been stored. So it can break an atomic mode settings assumption.
>>
>> Fix this by having custom helpers to allocate, duplicate and destroy the
>> plane state, that will take care of allocating and freeing these buffers.
>>
>> Suggested-by: Maxime Ripard <mripard@...nel.org>
>> Signed-off-by: Javier Martinez Canillas <javierm@...hat.com>
>> Acked-by: Maxime Ripard <mripard@...nel.org>
>> Tested-by: Geert Uytterhoeven <geert@...ux-m68k.org>
>> ---
>>
>> Changes in v5:
>> - Add collected tags from Maxime and Geert.
>> - Update commit message to not mention the kernel oops (Geert Uytterhoeven).
>> - Drop Reported-by and Fixes tags (Geert Uytterhoeven).
>> - Update comment about buffer and data_array fields (Geert Uytterhoeven).
>> - Remove superfluous NULL check in ssd130x_fb_blit_rect() (Geert Uytterhoeven).
>> - Reset .buffer to NULL if .data_array allocation fails (Geert Uytterhoeven).
>> - Inline buffer alloc/free helper functions (Geert Uytterhoeven).
>
> Thanks for the update!
>

You are welcome, and thanks for the review!

>> --- a/drivers/gpu/drm/solomon/ssd130x.c
>> +++ b/drivers/gpu/drm/solomon/ssd130x.c
>
>> @@ -535,7 +550,8 @@ static int ssd130x_update_rect(struct ssd130x_device *ssd130x, struct drm_rect *
>>         return ret;
>>  }
>>
>> -static void ssd130x_clear_screen(struct ssd130x_device *ssd130x)
>> +static void ssd130x_clear_screen(struct ssd130x_device *ssd130x,
>> +                                struct ssd130x_plane_state *ssd130x_state)
>>  {
>>         struct drm_rect fullscreen = {
>>                 .x1 = 0,
>> @@ -544,21 +560,21 @@ static void ssd130x_clear_screen(struct ssd130x_device *ssd130x)
>>                 .y2 = ssd130x->height,
>>         };
>>
>> -       ssd130x_update_rect(ssd130x, &fullscreen);
>> +       ssd130x_update_rect(ssd130x, ssd130x_state, &fullscreen);
>
> I've just realized another issue: since 49d7d581ceaf4cf8 ("drm/ssd130x:
> Don't allocate buffers on each plane update"). this no longer
> clears the screens, but just updates the hardware with the data in
> ssd130x_device.buffer, i.e. with the last image shown.
> So this should at least clear all of ssd130x_device.buffer before
> calling ssd130x_update_rect().
>

Oh, you are right. I missed that.

> As it's a bit pointless to transpose a black image, a better fix would
> be to just clear ssd130x.data_array, and call the low-level hardware
> functions like ssd130x_update_rect() does.
>

Yeah, this is a left over when we used to allocate a buffer here and I
agree with you that calling ssd130x_update_rect() is a pointless.

We can fix this as a separate follow-up patch though if you agree.

-- 
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ