Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 18 Oct 2022 13:48:11 +0200
From:      Paul Floyd <paulf2718@gmail.com>
To:        freebsd-hackers <freebsd-hackers@freebsd.org>
Subject:   Re: AMD64 14.0-CURRENT memory layout changes
Message-ID:  <578a011d-0c3f-3f91-48ca-17999a6515a9@gmail.com>
In-Reply-To: <Y0wiCAlHIHe9rFQ7@nuc>
References:  <bcfa260b-7a94-1414-a5ae-c281e96c76ec@gmail.com> <Y0wiCAlHIHe9rFQ7@nuc>

next in thread | previous in thread | raw e-mail | index | archive | help
Hi Mark


> Setting kern.elf(64|32).aslr.stack to 0 should restore the old
> behaviour.  It should also be possible to disable this on a per-process
> basis with proccontrol(1), but that doesn't appear to work, i.e., there
> is a bug.  However, all randomization can be disabled this way, try
> "procstat -m aslr -s disable ksh93".


If I turn off all aslr then I do see that the memory map reverts to the 
same layout as I get in 13.1.

But that doesn't solve my problems.

I've also seen that sysctl kern.usrstack is no longer used.

On 13.1 I see

   PID trylock  CALL 
__sysctl(0x7fffffffd310,0x2,0x800267c88,0x7fffffffd328,0,0)
   PID trylock  SCTL  "kern.usrstack"
   PID trylock  RET   __sysctl 0
   PID trylock  CALL  getrlimit(RLIMIT_STACK,0x7fffffffd318)
   PID trylock  RET   getrlimit 0
   PID trylock  CALL  thr_self(0x800a12000)
   PID trylock  RET   thr_self 0
   PID trylock  CALL 
mmap(0x7fffdfffe000,0x1000,0<PROT_NONE>,0x1000<MAP_ANON>,0xffffffff,0)
   PID trylock  RET   mmap 140736951476224/0x7fffdfffe000


But on 14.0

I think that this is the mmap for rtld
  PID trylock  CALL 
mmap(0,0x400000,0x3<PROT_READ|PROT_WRITE>,0x15001002<MAP_PRIVATE|MAP_ANON|MAP_ALIGNED(21)>,0xffffffff,0)
  PID trylock  RET   mmap 34372321280/0x800c00000
  PID trylock  CALL  thr_self(0x800a12000)
  PID trylock  RET   thr_self 0

then straight to mapping the stack

  PID trylock  CALL 
mmap(0x7fffdfffe000,0x1000,0<PROT_NONE>,0x1000<MAP_ANON>,0xffffffff,0)
  PID trylock  RET   mmap 140736951476224/0x7fffdfffe000


How is 14.0 working out what address to use for the stack?
(The above is with ASLR all off)

A+
Paul



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?578a011d-0c3f-3f91-48ca-17999a6515a9>