Date: Sat, 21 Sep 2019 20:03:17 +0000 (UTC) From: Konstantin Belousov <kib@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r352585 - head/sys/kern Message-ID: <201909212003.x8LK3HFK021501@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: kib Date: Sat Sep 21 20:03:17 2019 New Revision: 352585 URL: https://svnweb.freebsd.org/changeset/base/352585 Log: kern.elf{32,64}.pie_base sysctl: enforce page alignment. Requested by: rstone Sponsored by: The FreeBSD Foundation MFC after: 1 week Modified: head/sys/kern/imgact_elf.c Modified: head/sys/kern/imgact_elf.c ============================================================================== --- head/sys/kern/imgact_elf.c Sat Sep 21 19:51:57 2019 (r352584) +++ head/sys/kern/imgact_elf.c Sat Sep 21 20:03:17 2019 (r352585) @@ -136,8 +136,24 @@ SYSCTL_INT(_kern_elf32, OID_AUTO, read_exec, CTLFLAG_R #endif static u_long __elfN(pie_base) = ET_DYN_LOAD_ADDR; -SYSCTL_ULONG(__CONCAT(_kern_elf, __ELF_WORD_SIZE), OID_AUTO, pie_base, - CTLFLAG_RWTUN, &__elfN(pie_base), 0, +static int +sysctl_pie_base(SYSCTL_HANDLER_ARGS) +{ + u_long val; + int error; + + val = __elfN(pie_base); + error = sysctl_handle_long(oidp, &val, 0, req); + if (error != 0 || req->newptr == NULL) + return (error); + if ((val & PAGE_MASK) != 0) + return (EINVAL); + __elfN(pie_base) = val; + return (0); +} +SYSCTL_PROC(__CONCAT(_kern_elf, __ELF_WORD_SIZE), OID_AUTO, pie_base, + CTLTYPE_ULONG | CTLFLAG_MPSAFE | CTLFLAG_RW, NULL, 0, + sysctl_pie_base, "LU", "PIE load base without randomization"); SYSCTL_NODE(__CONCAT(_kern_elf, __ELF_WORD_SIZE), OID_AUTO, aslr, CTLFLAG_RW, 0,
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201909212003.x8LK3HFK021501>