[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ct6ydugpx3c5uklimg2w5irwtezxmcdikqn64p3hds5tjrb3y2@hvomhcxsbl34>
Date: Mon, 25 Sep 2023 11:59:02 +0200
From: Maxime Ripard <mripard@...nel.org>
To: David Gow <davidgow@...gle.com>
Cc: Arthur Grillo <arthurgrillo@...eup.net>,
David Airlie <airlied@...il.com>,
Daniel Vetter <daniel@...ll.ch>,
Javier Martinez Canillas <javierm@...hat.com>,
Brendan Higgins <brendan.higgins@...ux.dev>,
tales.aparecida@...il.com, andrealmeid@...eup.net,
mairacanal@...eup.net, dri-devel@...ts.freedesktop.org,
linux-kernel@...r.kernel.org, kunit-dev@...glegroups.com
Subject: Re: [PATCH 2/3] kunit: Add kunit_move_action_to_top_or_reset() to
reorder actions
Hi David,
On Fri, Sep 22, 2023 at 04:00:21PM +0800, David Gow wrote:
> On Wed, 20 Sept 2023 at 14:12, Arthur Grillo <arthurgrillo@...eup.net> wrote:
> >
> > On Kunit, if we allocate a resource A and B on this order, with its
> > deferred actions to free them. The resource stack would be something
> > like this:
> >
> > +---------+
> > | free(B) |
> > +---------+
> > | ... |
> > +---------+
> > | free(A) |
> > +---------+
> >
> > If the deferred action of A accesses B, this would cause a
> > use-after-free bug. To solve that, we need a way to change the order
> > of actions.
> >
> > Create a function to move an action to the top of the resource stack,
> > as shown in the diagram below.
> >
> > +---------+ +---------+
> > | free(B) | | free(A) |
> > +---------+ +---------+
> > | ... | -> | free(B) |
> > +---------+ +---------+
> > | free(A) | | ... |
> > +---------+ +---------+
> >
> > Signed-off-by: Arthur Grillo <arthurgrillo@...eup.net>
> > ---
>
> Thanks. This is a really interesting patch: my hope was that something
> like this wouldn't be necessary, as in most cases freeing things in
> the reverse order to which they were created is the right thing to do.
>
> It looks like, from the comments on patch 3, this may no longer be
> necessary? Is that so?
Yeah, it's no longer necessary
Maxime
Powered by blists - more mailing lists