From owner-svn-src-releng@freebsd.org Tue Jan 28 18:53:15 2020 Return-Path: Delivered-To: svn-src-releng@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 E5536237B04; Tue, 28 Jan 2020 18:53:15 +0000 (UTC) (envelope-from gordon@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 486bNW5rVcz4NGv; Tue, 28 Jan 2020 18:53:15 +0000 (UTC) (envelope-from gordon@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 C1D40278BF; Tue, 28 Jan 2020 18:53:15 +0000 (UTC) (envelope-from gordon@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 00SIrF0g037604; Tue, 28 Jan 2020 18:53:15 GMT (envelope-from gordon@FreeBSD.org) Received: (from gordon@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 00SIrF0T037601; Tue, 28 Jan 2020 18:53:15 GMT (envelope-from gordon@FreeBSD.org) Message-Id: <202001281853.00SIrF0T037601@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gordon set sender to gordon@FreeBSD.org using -f From: Gordon Tetlow Date: Tue, 28 Jan 2020 18:53:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-releng@freebsd.org Subject: svn commit: r357215 - in releng: 11.3/lib/libc/secure 12.0/lib/libc/secure 12.1/lib/libc/secure X-SVN-Group: releng X-SVN-Commit-Author: gordon X-SVN-Commit-Paths: in releng: 11.3/lib/libc/secure 12.0/lib/libc/secure 12.1/lib/libc/secure X-SVN-Commit-Revision: 357215 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-releng@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the release engineering / security commits to the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 28 Jan 2020 18:53:16 -0000 Author: gordon Date: Tue Jan 28 18:53:14 2020 New Revision: 357215 URL: https://svnweb.freebsd.org/changeset/base/357215 Log: Fix imprecise ordering of SSP canary initialization Submitted by: Kyle Evans Approved by: so Security: FreeBSD-EN-20:01.ssp Modified: releng/11.3/lib/libc/secure/stack_protector.c releng/12.0/lib/libc/secure/stack_protector.c releng/12.1/lib/libc/secure/stack_protector.c Modified: releng/11.3/lib/libc/secure/stack_protector.c ============================================================================== --- releng/11.3/lib/libc/secure/stack_protector.c Tue Jan 28 18:42:06 2020 (r357214) +++ releng/11.3/lib/libc/secure/stack_protector.c Tue Jan 28 18:53:14 2020 (r357215) @@ -40,11 +40,29 @@ __FBSDID("$FreeBSD$"); #include #include "libc_private.h" +/* + * We give __guard_setup a defined priority early on so that statically linked + * applications have a defined priority at which __stack_chk_guard will be + * getting initialized. This will not matter to most applications, because + * they're either not usually statically linked or they simply don't do things + * in constructors that would be adversely affected by their positioning with + * respect to this initialization. + * + * This conditional should be removed when GCC 4.2 is removed. + */ +#if __has_attribute(__constructor__) || __GNUC_PREREQ__(4, 3) +#define _GUARD_SETUP_CTOR_ATTR \ + __attribute__((__constructor__ (200), __used__)); +#else +#define _GUARD_SETUP_CTOR_ATTR \ + __attribute__((__constructor__, __used__)); +#endif + extern int __sysctl(const int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp, size_t newlen); long __stack_chk_guard[8] = {0, 0, 0, 0, 0, 0, 0, 0}; -static void __guard_setup(void) __attribute__((__constructor__, __used__)); +static void __guard_setup(void) _GUARD_SETUP_CTOR_ATTR; static void __fail(const char *); void __stack_chk_fail(void); void __chk_fail(void); Modified: releng/12.0/lib/libc/secure/stack_protector.c ============================================================================== --- releng/12.0/lib/libc/secure/stack_protector.c Tue Jan 28 18:42:06 2020 (r357214) +++ releng/12.0/lib/libc/secure/stack_protector.c Tue Jan 28 18:53:14 2020 (r357215) @@ -40,11 +40,29 @@ __FBSDID("$FreeBSD$"); #include #include "libc_private.h" +/* + * We give __guard_setup a defined priority early on so that statically linked + * applications have a defined priority at which __stack_chk_guard will be + * getting initialized. This will not matter to most applications, because + * they're either not usually statically linked or they simply don't do things + * in constructors that would be adversely affected by their positioning with + * respect to this initialization. + * + * This conditional should be removed when GCC 4.2 is removed. + */ +#if __has_attribute(__constructor__) || __GNUC_PREREQ__(4, 3) +#define _GUARD_SETUP_CTOR_ATTR \ + __attribute__((__constructor__ (200), __used__)); +#else +#define _GUARD_SETUP_CTOR_ATTR \ + __attribute__((__constructor__, __used__)); +#endif + extern int __sysctl(const int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp, size_t newlen); long __stack_chk_guard[8] = {0, 0, 0, 0, 0, 0, 0, 0}; -static void __guard_setup(void) __attribute__((__constructor__, __used__)); +static void __guard_setup(void) _GUARD_SETUP_CTOR_ATTR; static void __fail(const char *); void __stack_chk_fail(void); void __chk_fail(void); Modified: releng/12.1/lib/libc/secure/stack_protector.c ============================================================================== --- releng/12.1/lib/libc/secure/stack_protector.c Tue Jan 28 18:42:06 2020 (r357214) +++ releng/12.1/lib/libc/secure/stack_protector.c Tue Jan 28 18:53:14 2020 (r357215) @@ -40,11 +40,29 @@ __FBSDID("$FreeBSD$"); #include #include "libc_private.h" +/* + * We give __guard_setup a defined priority early on so that statically linked + * applications have a defined priority at which __stack_chk_guard will be + * getting initialized. This will not matter to most applications, because + * they're either not usually statically linked or they simply don't do things + * in constructors that would be adversely affected by their positioning with + * respect to this initialization. + * + * This conditional should be removed when GCC 4.2 is removed. + */ +#if __has_attribute(__constructor__) || __GNUC_PREREQ__(4, 3) +#define _GUARD_SETUP_CTOR_ATTR \ + __attribute__((__constructor__ (200), __used__)); +#else +#define _GUARD_SETUP_CTOR_ATTR \ + __attribute__((__constructor__, __used__)); +#endif + extern int __sysctl(const int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp, size_t newlen); long __stack_chk_guard[8] = {0, 0, 0, 0, 0, 0, 0, 0}; -static void __guard_setup(void) __attribute__((__constructor__, __used__)); +static void __guard_setup(void) _GUARD_SETUP_CTOR_ATTR; static void __fail(const char *); void __stack_chk_fail(void); void __chk_fail(void);