[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20211117190039.61d9746e@gandalf.local.home>
Date: Wed, 17 Nov 2021 19:00:39 -0500
From: Steven Rostedt <rostedt@...dmis.org>
To: Linus Torvalds <torvalds@...ux-foundation.org>
Cc: LKML <linux-kernel@...r.kernel.org>,
Ingo Molnar <mingo@...nel.org>,
Andrew Morton <akpm@...ux-foundation.org>,
Kalesh Singh <kaleshsingh@...gle.com>
Subject: Re: [GIT PULL] tracing: Fix double free bug
On Wed, 17 Nov 2021 15:38:59 -0800
Linus Torvalds <torvalds@...ux-foundation.org> wrote:
> On Wed, Nov 17, 2021 at 3:19 PM Steven Rostedt <rostedt@...dmis.org> wrote:
> >
> > On error, the operands and the histogram expression are destroyed,
> > but since the destruction is recursive, do not destroy the operands
> > if they already belong to the expression that is about to be destroyed.
>
> Honestly, this seems horribly ugly.
I guess we have a difference in opinion to what is ugly, as the v1 version
of Kalesh's patch was closer to yours, and I hated the complexity of having
to know when to to call what. Because the logic is not that simple.
See https://lore.kernel.org/all/20211117021223.2137117-1-kaleshsingh@google.com/
>
> The problem seems to be that the "goto error" cases are simply just wrong.
>
> Why isn't the fix to make the error cases be the right ones, instead
> of having one odd error case that then has to do some magic things to
> not free the wrong things?
>
> The patch ends up a bit bigger, mainly because I renamed the different
> "free" cases, and because I made the non-freeing ones just return the
> error directly.
I agree with the first part of your patch, which was not the reason for
being the cause of the bug.
>
> Something like this (UNTESTED!) patch, IOW?
But the part after the expr is allocated gets a bit more tricky, and that
is why I requested that logic, namely due to the "combine_consts" case. But
as the expr->operand[]s are NULL'd and the operand*s are destroyed, I guess
it's still fine with just freeing the expr if we add an error case there.
Kalesh, care to spin a v3 implementing Linus's solution?
-- Steve
Powered by blists - more mailing lists