public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>
To: Jan Kratochvil <jkratochvil@azul.com>
Cc: Florian Weimer <fweimer@redhat.com>,
	libc-alpha@sourceware.org, Anton Kozlov <akozlov@azul.com>
Subject: Re: [PATCH] RFC: Provide a function to reset IFUNC PLTs
Date: Thu, 9 Mar 2023 14:43:08 -0300	[thread overview]
Message-ID: <676ee95e-9981-a0cd-36b3-231b64b82673@linaro.org> (raw)
In-Reply-To: <ce18abb7-04f0-23ff-e9e7-20578c1c6309@linaro.org>



On 09/03/23 12:47, Adhemerval Zanella Netto wrote:
> 
> 
> On 09/03/23 08:32, Jan Kratochvil wrote:
>> On Wed, 08 Mar 2023 21:04:59 +0800, Adhemerval Zanella Netto wrote:
>>> Yes, without a stop-the-world scheme where a helper thread sets PR_GET_DUMPABLE 
>>> and PTRACE_ATTACH the process can not really be sure that any new thread will not 
>>> be created between the time you enumerate the process threads and call the 'freeze'
>>> function.
>>
>> That "Freezer" class does solve the race of new threads. I also do not see
>> a need for ptrace there, it is self-snapshotting/restoring.
>> 	https://github.com/openjdk/crac/pull/41/files#diff-aeec57d804d56002f26a85359fc4ac8b48cfc249d57c656a30a63fc6bf3457adR6029
> 
> I am not sure how the kernel would enumerate new tasks that are created
> while iterating over /proc/self/task.  On closefrom Linux fallback we have
> a similar problem, where the code iterates over /proc/self/fd, and everytime
> it closes a file descriptor it lseeks back to beginning.  It works because
> eventually there will be no more entries on /proc/self/fd, so either you
> will need to certify that kernel adds new tasks at the end of the getdents
> call (used by readdir, or lseek and keep track of all tasks already signaled.

And the 'handler' signal handler has some potential shortcomings as well: 

  * backtrace is not async-signal-safe: glibc implementation on first call
    issues dlopen, which calls malloc; and libgcc_eh.so *might* also calls malloc.
  
  * pthread calls are not async-signal-safe either.

  * it only handles libc.so, other libraries that uses ifunc for function
    selection also fails.

  * the syscall heuristics do not handle partial results (for instance if
    write syscall returns do EINTR).

So this code has the potential of deadlock, specially if you have another
thread issuing malloc.

  reply	other threads:[~2023-03-09 17:43 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-06  8:04 Jan Kratochvil
2023-03-07  8:40 ` Florian Weimer
2023-03-07 13:07   ` Adhemerval Zanella Netto
2023-03-08 10:21     ` Jan Kratochvil
2023-03-08 13:04       ` Adhemerval Zanella Netto
2023-03-09 11:32         ` Jan Kratochvil
2023-03-09 15:47           ` Adhemerval Zanella Netto
2023-03-09 17:43             ` Adhemerval Zanella Netto [this message]
2023-03-16 14:38             ` Jan Kratochvil
2023-03-20 16:47               ` Adhemerval Zanella Netto
2023-03-29 12:12                 ` Jan Kratochvil
2023-03-29 13:14                   ` Adhemerval Zanella Netto
2023-03-13 13:59           ` Florian Weimer
2023-03-14 12:55             ` Jan Kratochvil
2023-03-14 14:49               ` Florian Weimer
2023-03-14 15:06                 ` Jan Kratochvil
2023-03-08 10:23   ` Jan Kratochvil
2023-03-08 10:44     ` Florian Weimer
2023-03-08 11:03       ` Jan Kratochvil

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=676ee95e-9981-a0cd-36b3-231b64b82673@linaro.org \
    --to=adhemerval.zanella@linaro.org \
    --cc=akozlov@azul.com \
    --cc=fweimer@redhat.com \
    --cc=jkratochvil@azul.com \
    --cc=libc-alpha@sourceware.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 read-only IMAP folder(s) and NNTP newsgroup(s).