Page MenuHomeFreeBSD

D22943.id66083.diff
No OneTemporary

D22943.id66083.diff

Index: lib/Makefile
===================================================================
--- lib/Makefile
+++ lib/Makefile
@@ -18,6 +18,8 @@
${_libcplusplus} \
${_libcxxrt} \
libelf \
+ libssp \
+ libssp_nonshared \
msun
# The main list; please keep these sorted alphabetically.
Index: lib/libc/secure/stack_protector.c
===================================================================
--- lib/libc/secure/stack_protector.c
+++ lib/libc/secure/stack_protector.c
@@ -58,6 +58,7 @@
__attribute__((__constructor__, __used__));
#endif
+extern long __stack_chk_guard[8];
extern int __sysctl(const int *name, u_int namelen, void *oldp,
size_t *oldlenp, void *newp, size_t newlen);
@@ -73,8 +74,8 @@
{
static const int mib[2] = { CTL_KERN, KERN_ARND };
volatile long tmp_stack_chk_guard[nitems(__stack_chk_guard)];
- size_t len;
- int error, idx;
+ size_t idx, len;
+ int error;
if (__stack_chk_guard[0] != 0)
return;
@@ -84,7 +85,8 @@
* data into a temporal array, then do manual volatile copy to
* not allow optimizer to call memcpy() behind us.
*/
- error = _elf_aux_info(AT_CANARY, (void *)tmp_stack_chk_guard,
+ error = _elf_aux_info(AT_CANARY,
+ __DEQUALIFY(void *, tmp_stack_chk_guard),
sizeof(tmp_stack_chk_guard));
if (error == 0 && tmp_stack_chk_guard[0] != 0) {
for (idx = 0; idx < nitems(__stack_chk_guard); idx++) {
Index: lib/libssp/Makefile
===================================================================
--- /dev/null
+++ lib/libssp/Makefile
@@ -0,0 +1,17 @@
+# $FreeBSD$
+
+PACKAGE= clibs
+SHLIBDIR?= /lib
+SHLIB= ssp
+SHLIB_MAJOR= 1
+
+VERSION_DEF= ${.CURDIR}/Versions.def
+SYMBOL_MAPS= ${.CURDIR}/Symbol.map
+
+.PATH: ${SRCTOP}/lib/libc/secure
+CFLAGS+= -I${SRCTOP}/lib/libc/include -DIN_LIBSSP
+SRCS= stack_protector.c fortify_stubs.c
+
+CFLAGS.fortify_stubs.c= -Wno-unused-parameter
+
+.include <bsd.lib.mk>
Index: lib/libssp/Symbol.map
===================================================================
--- /dev/null
+++ lib/libssp/Symbol.map
@@ -0,0 +1,22 @@
+/*
+ * $FreeBSD$
+ */
+
+LIBSSP_1.0 {
+ __chk_fail;
+ __stack_chk_fail;
+ __stack_chk_guard;
+
+ /* Currently unsupported: _FORTIFY_SOURCE symbols. */
+ __memcpy_chk;
+ __memset_chk;
+ __snprintf_chk;
+ __sprintf_chk;
+ __stpcpy_chk;
+ __strcat_chk;
+ __strcpy_chk;
+ __strncat_chk;
+ __strncpy_chk;
+ __vsnprintf_chk;
+ __vsprintf_chk;
+};
Index: lib/libssp/Versions.def
===================================================================
--- /dev/null
+++ lib/libssp/Versions.def
@@ -0,0 +1,4 @@
+# $FreeBSD$
+
+LIBSSP_1.0 {
+};
Index: lib/libssp/fortify_stubs.c
===================================================================
--- /dev/null
+++ lib/libssp/fortify_stubs.c
@@ -0,0 +1,134 @@
+/*-
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2019 Kyle Evans <kevans@FreeBSD.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/types.h>
+
+#include <stdarg.h>
+#include <stdlib.h>
+
+/* Signatures grabbed from LSB Core Specification 4.1 */
+void *__memcpy_chk(void *dst, const void *src, size_t len,
+ size_t dstlen);
+void *__memset_chk(void *dst, int c, size_t len, size_t dstlen);
+int __snprintf_chk(char *str, size_t maxlen, int flag, size_t strlen,
+ const char *fmt);
+int __sprintf_chk(char *str, int flag, size_t strlen, const char *fmt);
+char *__stpcpy_chk(char *dst, const char *src, size_t dstlen);
+char *__strcat_chk(char *dst, const char *src, size_t dstlen);
+char *__strcpy_chk(char *dst, const char *src, size_t dstlen);
+char *__strncat_chk(char *dst, const char *src, size_t len, size_t dstlen);
+char *__strncpy_chk(char *dst, const char *src, size_t len, size_t dstlen);
+int __vsnprintf_chk(char *str, size_t size, const char *format,
+ va_list ap);
+int __vsprintf_chk(char *str, int flag, size_t slen, const char *format,
+ va_list ap);
+
+#define ABORT() abort2("_FORTIFY_SOURCE not supported", 0, NULL)
+
+void *
+__memcpy_chk(void *dst, const void *src, size_t len,
+ size_t dstlen)
+{
+
+ ABORT();
+}
+
+void *
+__memset_chk(void *dst, int c, size_t len, size_t dstlen)
+{
+
+ ABORT();
+}
+
+int
+__snprintf_chk(char *str, size_t maxlen, int flag, size_t strlen,
+ const char *fmt)
+{
+
+ ABORT();
+}
+
+int
+__sprintf_chk(char *str, int flag, size_t strlen, const char *fmt)
+{
+
+ ABORT();
+}
+
+char *
+__stpcpy_chk(char *dst, const char *src, size_t dstlen)
+{
+
+ ABORT();
+}
+
+char *
+__strcat_chk(char *dst, const char *src, size_t dstlen)
+{
+
+ ABORT();
+}
+
+char *
+__strcpy_chk(char *dst, const char *src, size_t dstlen)
+{
+
+ ABORT();
+}
+
+char *
+__strncat_chk(char *dst, const char *src, size_t len, size_t dstlen)
+{
+
+ ABORT();
+}
+
+char *
+__strncpy_chk(char *dst, const char *src, size_t len, size_t dstlen)
+{
+
+ ABORT();
+}
+
+int
+__vsnprintf_chk(char *str, size_t size, const char *format,
+ va_list ap)
+{
+
+ ABORT();
+}
+
+int
+__vsprintf_chk(char *str, int flag, size_t slen, const char *format,
+ va_list ap)
+{
+
+ ABORT();
+}
Index: lib/libssp_nonshared/Makefile
===================================================================
--- /dev/null
+++ lib/libssp_nonshared/Makefile
@@ -0,0 +1,10 @@
+# $FreeBSD$
+
+PACKAGE= clibs
+LIB= ssp_nonshared
+NO_PIC=
+MK_PROFILE= no
+
+SRCS= libssp_nonshared.c
+
+.include <bsd.lib.mk>
Index: lib/libssp_nonshared/libssp_nonshared.c
===================================================================
--- /dev/null
+++ lib/libssp_nonshared/libssp_nonshared.c
@@ -0,0 +1,17 @@
+/*
+ * Written by Alexander Kabaev <kan@FreeBSD.org>
+ * The file is in public domain.
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+void __stack_chk_fail(void);
+void __stack_chk_fail_local(void);
+
+void __hidden
+__stack_chk_fail_local(void)
+{
+
+ __stack_chk_fail();
+}

File Metadata

Mime Type
text/plain
Expires
Tue, Mar 24, 1:27 AM (8 h, 22 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
30218796
Default Alt Text
D22943.id66083.diff (6 KB)

Event Timeline