From owner-svn-src-head@freebsd.org Sun Feb 9 12:10:38 2020 Return-Path: Delivered-To: svn-src-head@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id B508723759F; Sun, 9 Feb 2020 12:10:38 +0000 (UTC) (envelope-from kib@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 48FntQ4DQjz44QK; Sun, 9 Feb 2020 12:10:38 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 8C5785F32; Sun, 9 Feb 2020 12:10:38 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 019CAc7E006087; Sun, 9 Feb 2020 12:10:38 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 019CAciS006085; Sun, 9 Feb 2020 12:10:38 GMT (envelope-from kib@FreeBSD.org) Message-Id: <202002091210.019CAciS006085@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Sun, 9 Feb 2020 12:10:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r357695 - in head: sys/kern sys/sys usr.bin/procstat X-SVN-Group: head X-SVN-Commit-Author: kib X-SVN-Commit-Paths: in head: sys/kern sys/sys usr.bin/procstat X-SVN-Commit-Revision: 357695 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 09 Feb 2020 12:10:38 -0000 Author: kib Date: Sun Feb 9 12:10:37 2020 New Revision: 357695 URL: https://svnweb.freebsd.org/changeset/base/357695 Log: Add AT_BSDFLAGS auxv entry. The intent is to provide bsd-specific flags relevant to interpreter and C runtime. I did not want to reuse AT_FLAGS which is common ELF auxv entry. Use bsdflags to report kernel support for sigfastblock(2). This allows rtld and libthr to safely infer the syscall presence without SIGSYS. The tunable kern.elf{32,64}.sigfastblock blocks reporting. Tested by: pho Disscussed with: cem, emaste, jilles Sponsored by: The FreeBSD Foundation Differential revision: https://reviews.freebsd.org/D12773 Modified: head/sys/kern/imgact_elf.c head/sys/sys/elf_common.h head/usr.bin/procstat/procstat_auxv.c Modified: head/sys/kern/imgact_elf.c ============================================================================== --- head/sys/kern/imgact_elf.c Sun Feb 9 11:53:37 2020 (r357694) +++ head/sys/kern/imgact_elf.c Sun Feb 9 12:10:37 2020 (r357695) @@ -183,6 +183,11 @@ SYSCTL_INT(ASLR_NODE_OID, OID_AUTO, stack_gap, CTLFLAG __XSTRING(__CONCAT(ELF, __ELF_WORD_SIZE)) ": maximum percentage of main stack to waste on a random gap"); +static int __elfN(sigfastblock) = 1; +SYSCTL_INT(__CONCAT(_kern_elf, __ELF_WORD_SIZE), OID_AUTO, sigfastblock, + CTLFLAG_RWTUN, &__elfN(sigfastblock), 0, + "enable sigfastblock for new processes"); + static Elf_Brandinfo *elf_brand_list[MAX_BRANDS]; #define aligned(a, t) (rounddown2((u_long)(a), sizeof(t)) == (u_long)(a)) @@ -1366,6 +1371,8 @@ __elfN(freebsd_copyout_auxargs)(struct image_params *i 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); AUXARGS_ENTRY(pos, AT_NULL, 0); free(imgp->auxargs, M_TEMP); Modified: head/sys/sys/elf_common.h ============================================================================== --- head/sys/sys/elf_common.h Sun Feb 9 11:53:37 2020 (r357694) +++ head/sys/sys/elf_common.h Sun Feb 9 12:10:37 2020 (r357695) @@ -954,8 +954,9 @@ typedef struct { #define AT_EHDRFLAGS 24 /* e_flags field from elf hdr */ #define AT_HWCAP 25 /* CPU feature flags. */ #define AT_HWCAP2 26 /* CPU feature flags 2. */ +#define AT_BSDFLAGS 27 /* ELF BSD Flags. */ -#define AT_COUNT 27 /* Count of defined aux entry types. */ +#define AT_COUNT 28 /* Count of defined aux entry types. */ /* * Relocation types. @@ -1456,5 +1457,6 @@ typedef struct { #define R_X86_64_TLSDESC 36 #define R_X86_64_IRELATIVE 37 +#define ELF_BSDF_SIGFASTBLK 0x0001 /* Kernel supports fast sigblock */ #endif /* !_SYS_ELF_COMMON_H_ */ Modified: head/usr.bin/procstat/procstat_auxv.c ============================================================================== --- head/usr.bin/procstat/procstat_auxv.c Sun Feb 9 11:53:37 2020 (r357694) +++ head/usr.bin/procstat/procstat_auxv.c Sun Feb 9 12:10:37 2020 (r357695) @@ -197,6 +197,12 @@ procstat_auxv(struct procstat *procstat, struct kinfo_ prefix, "AT_HWCAP2", (u_long)auxv[i].a_un.a_val); break; #endif +#ifdef AT_BSDFLAGS + case AT_BSDFLAGS: + xo_emit("{dw:/%s}{Lw:/%-16s/%s}{:AT_BSDFLAGS/%#lx}\n", + prefix, "AT_BSDFLAGS", (u_long)auxv[i].a_un.a_val); + break; +#endif default: xo_emit("{dw:/%s}{Lw:/%16ld/%ld}{:UNKNOWN/%#lx}\n", prefix, auxv[i].a_type, auxv[i].a_un.a_val);