From: Max Filippov <jcmvbkbc@gmail.com>
To: Rich Felker <dalias@libc.org>
Cc: musl@lists.openwall.com
Subject: [musl] AT_EXECFN aux entry passed by the linux kernel is broken in NOMMU
Date: Wed, 20 Mar 2024 08:54:56 -0700 [thread overview]
Message-ID: <CAMo8BfJhv6U2VGtd7H3f2Z6xDXAvkHRapZVaKZ1GWJmkBn7tUg@mail.gmail.com> (raw)
Hi Rich,
I began testing xtensa FDPIC musl port in full system emulation and
found that /sbin/init crashes inside __dls3() on the following line:
if ((aux[0] & (1UL<<AT_EXECFN))
&& strncmp((char *)aux[AT_EXECFN], "/proc/", 6))
I see that aux[AT_EXECFN] equals 0x1fff1, it can be traced back to the value
0x1fffc written into the bprm->p on its initialization in the
__bprm_mm_init() here:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/fs/exec.c?h=v6.8#n352
moved backwards by the copy_string_kernel() call here:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/fs/exec.c?h=v6.8#n1958
copied to bprm->exec and then written to the aux vector unchanged here:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/fs/binfmt_elf_fdpic.c?h=v6.8#n661
I understand that in NOMMU kernel the bprm->p is the offset inside the
temporary program arguments array maintained in separate pages
in the linux_binprm::page and it needs translation to the actual address
when that array is finally copied to the user stack. It seems that both the
kernel code that creates aux[AT_EXECFN] and the musl code that
examines it predate the SH FDPIC port, so somehow it worked for SH,
I guess because on SH accessing the addresses below 0x20000 didn't
cause a crash?
Disabling the above reference to aux[AT_EXECFN] fixes the boot on
xtensa NOMMU kernel for me.
--
Thanks.
-- Max
reply other threads:[~2024-03-20 15:55 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=CAMo8BfJhv6U2VGtd7H3f2Z6xDXAvkHRapZVaKZ1GWJmkBn7tUg@mail.gmail.com \
--to=jcmvbkbc@gmail.com \
--cc=dalias@libc.org \
--cc=musl@lists.openwall.com \
/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.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/musl/
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).