Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <87msdeoubb.fsf@vuxu.org>
Date: Sat, 22 Mar 2025 00:08:56 +0100
From: Leah Neukirchen <leah@...u.org>
To: Rich Felker <dalias@...c.org>
Cc: MouriNaruto <mourinaruto@...il.com>,  musl@...ts.openwall.com,
  MouriNaruto <Kenji.Mouri@...look.com>
Subject: Re: [PATCH] workaround the issue that pthread_getattr_np
 won't return in FreeBSD Linuxulator

Rich Felker <dalias@...c.org> writes:

> On Fri, Mar 21, 2025 at 11:27:53PM +0100, Leah Neukirchen wrote:
>> Rich Felker <dalias@...c.org> writes:
>> 
>> > only tell if it's currently paged in, not if it's mapped. There's
>> > procfs which could be used if mounted, but that's more of a pain to
>> > work with and not always present, and I'm not sure it would help on
>> > FreeBSD anyway.
>> 
>> FreeBSD took precautions to make "linprocfs" work in such a way that
>> glibc parses it properly:
>> https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=253337
>
> I think this is promising that they might also fix mremap so that musl
> can interpret it properly.
>
> As for procfs, does that include /proc/self/maps? That's what we'd
> have to parse, and I'm not even sure how rigorously safe it is to
> parse... so I'd rather not go there.

Exactly, here's an example on FreeBSD:

# cat /tmp/compat/self/maps
000027a17ce04000-000027a17ce06000 r--p 00000000 00:00 48618     /bin/cat
000027a17ce06000-000027a17ce08000 r-xp 00001000 00:00 48618     /bin/cat
000027a17ce08000-000027a17ce09000 r--p 00000000 00:00 0 
000027a17ce09000-000027a17ce0a000 rw-p 00001000 00:00 0 
000027a99d469000-000027a99d489000 rw-p 00000000 00:00 0 
000027a99d60c000-000027a99d60d000 r-xs 00000000 00:00 0 
000027a99daaa000-000027a99db2f000 r--p 00000000 00:00 39034     /lib/libc.so.7
000027a99db30000-000027a99dc7a000 r-xp 00085000 00:00 39034     /lib/libc.so.7
000027a99dc7a000-000027a99dc84000 r--p 0039c000 00:00 39034     /lib/libc.so.7
000027a99dc84000-000027a99dc8b000 rw-p 003ae000 00:00 39034     /lib/libc.so.7
000027a99dc8b000-000027a99ddad000 rw-p 00000000 00:00 0 
000027a99edad000-000027a99edae000 r--s 00000000 00:00 0 
00003140936df000-00003140936e6000 r--p 00000000 00:00 39556     /libexec/ld-elf.so.1
00003140936e6000-00003140936fc000 r-xp 00006000 00:00 39556     /libexec/ld-elf.so.1
00003140936fc000-00003140936fd000 r--p 00036000 00:00 39556     /libexec/ld-elf.so.1
00003140936fd000-00003140936fe000 r--p 00000000 00:00 0 
00003140936fe000-0000314093700000 rw-p 00001000 00:00 0 
00004acf42400000-00004acf42421000 rw-p 00000000 00:00 0 
00004acf42600000-00004acf43000000 rw-p 00000000 00:00 0 

Notably the [stack] is missing from Linux, but you should infer the
proper mapping anyway.  Else it's just parsing two hex numbers at the
beginning of the line, not terribly difficult.

-- 
Leah Neukirchen  <leah@...u.org>  https://leahneukirchen.org

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.