From nobody Fri Sep 16 20:25:37 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4MTlv536K1z4d6tZ; Fri, 16 Sep 2022 20:25:37 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4MTlv52Zhcz3MTw; Fri, 16 Sep 2022 20:25:37 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1663359937; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=04muahX6IWja6pu9fMJFQsM8EpszBUhNNbcN0PbNu4A=; b=OfSDd0M6OCPaRTLjgH/gRq7hcrDW/YQeO7AgKtQMsQopGK/hqVolLs3KwYjICUSDUqdR1W Hs3bwcx/ZlOS9Lx0RHPvy9JxYySqErORHXed9rHL8DTncrX7zxR4JJLpsatwaOBWXFeTWS SJfTbaC4OFriofKaGesEccBcMSLjBI4L8o5SZO3TOCHQzIladZ2/n5XJlhqk7JQCSlf5Dn Shkleb2rFfUbczl0MLkE7wL/O7ArDj3C9Gz53ctjMzRHr9wyAwpOB1HypUWwFbB/fpxbDh U74so+D+Yf4qLB31iUNmNDnhMihRjtTmlyJIAQOzAY5clZ7VGkACvLl1CYAsmg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4MTlv51cxnzT1Y; Fri, 16 Sep 2022 20:25:37 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 28GKPbkD026293; Fri, 16 Sep 2022 20:25:37 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 28GKPbNU026292; Fri, 16 Sep 2022 20:25:37 GMT (envelope-from git) Date: Fri, 16 Sep 2022 20:25:37 GMT Message-Id: <202209162025.28GKPbNU026292@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: ff41239f587f - main - Add AT_USRSTACK{BASE, LIM} AT vectors, and ELF_BSDF_VMNOOVERCOMMIT flag List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: ff41239f587f2c2850c10639bd0ab8b5422b33fa Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1663359937; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=04muahX6IWja6pu9fMJFQsM8EpszBUhNNbcN0PbNu4A=; b=YMwifcyAsu4bHSMtw55i2FQ1IklML9o7icbCJCux5DqKAluFP2jvhXBc0FF2yXsbFuBuTl ahqAEYtG9Pj9Q7UTC9DvaMYs+IgAymAfJKoWVJlIptRUvf1fp7cnId0ro46ZBWxthW9JZH DPYvY51ybw0kWDyOUUwGkv7jOll2d8vmhnt/nvvLeF2O3kz1PKGBs9daAC0f1/LIeMQO5B RUxa1Q/lp0tFZNj9R9IdqFJyQzE71qDmP3/fmIlMr5SCujHMRTfEa5d3cJEsKAWKcwIXFm 7OdCGwZmHLKJUa2qWcJwghC9OTT9OK05PIPwMe71rAIIe7cK7fiaMpi90E5Q8A== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1663359937; a=rsa-sha256; cv=none; b=eS47+qs8CamxN5hZa+m9wYEowG0R52HLNQ+IUMPlnqtzuNEyKUt818BDxmcRGOPWyclOos gMWku0spK7eezngFpaYt2HpsfzPSv5fwXutxcxoeY5GT6i+oZJITlwrBVtzBcdvCY5kk1B XTyytvmuRZFym+XFdw6/u9IrOgVnd9ot0qEAzSWeaaliXkXNfmufRxD6NMS3ch9LTeVuY2 opQEGrzsPKX9GN2H/9B+DXg6N//SzxDl0wb6k16vUFNHrSIxYZJD7A9RpfERoEWbGanb9K ftAztINkEj/4m7k6coEZXq/cCSRe+yglKdGX5WXmECZOPex0J4IjmVfrgjzpYQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=ff41239f587f2c2850c10639bd0ab8b5422b33fa commit ff41239f587f2c2850c10639bd0ab8b5422b33fa Author: Konstantin Belousov AuthorDate: 2022-09-12 19:32:02 +0000 Commit: Konstantin Belousov CommitDate: 2022-09-16 20:23:26 +0000 Add AT_USRSTACK{BASE, LIM} AT vectors, and ELF_BSDF_VMNOOVERCOMMIT flag Reviewed by: brooks, imp (previous version) Discussed with: markj Sponsored by: The FreeBSD Foundation MFC after: 2 weeks Differential revision: https://reviews.freebsd.org/D36540 --- sys/kern/imgact_elf.c | 14 +++++++++++--- sys/sys/elf_common.h | 5 ++++- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/sys/kern/imgact_elf.c b/sys/kern/imgact_elf.c index 6c36c880a2c0..1c13a9a7c737 100644 --- a/sys/kern/imgact_elf.c +++ b/sys/kern/imgact_elf.c @@ -1448,7 +1448,8 @@ __elfN(freebsd_copyout_auxargs)(struct image_params *imgp, uintptr_t base) Elf_Auxargs *args = (Elf_Auxargs *)imgp->auxargs; Elf_Auxinfo *argarray, *pos; struct vmspace *vmspace; - int error; + rlim_t stacksz; + int error, bsdflags, oc; argarray = pos = malloc(AT_COUNT * sizeof(*pos), M_TEMP, M_WAITOK | M_ZERO); @@ -1489,8 +1490,12 @@ __elfN(freebsd_copyout_auxargs)(struct image_params *imgp, uintptr_t base) AUXARGS_ENTRY(pos, AT_HWCAP, *imgp->sysent->sv_hwcap); if (imgp->sysent->sv_hwcap2 != NULL) AUXARGS_ENTRY(pos, AT_HWCAP2, *imgp->sysent->sv_hwcap2); - AUXARGS_ENTRY(pos, AT_BSDFLAGS, __elfN(sigfastblock) ? - ELF_BSDF_SIGFASTBLK : 0); + bsdflags = 0; + bsdflags |= __elfN(sigfastblock) ? ELF_BSDF_SIGFASTBLK : 0; + oc = atomic_load_int(&vm_overcommit); + bsdflags |= (oc & (SWAP_RESERVE_FORCE_ON | SWAP_RESERVE_RLIMIT_ON)) != + 0 ? ELF_BSDF_VMNOOVERCOMMIT : 0; + AUXARGS_ENTRY(pos, AT_BSDFLAGS, bsdflags); AUXARGS_ENTRY(pos, AT_ARGC, imgp->args->argc); AUXARGS_ENTRY_PTR(pos, AT_ARGV, imgp->argv); AUXARGS_ENTRY(pos, AT_ENVC, imgp->args->envc); @@ -1506,6 +1511,9 @@ __elfN(freebsd_copyout_auxargs)(struct image_params *imgp, uintptr_t base) AUXARGS_ENTRY(pos, AT_KPRELOAD, vmspace->vm_shp_base + imgp->sysent->sv_vdso_offset); } + AUXARGS_ENTRY(pos, AT_USRSTACKBASE, round_page(vmspace->vm_stacktop)); + stacksz = imgp->proc->p_limit->pl_rlimit[RLIMIT_STACK].rlim_cur; + AUXARGS_ENTRY(pos, AT_USRSTACKLIM, stacksz); AUXARGS_ENTRY(pos, AT_NULL, 0); free(imgp->auxargs, M_TEMP); diff --git a/sys/sys/elf_common.h b/sys/sys/elf_common.h index 23440f535887..9366593b24bd 100644 --- a/sys/sys/elf_common.h +++ b/sys/sys/elf_common.h @@ -986,8 +986,10 @@ typedef struct { #define AT_PS_STRINGS 32 /* struct ps_strings */ #define AT_FXRNG 33 /* Pointer to root RNG seed version. */ #define AT_KPRELOAD 34 /* Base of vdso, preloaded by rtld */ +#define AT_USRSTACKBASE 35 /* Top of user stack */ +#define AT_USRSTACKLIM 36 /* Grow limit of user stack */ -#define AT_COUNT 35 /* Count of defined aux entry types. */ +#define AT_COUNT 37 /* Count of defined aux entry types. */ /* * Relocation types. @@ -1501,5 +1503,6 @@ typedef struct { #define R_X86_64_REX_GOTPCRELX 42 #define ELF_BSDF_SIGFASTBLK 0x0001 /* Kernel supports fast sigblock */ +#define ELF_BSDF_VMNOOVERCOMMIT 0x0002 #endif /* !_SYS_ELF_COMMON_H_ */