public inbox for dash@vger.kernel.org
 help / color / mirror / Atom feed
From: Herbert Xu <herbert@gondor.apana.org.au>
To: Harald van Dijk <harald@gigawatt.nl>
Cc: Denys Vlasenko <dvlasenk@redhat.com>, dash@vger.kernel.org
Subject: Re: Looking at "int vforked" in signal handler is racy
Date: Mon, 11 Aug 2025 13:00:45 +0800	[thread overview]
Message-ID: <aJl4_WsQeHF6PI0N@gondor.apana.org.au> (raw)
In-Reply-To: <b6a063f8-9844-4f81-90a8-0f65e7c819bf@gigawatt.nl>

On Sun, Aug 10, 2025 at 11:20:40PM +0100, Harald van Dijk wrote:
>
> That approach seems solid to me at a very quick glance. I think you don't
> even need separate have_vfork_sibling and vfork_parent_pid variables, just
> make the existing vforked variable a pid, or 0. A mostly untested patch
> using that:

Looks good to me.  Could you turn this into a patch please? If
you could run some quick speed tests on this versus the existing
code that would be even better :)

> I do wonder if the use of vforked in a signal handler, even in current dash,
> would require the use of volatile to ensure no compiler optimisations mess
> with it, but I think that is not affected by this patch. If it is necessary,
> it is already necessary now, and if it is not necessary now, it will not
> become necessary with this patch.

Yes vfork should be marked as volatile.  Although being a global
variable means that there shouldn't be any practical difference.

Thanks,
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

  reply	other threads:[~2025-08-11  5:00 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-09 13:29 Looking at "int vforked" in signal handler is racy Denys Vlasenko
2025-08-09 13:42 ` Denys Vlasenko
2025-08-09 13:52 ` Harald van Dijk
2025-08-10 19:33   ` Denys Vlasenko
2025-08-10 22:20     ` Harald van Dijk
2025-08-11  5:00       ` Herbert Xu [this message]
2025-08-11 12:58         ` Harald van Dijk
2025-08-22  1:32           ` Harald van Dijk
2025-08-24  2:39             ` Herbert Xu

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=aJl4_WsQeHF6PI0N@gondor.apana.org.au \
    --to=herbert@gondor.apana.org.au \
    --cc=dash@vger.kernel.org \
    --cc=dvlasenk@redhat.com \
    --cc=harald@gigawatt.nl \
    /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