qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Richard Henderson <richard.henderson@linaro.org>
To: "Alex Bennée" <alex.bennee@linaro.org>, anjo@rev.ng
Cc: qemu-devel@nongnu.org, "ale@rev.ng" <ale@rev.ng>, iii@linux.ibm.com
Subject: Re: ASan reports use-after-free when running munmap-pthread
Date: Fri, 3 Feb 2023 08:08:12 -1000	[thread overview]
Message-ID: <f496b7cb-5de6-034c-82e1-997b3763f9fc@linaro.org> (raw)
In-Reply-To: <2ecdb36a-adf6-d5b0-8072-2246efdaf99d@linaro.org>

On 2/3/23 07:34, Richard Henderson wrote:
> On 2/3/23 01:23, Alex Bennée wrote:
>>
>> Anton Johansson <anjo@rev.ng> writes:
>>
>>> Hi,
>>>
>>> I was running check-tcg with ASan enabled on master, and ran into
>>> the following use-after-free. There appears to be a race between
>>> jump cache invalidation and thread destruction (?)
>>>
>>> I thought I'd post here since I noticed some previous discussion on the
>>> topic, and I'm not sure myself what a proper fix would look like.
>>
>> Something like:
>>
>> modified   accel/tcg/tb-maint.c
>> @@ -858,9 +858,7 @@ static void tb_jmp_cache_inval_tb(TranslationBlock *tb)
>>           CPU_FOREACH(cpu) {
>>               CPUJumpCache *jc = cpu->tb_jmp_cache;
>> -            if (qatomic_read(&jc->array[h].tb) == tb) {
>> -                qatomic_set(&jc->array[h].tb, NULL);
>> -            }
>> +            qatomic_cmpxchg(&jc->array[h].tb, tb, NULL);
>>           }
>>       }
> 
> No, this doesn't affect the use-after-free of jc itself.
> I think CPUJumpCache needs to be freed with RCU.

Bah, we already do that.


r~


  reply	other threads:[~2023-02-03 18:08 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-02 19:06 ASan reports use-after-free when running munmap-pthread Anton Johansson via
2023-02-03 11:23 ` Alex Bennée
2023-02-03 17:34   ` Richard Henderson
2023-02-03 18:08     ` Richard Henderson [this message]
2023-02-03 21:18 ` Richard Henderson
2023-02-04 12:33   ` Anton Johansson via

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f496b7cb-5de6-034c-82e1-997b3763f9fc@linaro.org \
    --to=richard.henderson@linaro.org \
    --cc=ale@rev.ng \
    --cc=alex.bennee@linaro.org \
    --cc=anjo@rev.ng \
    --cc=iii@linux.ibm.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).