On Thu, Jan 4, 2024 at 5:07 PM Rob Landley <r...@landley.net> wrote:
>
> On 1/4/24 18:30, enh wrote:
> >> Between the two of them you can do things like check the current timestamp
> >> without a system call. What they actually provide varies by OS (and then 
> >> your
> >> libc has to be taught to use each new capability out of there instead of 
> >> making
> >> the syscalls).
> >>
> >> "cat /proc/self/maps" and they're the last two entries if present.
> >
> > (not necesssarily. aslr applies to them too.)
>
> I thought that was in order of map creation, not the order they occurred in 
> the
> address space?

afaik only the dynamic linker does the former. the kernel does the
latter (though iirc it's within a window of where the previous one
went, so it's not as random as you might imagine if someone just
describes the idea to you and you don't look at the implementation!).

(iirc there are differences between architectures here too. so you
might be right for x86? but certainly on arm64, literally the first
process i just picked had vmas after the vvars/vdso ones.)

> > funnily enough (as you can see from that link), argc is there too, so
> > you don't have to count the entries in argv. (and although a null
> > argv[0] is no longer allowed, that was allowed by linux until fairly
> > recently.)
>
> I really need to check in a lot of the dirty changes in my tree:
>
> diff --git a/main.c b/main.c
> index 3d9f612e..190e65cd 100644
> --- a/main.c
> +++ b/main.c
> diff --git a/main.c b/main.c
> index 3d9f612e..190e65cd 100644
> --- a/main.c
> +++ b/main.c
> @@ -279,6 +280,7 @@ void toybox_main(void)
>  int main(int argc, char *argv[])
>  {
>    // don't segfault if our environment is crazy
> +  // TODO mooted by kernel commit dcd46d897adb7 5.17 kernel Jan 2022
>    if (!*argv) return 127;
>
>    // Snapshot stack location so we can detect recursion depth later.
>
> It's the tabsplosion problem in code form...
>
> Rob
_______________________________________________
Toybox mailing list
Toybox@lists.landley.net
http://lists.landley.net/listinfo.cgi/toybox-landley.net

Reply via email to