mailing list of musl libc
 help / color / mirror / code / Atom feed
* [musl] AT_EXECFN aux entry passed by the linux kernel is broken in NOMMU
@ 2024-03-20 15:54 Max Filippov
  0 siblings, 0 replies; only message in thread
From: Max Filippov @ 2024-03-20 15:54 UTC (permalink / raw)
  To: Rich Felker; +Cc: musl

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-03-20 15:55 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-20 15:54 [musl] AT_EXECFN aux entry passed by the linux kernel is broken in NOMMU Max Filippov

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).