Re: [PATCH] media: mtk-jpeg: Fix use after free bug due to uncanceled work

From: Zheng Hacker
Date: Thu Mar 09 2023 - 02:19:10 EST


Guenter Roeck <linux@xxxxxxxxxxxx> 于2023年3月9日周四 13:30写道:
>
> On 3/8/23 19:58, Zheng Hacker wrote:
> > Hi,
> >
> > Thanks for your reply. I think you're right. I don't know if there is
> > other method to stop new work from enqueing. Could you please give me
> > some advice about the fix?
> >
>
> Top-posting is discouraged.
>

Sorry I forgot that. Thanks for the kind reminder.

> Anyway -
> I don't know the code well enough to suggest a solution.
> It all depends on the driver architecture. The maintainers might
> have a better idea.
>

Yes, some related developers have reached out to me and discussed fixes with me.

> A worse problem appears to be that the worker is also canceled
> from mtk_jpeg_enc_irq() and mtk_jpeg_dec_irq(). Those are non-threaded
> interrupt handlers which, as far as I know, must not sleep and thus
> can not call cancel_delayed_work_sync(). I have no idea how to solve
> that problem either.
>

I'd be glad to pass along your thoughts and recommendations to the
relevant parties.

Best regards,
Zheng