git: 1798b44fda38 - main - user stack randomization: only enable by default for 64bit processes

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Tue, 24 Oct 2023 22:07:05 UTC
The branch main has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=1798b44fda382c473c9fc7762e162613a39dc23c

commit 1798b44fda382c473c9fc7762e162613a39dc23c
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2023-10-24 21:44:06 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2023-10-24 22:06:48 +0000

    user stack randomization: only enable by default for 64bit processes
    
    All aslr knobs are disabled by default for 32bit processes, except
    stack.  This results in weird stack location, typically making around 1G
    of user address space hard to use.
    
    Reviewed by:    emaste
    Sponsored by:   The FreeBSD Foundation
    MFC after:      1 week
    Differential revision:  https://reviews.freebsd.org/D42356
---
 sys/kern/imgact_elf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sys/kern/imgact_elf.c b/sys/kern/imgact_elf.c
index e01bccc93cb0..4ebd08082545 100644
--- a/sys/kern/imgact_elf.c
+++ b/sys/kern/imgact_elf.c
@@ -200,7 +200,7 @@ SYSCTL_INT(ASLR_NODE_OID, OID_AUTO, honor_sbrk, CTLFLAG_RW,
     &__elfN(aslr_honor_sbrk), 0,
     __XSTRING(__CONCAT(ELF, __ELF_WORD_SIZE)) ": assume sbrk is used");
 
-static int __elfN(aslr_stack) = 1;
+static int __elfN(aslr_stack) = __ELF_WORD_SIZE == 64;
 SYSCTL_INT(ASLR_NODE_OID, OID_AUTO, stack, CTLFLAG_RWTUN,
     &__elfN(aslr_stack), 0,
     __XSTRING(__CONCAT(ELF, __ELF_WORD_SIZE))