Page MenuHomeFreeBSD

rtld-elf: Fix VDSO Obj_Entry mapsize and report in utrace(2)
ClosedPublic

Authored by jrtc27 on Aug 15 2025, 7:38 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Oct 12, 1:29 PM
Unknown Object (File)
Fri, Oct 10, 4:18 PM
Unknown Object (File)
Fri, Oct 10, 4:18 PM
Unknown Object (File)
Fri, Oct 10, 4:18 PM
Unknown Object (File)
Fri, Oct 10, 4:18 PM
Unknown Object (File)
Fri, Oct 10, 10:29 AM
Unknown Object (File)
Thu, Oct 9, 9:33 PM
Unknown Object (File)
Wed, Oct 8, 9:18 PM
Subscribers

Details

Summary

Subtracing addr is only appropriate for position-dependent objects,
where vaddrbase would also be the same value. For position-independent
objects, like the VDSO (which we already assume due to setting vaddrbase
to 0), the segments start at 0, not addr.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Before:

jrtc4@amoracia:~/freebsd-src$ LD_UTRACE=1 ktrace -t u /libexec/ld-elf.so.1 /usr/bin/true && kdump | grep loaded
  6613 ld-elf.so.1 USER  RTLD: loaded   0x47728f403408 @ 0x1dbb7f8e9000 - 0x1dbb7f8e8fff ([vdso])
  6613 ld-elf.so.1 USER  RTLD: loaded   0x47728f403808 @ 0x1dbb7ff71000 - 0x1dbb80273fff (/lib/libc.so.7)

After:

jrtc4@amoracia:~/freebsd-src$ LD_UTRACE=1 ktrace -t u ~/freebsd-obj/home/jrtc4/freebsd-src/amd64.amd64/libexec/rtld-elf/ld-elf.so.1 /usr/bin/true && kdump | grep loaded
  6607 ld-elf.so.1 USER  RTLD: loaded   0x55e2a0a03408 @ 0x2e106a0ad000 - 0x2e106a0adfff ([vdso])
  6607 ld-elf.so.1 USER  RTLD: loaded   0x55e2a0a03808 @ 0x2e106b725000 - 0x2e106ba27fff (/lib/libc.so.7)
libexec/rtld-elf/rtld.c
3034

Why the round_page() is needed?

libexec/rtld-elf/rtld.c
3034

Because you can't have sub-page mappings? We round_page in digest_phdr. But maybe your point is that this a special sub-page-granularity object, unlike the ones we mmap from userspace?

libexec/rtld-elf/rtld.c
3034

Exactly. The vdso object itself only occupies parts of the shared page(s), there is other stuff co-located with it, like timehands, or rndg data.

In the description: s/eto/to/

This revision is now accepted and ready to land.Aug 15 2025, 10:19 PM

Now:

jrtc4@amoracia:~/freebsd-src$ LD_UTRACE=1 ktrace -t u ~/freebsd-obj/home/jrtc4/freebsd-src/amd64.amd64/libexec/rtld-elf/ld-elf.so.1 /usr/bin/true && kdump | grep loaded
 80756 ld-elf.so.1 USER  RTLD: loaded   0x5a069ee03408 @ 0x3dae988c1000 - 0x3dae988c12e5 ([vdso])
 80756 ld-elf.so.1 USER  RTLD: loaded   0x5a069ee03808 @ 0x3dae98deb000 - 0x3dae990edfff (/lib/libc.so.7)
In D51924#1186691, @kib wrote:

In the description: s/eto/to/

Uh yes, and there's another typo in there too, thanks.