From patchwork Wed Nov 29 00:21:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yaakov Selkowitz X-Patchwork-Id: 119908 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp2395512qgn; Tue, 28 Nov 2017 16:22:04 -0800 (PST) X-Google-Smtp-Source: AGs4zMaO3LZRyPmhTdEeqFg08K9bHN9Dd9UCGLy0TsCIoduuYt4bHGY8MdGN5KvalrPmzO8E0Vpw X-Received: by 10.84.128.197 with SMTP id a63mr1003584pla.212.1511914924394; Tue, 28 Nov 2017 16:22:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511914924; cv=none; d=google.com; s=arc-20160816; b=fkuAydriq0aYNVG8lj965w036HEXJD9Oa7XDMiPzqL8lvm5fZg/KImthukLo3m9eNo lCPZb5TTTTy6tMZ7I4oUrsuU5UksqmLVynt+sdi1KIHNiwiO5wTPZ0a2nE9MSuLNvNZL jp8Q5Dkh1KR0NU99FM75mBvnx6FmAs+QLHselImt4TXBiCtLXxqYjUtlrfJAVPvj50BU WXMOnPUMFIeB3sd8V25OjIW+sp3v4X35uRPlB6ekTImxuoTXvDI/V1v2XwSX/RYH9NNq hUst/CLiBy8b+cgD33plu39FXuM1fbsl12qMMqNqPGABczNOs9r/hCBWORYow4+ieqvj bSrg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:to:from:delivered-to :sender:list-help:list-post:list-archive:list-subscribe :list-unsubscribe:list-id:precedence:mailing-list:dkim-signature :domainkey-signature:arc-authentication-results; bh=+syHu05mAOUD4BR2oplzwWJl8p+z/9/z/Yrggl4xxcg=; b=BTj5JzE3cw2fvCBDE9TndV4uVzAwE93e+8VOn0nB6WQtWzLLlFkzf/EjmaJGMKjaaD 2fbI6uNclu3yNxRbx2emi+7Sv+gS6sFYmLiLClEEREZrbTUHH+4471ZBmnadmV30Gf9e 4UzvjxOwrQKGvvGqTOoB24PvfrlfZHkrO5LPQIpfZ65Z7/33A+cfBC3gHOES4KYNeyfI e75Axu0Ao8xHbWRgTvGIZNTRSHru5xmg+rd3jQDUnzVDeNey2IrXZRs7VT+yFu+D0YQ4 TKNODyHO2f7k3icfjDFCN6nrxtlbQEdRqATxZZvQGaOdXSJ6tvjbbAVHCu0jK2pvPHpu 68nQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=l8drBjbc; spf=pass (google.com: domain of newlib-return-15386-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=newlib-return-15386-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id k1si309320pld.40.2017.11.28.16.22.04 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 28 Nov 2017 16:22:04 -0800 (PST) Received-SPF: pass (google.com: domain of newlib-return-15386-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=l8drBjbc; spf=pass (google.com: domain of newlib-return-15386-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=newlib-return-15386-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=TkfBn8NiHFpkVa0XlJ9+5bpRYfBE70f axJ9Fu7zKcmWkeI3jt+hgT9Cp2tT983IOAYGJ/gSGrPYUH9yzS+wwoBipo93IleP Pb1KXaUAx0hWNJ4nihfc2Wo7+sCwFUDqBOOODmyDpdceUccjXmBSzyhqRxZwHS+3 xO4y8uJAv/tM= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; s=default; bh=sXstxDTIWxwu26zCDThfP6JvI3Y=; b=l8drB jbcQH84597H0eaVhKERwfoesyrUIX2343qiOhQBgrkdCuPHekXwOUW8Hhk3qBDvb WCA9Kb/ogEYIUgYUGj0zlwZBUV5mKDHExLqHQR8UW3VzNrLbEP7OABYqeBcbSu5o zn/2sXpjrsbp4DVsZgI/kdOXRffvqomU8QVw58= Received: (qmail 64173 invoked by alias); 29 Nov 2017 00:21:55 -0000 Mailing-List: contact newlib-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: newlib-owner@sourceware.org Delivered-To: mailing list newlib@sourceware.org Received: (qmail 63279 invoked by uid 89); 29 Nov 2017 00:21:55 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.7 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KB_WAM_FROM_NAME_SINGLEWORD, SPF_HELO_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy= X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 29 Nov 2017 00:21:54 +0000 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C4D16C04B952 for ; Wed, 29 Nov 2017 00:21:52 +0000 (UTC) Received: from localhost.localdomain (ovpn-120-11.rdu2.redhat.com [10.10.120.11]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5E150600D1 for ; Wed, 29 Nov 2017 00:21:52 +0000 (UTC) From: Yaakov Selkowitz To: newlib@sourceware.org Subject: [PATCH v4 01/10] ssp: add APIs for Stack Smashing Protection Date: Tue, 28 Nov 2017 18:21:34 -0600 Message-Id: <20171129002143.12500-2-yselkowi@redhat.com> In-Reply-To: <20171129002143.12500-1-yselkowi@redhat.com> References: <20171129002143.12500-1-yselkowi@redhat.com> Compiling with any of the -fstack-protector* flags requires the __stack_chk_guard data import (which needs to be initialized) and the __stack_chk_fail{,_local} functions. While GCC's own libssp can provide these, it is better that we provide these ourselves. The implementation is custom due to being OS-specific. Signed-off-by: Yaakov Selkowitz --- newlib/libc/ssp/stack_protector.c | 45 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 newlib/libc/ssp/stack_protector.c -- 2.15.0 diff --git a/newlib/libc/ssp/stack_protector.c b/newlib/libc/ssp/stack_protector.c new file mode 100644 index 000000000..ee014b69d --- /dev/null +++ b/newlib/libc/ssp/stack_protector.c @@ -0,0 +1,45 @@ +#include +#include +#include +#include +#include +#include + +uintptr_t __stack_chk_guard = 0; + +void +__attribute__((__constructor__)) +__stack_chk_init (void) +{ + if (__stack_chk_guard != 0) + return; + +#if defined(__CYGWIN__) || defined(__rtems__) + arc4random_buf(&__stack_chk_guard, sizeof(__stack_chk_guard)); +#else + /* If getentropy is not available, use the "terminator canary". */ + ((unsigned char *)&__stack_chk_guard)[0] = 0; + ((unsigned char *)&__stack_chk_guard)[1] = 0; + ((unsigned char *)&__stack_chk_guard)[2] = '\n'; + ((unsigned char *)&__stack_chk_guard)[3] = 255; +#endif +} + +void +__attribute__((__noreturn__)) +__stack_chk_fail (void) +{ + char msg[] = "*** stack smashing detected ***: terminated\n"; + write (2, msg, strlen (msg)); + raise (SIGABRT); + _exit (127); +} + +#ifdef __ELF__ +void +__attribute__((visibility ("hidden"))) +__stack_chk_fail_local (void) +{ + __stack_chk_fail(); +} +#endif From patchwork Wed Nov 29 00:21:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yaakov Selkowitz X-Patchwork-Id: 119909 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp2395671qgn; Tue, 28 Nov 2017 16:22:13 -0800 (PST) X-Google-Smtp-Source: AGs4zMZ8tE50T5IXBTsUI1K+7LrPbhJLieIy7Q+L/s6BJ17Lw/6aLtVGRqMM6L6ftidXhQZJUBuG X-Received: by 10.159.194.197 with SMTP id u5mr987898plz.448.1511914933866; Tue, 28 Nov 2017 16:22:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511914933; cv=none; d=google.com; s=arc-20160816; b=u41Di7ycd9ISPmyo7/MrdzfZHo18ssKEd/ydsKxpf8caNSffhG6xMSBkcEu2ohuOIS pmMcfUy8/31vxxhTwmAWMTT1eRwJCpCjeJd98WzMB/3m8JaWVStbRMwIiYR5LX8f3Epw ULSJnV0ZpzC+TcM3BVlOyukElQTrnv2gfu6iklPekL/o5OjpWeR6QgjrEqYGa8f8O0in 73e47bznOWpsVbiZxFOnmV0chANndl3SsKA47exrv0Hp8ePiJHl5fzZGDK+v/aevPHXe 5aBW2cAYreHQnN5lHJv77wI/71p8nRnvDnc0jX86bPBFMr9c93tlCb+NEN72fxdN3aMI eTfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:to:from:delivered-to :sender:list-help:list-post:list-archive:list-subscribe :list-unsubscribe:list-id:precedence:mailing-list:dkim-signature :domainkey-signature:arc-authentication-results; bh=U8T8Ov84Lng68VrsXgzRPt39gL1aZOV+o6O8VkElBxQ=; b=zaMZlKDU5I4nr5zDNVgWsWn/TgaBUTkklG/z6086FFgf4gxvyuOOAhy9FPHAn7hRXZ Mb4Mt+pC+t2b3qkXnuv7BS2QrULk+XstDm2Q7u6OFICP9IGHDzXpOKowXWQr6Ry5SLIZ 2X8Ftncl1jfevY7hDGjlT1LsKqO/mJ4PGlIA8sq7tuf6kSgIsK+XMdKAX2zGUm57sbya h3ZvE1NyKKtMU25vj9Ksij15JuMUWB1Cm9qtBF30QlXy0V0IJLjSDRJx1DHExWoZzxuk RuxkO3Buo955h7JDTfbAAL0/RPhpl4ssgRW0PvyouDimfVARuq+hos3ryZTWIFvNwziv zhyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=nvBHNiQu; spf=pass (google.com: domain of newlib-return-15387-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=newlib-return-15387-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id u14si307228pfh.288.2017.11.28.16.22.13 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 28 Nov 2017 16:22:13 -0800 (PST) Received-SPF: pass (google.com: domain of newlib-return-15387-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=nvBHNiQu; spf=pass (google.com: domain of newlib-return-15387-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=newlib-return-15387-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=Zsh5RYE5rfg8TrC/ZBGc1O+gBleAIft nZ0B+OyrdItSuNZnjXFGSmAf3vr2MbSYMbMKfo3cho2nz/C4AJaQAOuqtVms1QAX ZAOFUbkfp+2rduWjEjbfl3E40Who8KeLBf3dc44qmedfSnEzm4aub3hKCQ4cse7o VPLHsnhpH1To= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; s=default; bh=gh74MMAT9LF8nRXSMV+9fWn2jRQ=; b=nvBHN iQujlvrK1wFCcV598wIo4LiCgyH8SZLPmClV/AbeG4jwoptCv9Yotwcli84sCn2T E1zT/jHHYrhzpPmz8TOQpZ86b93/SbYB9/h6GjVYwx9e8YxlYziPMdLbqpS7AYN0 SYbNth0OAznwC8yNVuV6/2Cvy+mNk+rP2zBGa8= Received: (qmail 64668 invoked by alias); 29 Nov 2017 00:21:56 -0000 Mailing-List: contact newlib-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: newlib-owner@sourceware.org Delivered-To: mailing list newlib@sourceware.org Received: (qmail 64597 invoked by uid 89); 29 Nov 2017 00:21:56 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.7 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KB_WAM_FROM_NAME_SINGLEWORD, SPF_HELO_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy= X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 29 Nov 2017 00:21:54 +0000 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 722CC356D8 for ; Wed, 29 Nov 2017 00:21:53 +0000 (UTC) Received: from localhost.localdomain (ovpn-120-11.rdu2.redhat.com [10.10.120.11]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0B375600D1 for ; Wed, 29 Nov 2017 00:21:52 +0000 (UTC) From: Yaakov Selkowitz To: newlib@sourceware.org Subject: [PATCH v4 02/10] ssp: add Object Size Checking common code Date: Tue, 28 Nov 2017 18:21:35 -0600 Message-Id: <20171129002143.12500-3-yselkowi@redhat.com> In-Reply-To: <20171129002143.12500-1-yselkowi@redhat.com> References: <20171129002143.12500-1-yselkowi@redhat.com> The Object Size Checking (-D_FORTIFY_SOURCE=*) functionality provides wrappers around functions suspectible to buffer overflows. While independent from Stack Smashing Protection (-fstack-protector*), they are often used and implemented together. While GCC also provides an implementation in libssp, it is completely broken (CVE-2016-4973, RHBZ#1324759) and seemingly unfixable, as there is no reliable way for a preprocessor macro to trigger a link flag. Therefore, adding this here is necessary to make it work. Note that this does require building gcc with --disable-libssp and gcc_cv_libc_provides_ssp=yes. Signed-off-by: Yaakov Selkowitz --- newlib/libc/include/ssp/ssp.h | 75 ++++++++++++++++++++++++++++++++++++++ newlib/libc/include/sys/features.h | 18 ++++++++- newlib/libc/ssp/chk_fail.c | 13 +++++++ 3 files changed, 105 insertions(+), 1 deletion(-) create mode 100644 newlib/libc/include/ssp/ssp.h create mode 100644 newlib/libc/ssp/chk_fail.c -- 2.15.0 diff --git a/newlib/libc/include/ssp/ssp.h b/newlib/libc/include/ssp/ssp.h new file mode 100644 index 000000000..e3c2728c7 --- /dev/null +++ b/newlib/libc/include/ssp/ssp.h @@ -0,0 +1,75 @@ +/* $NetBSD: ssp.h,v 1.13 2015/09/03 20:43:47 plunky Exp $ */ + +/*- + * Copyright (c) 2006, 2011 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Christos Zoulas. + * + * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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. + */ +#ifndef _SSP_SSP_H_ +#define _SSP_SSP_H_ + +#include + +/* __ssp_real is used by the implementation in libc */ +#if __SSP_FORTIFY_LEVEL == 0 +#define __ssp_real_(fun) fun +#else +#define __ssp_real_(fun) __ssp_real_ ## fun +#endif +#define __ssp_real(fun) __ssp_real_(fun) + +#define __ssp_bos(ptr) __builtin_object_size(ptr, __SSP_FORTIFY_LEVEL > 1) +#define __ssp_bos0(ptr) __builtin_object_size(ptr, 0) + +#define __ssp_check(buf, len, bos) \ + if (bos(buf) != (size_t)-1 && len > bos(buf)) \ + __chk_fail() +#define __ssp_decl(rtype, fun, symbol, args) \ +rtype __ssp_real_(fun) args __asm__(__ASMNAME(#symbol)); \ +_ELIDABLE_INLINE rtype fun args __asm__(__ASMNAME("__ssp_protected_" #fun)); \ +_ELIDABLE_INLINE rtype fun args +#define __ssp_redirect_raw(rtype, fun, symbol, args, call, cond, bos) \ +__ssp_decl(rtype, fun, symbol, args) \ +{ \ + if (cond) \ + __ssp_check(__buf, __len, bos); \ + return __ssp_real_(fun) call; \ +} + +#define __ssp_redirect(rtype, fun, args, call) \ + __ssp_redirect_raw(rtype, fun, fun, args, call, 1, __ssp_bos) +#define __ssp_redirect0(rtype, fun, args, call) \ + __ssp_redirect_raw(rtype, fun, fun, args, call, 1, __ssp_bos0) + +#define __ssp_overlap(a, b, l) \ + (((a) <= (b) && (b) < (a) + (l)) || ((b) <= (a) && (a) < (b) + (l))) + +__BEGIN_DECLS +void __stack_chk_fail(void) __dead2; +void __chk_fail(void) __dead2; +__END_DECLS + +#endif /* _SSP_SSP_H_ */ diff --git a/newlib/libc/include/sys/features.h b/newlib/libc/include/sys/features.h index 95d20533e..2900b332f 100644 --- a/newlib/libc/include/sys/features.h +++ b/newlib/libc/include/sys/features.h @@ -100,6 +100,9 @@ extern "C" { * _SVID_SOURCE (deprecated by _DEFAULT_SOURCE) * _DEFAULT_SOURCE (or none of the above) * POSIX-1.2008 with BSD and SVr4 extensions + * + * _FORTIFY_SOURCE = 1 or 2 + * Object Size Checking function wrappers */ #ifdef _GNU_SOURCE @@ -233,9 +236,11 @@ extern "C" { * __GNU_VISIBLE * GNU extensions; enabled with _GNU_SOURCE. * + * __SSP_FORTIFY_LEVEL + * Object Size Checking; defined to 0 (off), 1, or 2. + * * In all cases above, "enabled by default" means either by defining * _DEFAULT_SOURCE, or by not defining any of the public feature test macros. - * Defining _GNU_SOURCE makes all of the above avaliable. */ #ifdef _ATFILE_SOURCE @@ -314,6 +319,17 @@ extern "C" { #define __XSI_VISIBLE 0 #endif +#if _FORTIFY_SOURCE > 0 && !defined(__cplusplus) && !defined(__lint__) && \ + (__OPTIMIZE__ > 0 || defined(__clang__)) && __GNUC_PREREQ__(4, 1) +# if _FORTIFY_SOURCE > 1 +# define __SSP_FORTIFY_LEVEL 2 +# else +# define __SSP_FORTIFY_LEVEL 1 +# endif +#else +# define __SSP_FORTIFY_LEVEL 0 +#endif + /* RTEMS adheres to POSIX -- 1003.1b with some features from annexes. */ #ifdef __rtems__ diff --git a/newlib/libc/ssp/chk_fail.c b/newlib/libc/ssp/chk_fail.c new file mode 100644 index 000000000..b1f8e42a6 --- /dev/null +++ b/newlib/libc/ssp/chk_fail.c @@ -0,0 +1,13 @@ +#include +#include +#include + +void +__attribute__((__noreturn__)) +__chk_fail(void) +{ + char msg[] = "*** buffer overflow detected ***: terminated\n"; + write (2, msg, strlen (msg)); + raise (SIGABRT); + _exit (127); +} From patchwork Wed Nov 29 00:21:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yaakov Selkowitz X-Patchwork-Id: 119912 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp2396057qgn; Tue, 28 Nov 2017 16:22:38 -0800 (PST) X-Google-Smtp-Source: AGs4zMYAArUCvSO9GoYeIpAV1UR2tsiarJ8Zz5STOQJZ95JFMSz42vOzAV5hmn0QHHyZV4/9EgvE X-Received: by 10.84.217.150 with SMTP id p22mr944398pli.427.1511914958109; Tue, 28 Nov 2017 16:22:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511914958; cv=none; d=google.com; s=arc-20160816; b=wSOfJDDBy8b2TmFmxWiljaK+EqsXqqC7/iatC5z6XHo3hjCq9OrBtsPdtd+WZgIVAi DXV1AWQXu5qlt8qONR3H0ZwhZ+rd9K7pMN+9UC+0kTvOiSshniO87vxAA0i65GHJuGs2 XBuh2nZOE6W2xKgJ6YCactNjfc2wW2zxpt2IzuziRny9PQzMDbp4ozzq+Vp5/DXHCf7d u349xOJkqxAR1VXZaMTIZ/olohQJQNyTyIp75tz08ThHoIGk6SMUqW8H5fbxFuWtpbpj v+lqG19eyem0xemJBc0HldLYL4f+oUksGnZhZIyasOUY7mpLvFGFFkvgLiZsmQ5fdRKr 09tw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:to:from:delivered-to :sender:list-help:list-post:list-archive:list-subscribe :list-unsubscribe:list-id:precedence:mailing-list:dkim-signature :domainkey-signature:arc-authentication-results; bh=4teDZCuoL53FbRtDhK6A5q60o49Qj/TqvDNZpnwUpx0=; b=0hA7rMQSM4CQBGrK0fiL2bdnFAxDriXh8rAaKfZZDE3OS10liUUjYxzwrTaB1Nphqq umnhA7nDDN67Ymgb9iKpsfa2ltSAW+i7WjSN7dW1q9Lldql2T/wGCpVz9IzuAeANN15y bOy0mLJAzHodY6bbmMyxVGLLrZys1agGyGbiGeyaNBu22A11WGkXdA/goP+LQcocnuYl gJ6t2zhT2kXVLlO+cw/bkVSiSusil+u1TC3JsRA4DG1v7Ql/QGZq7UYehbMtM0D89FZd Jbfm9WbX12jXZ8Gvs1pxIyQ5VFKhj1QQ1TbS1kisK5Ek5jKt+8i6bBVVHVBkyv0ipSTU jZtQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=OP4PA1uH; spf=pass (google.com: domain of newlib-return-15390-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=newlib-return-15390-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id r2si292051pgs.685.2017.11.28.16.22.37 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 28 Nov 2017 16:22:38 -0800 (PST) Received-SPF: pass (google.com: domain of newlib-return-15390-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=OP4PA1uH; spf=pass (google.com: domain of newlib-return-15390-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=newlib-return-15390-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=FeQ/NJg24xj6YB/txgCuOHauNkgfPJw MILQzJLeYmwln2SCyOjeC2bVw+4vl0HMk30bjfFmKA5ZQ+boW+1dKVM3fPcL4IhM WrARMak226pDUrX/qcQgv4SxRQC8ixMX1oZJkNcMERBECKDDnaavRJBK/+6DApai j/SSPfu1ztIA= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; s=default; bh=QmUz6cVDUk0ergPPsJpYhTNzbI4=; b=OP4PA 1uHPFeCpAD6xEzoTkJK9gZ/lI2virRZCEIdxV4XhALZ7aewlrvRKD////meJH5n6 MdM9E8hbT9IjvomlkXaoaSoTM8jjv+eOgjA+IoDyISesiPobQ9GefzXLhJN/3/T/ me53GcreP7BQ2sO9XodGUnTKpm2j965oA7x+ek= Received: (qmail 66272 invoked by alias); 29 Nov 2017 00:22:00 -0000 Mailing-List: contact newlib-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: newlib-owner@sourceware.org Delivered-To: mailing list newlib@sourceware.org Received: (qmail 66137 invoked by uid 89); 29 Nov 2017 00:21:59 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.7 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KB_WAM_FROM_NAME_SINGLEWORD, SPF_HELO_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=1115 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 29 Nov 2017 00:21:55 +0000 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 26202822 for ; Wed, 29 Nov 2017 00:21:54 +0000 (UTC) Received: from localhost.localdomain (ovpn-120-11.rdu2.redhat.com [10.10.120.11]) by smtp.corp.redhat.com (Postfix) with ESMTPS id ADCF3600D1 for ; Wed, 29 Nov 2017 00:21:53 +0000 (UTC) From: Yaakov Selkowitz To: newlib@sourceware.org Subject: [PATCH v4 03/10] ssp: add Object Size Checking for string.h functions Date: Tue, 28 Nov 2017 18:21:36 -0600 Message-Id: <20171129002143.12500-4-yselkowi@redhat.com> In-Reply-To: <20171129002143.12500-1-yselkowi@redhat.com> References: <20171129002143.12500-1-yselkowi@redhat.com> The implementation is from NetBSD, with the addition of mempcpy (a GNU extension) for parity with glibc and libssp. Signed-off-by: Yaakov Selkowitz --- newlib/libc/include/ssp/string.h | 115 +++++++++++++++++++++++++++++++++++++++ newlib/libc/include/string.h | 4 ++ newlib/libc/ssp/memcpy_chk.c | 54 ++++++++++++++++++ newlib/libc/ssp/memmove_chk.c | 50 +++++++++++++++++ newlib/libc/ssp/mempcpy_chk.c | 21 +++++++ newlib/libc/ssp/memset_chk.c | 49 +++++++++++++++++ newlib/libc/ssp/stpcpy_chk.c | 58 ++++++++++++++++++++ newlib/libc/ssp/stpncpy_chk.c | 56 +++++++++++++++++++ newlib/libc/ssp/strcat_chk.c | 62 +++++++++++++++++++++ newlib/libc/ssp/strcpy_chk.c | 55 +++++++++++++++++++ newlib/libc/ssp/strncat_chk.c | 73 +++++++++++++++++++++++++ newlib/libc/ssp/strncpy_chk.c | 55 +++++++++++++++++++ 12 files changed, 652 insertions(+) create mode 100644 newlib/libc/include/ssp/string.h create mode 100644 newlib/libc/ssp/memcpy_chk.c create mode 100644 newlib/libc/ssp/memmove_chk.c create mode 100644 newlib/libc/ssp/mempcpy_chk.c create mode 100644 newlib/libc/ssp/memset_chk.c create mode 100644 newlib/libc/ssp/stpcpy_chk.c create mode 100644 newlib/libc/ssp/stpncpy_chk.c create mode 100644 newlib/libc/ssp/strcat_chk.c create mode 100644 newlib/libc/ssp/strcpy_chk.c create mode 100644 newlib/libc/ssp/strncat_chk.c create mode 100644 newlib/libc/ssp/strncpy_chk.c -- 2.15.0 diff --git a/newlib/libc/include/ssp/string.h b/newlib/libc/include/ssp/string.h new file mode 100644 index 000000000..cd5592ba6 --- /dev/null +++ b/newlib/libc/include/ssp/string.h @@ -0,0 +1,115 @@ +/* $NetBSD: string.h,v 1.13 2014/11/29 13:23:48 pooka Exp $ */ + +/*- + * Copyright (c) 2006 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Christos Zoulas. + * + * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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. + */ +#ifndef _SSP_STRING_H_ +#define _SSP_STRING_H_ + +#include +#include + +__BEGIN_DECLS +void *__memcpy_chk(void *, const void *, size_t, size_t); +void *__memmove_chk(void *, void *, size_t, size_t); +void *__mempcpy_chk(void *, const void *, size_t, size_t); +void *__memset_chk(void *, int, size_t, size_t); +char *__stpcpy_chk(char *, const char *, size_t); +char *__strcat_chk(char *, const char *, size_t); +char *__strcpy_chk(char *, const char *, size_t); +char *__strncat_chk(char *, const char *, size_t, size_t); +char *__strncpy_chk(char *, const char *, size_t, size_t); +__END_DECLS + +#if __SSP_FORTIFY_LEVEL > 0 + +#define __ssp_bos_check3(fun, dst, src, len) \ + ((__ssp_bos0(dst) != (size_t)-1) ? \ + __builtin___ ## fun ## _chk(dst, src, len, __ssp_bos0(dst)) : \ + __ ## fun ## _ichk(dst, src, len)) + +#define __ssp_bos_check2(fun, dst, src) \ + ((__ssp_bos0(dst) != (size_t)-1) ? \ + __builtin___ ## fun ## _chk(dst, src, __ssp_bos0(dst)) : \ + __ ## fun ## _ichk(dst, src)) + +#define __ssp_bos_icheck3_restrict(fun, type1, type2) \ +_ELIDABLE_INLINE type1 __ ## fun ## _ichk(type1 __restrict, type2 __restrict, size_t); \ +_ELIDABLE_INLINE type1 \ +__ ## fun ## _ichk(type1 __restrict dst, type2 __restrict src, size_t len) { \ + return __builtin___ ## fun ## _chk(dst, src, len, __ssp_bos0(dst)); \ +} + +#define __ssp_bos_icheck3(fun, type1, type2) \ +_ELIDABLE_INLINE type1 __ ## fun ## _ichk(type1, type2, size_t); \ +_ELIDABLE_INLINE type1 \ +__ ## fun ## _ichk(type1 dst, type2 src, size_t len) { \ + return __builtin___ ## fun ## _chk(dst, src, len, __ssp_bos0(dst)); \ +} + +#define __ssp_bos_icheck2_restrict(fun, type1, type2) \ +_ELIDABLE_INLINE type1 __ ## fun ## _ichk(type1, type2); \ +_ELIDABLE_INLINE type1 \ +__ ## fun ## _ichk(type1 __restrict dst, type2 __restrict src) { \ + return __builtin___ ## fun ## _chk(dst, src, __ssp_bos0(dst)); \ +} + +__BEGIN_DECLS +__ssp_bos_icheck3_restrict(memcpy, void *, const void *) +__ssp_bos_icheck3(memmove, void *, const void *) +__ssp_bos_icheck3_restrict(mempcpy, void *, const void *) +__ssp_bos_icheck3(memset, void *, int) +__ssp_bos_icheck2_restrict(stpcpy, char *, const char *) +#if __GNUC_PREREQ__(4,8) || defined(__clang__) +__ssp_bos_icheck3_restrict(stpncpy, char *, const char *) +#endif +__ssp_bos_icheck2_restrict(strcpy, char *, const char *) +__ssp_bos_icheck2_restrict(strcat, char *, const char *) +__ssp_bos_icheck3_restrict(strncpy, char *, const char *) +__ssp_bos_icheck3_restrict(strncat, char *, const char *) +__END_DECLS + +#define memcpy(dst, src, len) __ssp_bos_check3(memcpy, dst, src, len) +#define memmove(dst, src, len) __ssp_bos_check3(memmove, dst, src, len) +#if __GNU_VISIBLE +#define mempcpy(dst, src, len) __ssp_bos_check3(mempcpy, dst, src, len) +#endif +#define memset(dst, val, len) __ssp_bos_check3(memset, dst, val, len) +#if __POSIX_VISIBLE >= 200809 +#define stpcpy(dst, src) __ssp_bos_check2(stpcpy, dst, src) +#if __GNUC_PREREQ__(4,8) || defined(__clang__) +#define stpncpy(dst, src, len) __ssp_bos_check3(stpncpy, dst, src, len) +#endif +#endif +#define strcpy(dst, src) __ssp_bos_check2(strcpy, dst, src) +#define strcat(dst, src) __ssp_bos_check2(strcat, dst, src) +#define strncpy(dst, src, len) __ssp_bos_check3(strncpy, dst, src, len) +#define strncat(dst, src, len) __ssp_bos_check3(strncat, dst, src, len) + +#endif /* __SSP_FORTIFY_LEVEL > 0 */ +#endif /* _SSP_STRING_H_ */ diff --git a/newlib/libc/include/string.h b/newlib/libc/include/string.h index 57db7742b..b54b83335 100644 --- a/newlib/libc/include/string.h +++ b/newlib/libc/include/string.h @@ -176,4 +176,8 @@ char *_EXFUN(__nonnull ((1)) basename,(const char *)) __asm__(__ASMNAME("__gnu_b _END_STD_C +#if __SSP_FORTIFY_LEVEL > 0 +#include +#endif + #endif /* _STRING_H_ */ diff --git a/newlib/libc/ssp/memcpy_chk.c b/newlib/libc/ssp/memcpy_chk.c new file mode 100644 index 000000000..63f536dc5 --- /dev/null +++ b/newlib/libc/ssp/memcpy_chk.c @@ -0,0 +1,54 @@ +/* $NetBSD: memcpy_chk.c,v 1.7 2015/05/13 19:57:16 joerg Exp $ */ + +/*- + * Copyright (c) 2006 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Christos Zoulas. + * + * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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 +__RCSID("$NetBSD: memcpy_chk.c,v 1.7 2015/05/13 19:57:16 joerg Exp $"); + +/*LINTLIBRARY*/ + +#include +#include + +#undef memcpy + +void *__memcpy_chk(void * __restrict, const void * __restrict, size_t, size_t); + +void * +__memcpy_chk(void * __restrict dst, const void * __restrict src, size_t len, + size_t slen) +{ + if (len > slen) + __chk_fail(); + + if (__ssp_overlap((const char *)src, (const char *)dst, len)) + __chk_fail(); + + return memcpy(dst, src, len); +} diff --git a/newlib/libc/ssp/memmove_chk.c b/newlib/libc/ssp/memmove_chk.c new file mode 100644 index 000000000..f8f03d778 --- /dev/null +++ b/newlib/libc/ssp/memmove_chk.c @@ -0,0 +1,50 @@ +/* $NetBSD: memmove_chk.c,v 1.5 2014/09/17 00:39:28 joerg Exp $ */ + +/*- + * Copyright (c) 2006 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Christos Zoulas. + * + * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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 +__RCSID("$NetBSD: memmove_chk.c,v 1.5 2014/09/17 00:39:28 joerg Exp $"); + +/*LINTLIBRARY*/ + +#include +#include + +#undef memmove + +void *__memmove_chk(void *, void *src, size_t, size_t); + +void * +__memmove_chk(void *dst, void *src, size_t len, + size_t slen) +{ + if (len > slen) + __chk_fail(); + return memmove(dst, src, len); +} diff --git a/newlib/libc/ssp/mempcpy_chk.c b/newlib/libc/ssp/mempcpy_chk.c new file mode 100644 index 000000000..fc2ccf894 --- /dev/null +++ b/newlib/libc/ssp/mempcpy_chk.c @@ -0,0 +1,21 @@ +#define _GNU_SOURCE +#include +#include +#include + +#undef mempcpy + +void *__mempcpy_chk(void * __restrict, const void * __restrict, size_t, size_t); + +void * +__mempcpy_chk(void * __restrict dst, const void * __restrict src, size_t len, + size_t slen) +{ + if (len > slen) + __chk_fail(); + + if (__ssp_overlap((const char *)src, (const char *)dst, len)) + __chk_fail(); + + return mempcpy(dst, src, len); +} diff --git a/newlib/libc/ssp/memset_chk.c b/newlib/libc/ssp/memset_chk.c new file mode 100644 index 000000000..0e303b9eb --- /dev/null +++ b/newlib/libc/ssp/memset_chk.c @@ -0,0 +1,49 @@ +/* $NetBSD: memset_chk.c,v 1.5 2014/09/17 00:39:28 joerg Exp $ */ + +/*- + * Copyright (c) 2006 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Christos Zoulas. + * + * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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 +__RCSID("$NetBSD: memset_chk.c,v 1.5 2014/09/17 00:39:28 joerg Exp $"); + +/*LINTLIBRARY*/ + +#include +#include + +#undef memset + +void *__memset_chk(void * __restrict, int, size_t, size_t); + +void * +__memset_chk(void * __restrict dst, int val, size_t len, size_t slen) +{ + if (len > slen) + __chk_fail(); + return memset(dst, val, len); +} diff --git a/newlib/libc/ssp/stpcpy_chk.c b/newlib/libc/ssp/stpcpy_chk.c new file mode 100644 index 000000000..ed1d74ad7 --- /dev/null +++ b/newlib/libc/ssp/stpcpy_chk.c @@ -0,0 +1,58 @@ +/* $NetBSD: stpcpy_chk.c,v 1.6 2015/05/09 15:42:21 christos Exp $ */ + +/*- + * Copyright (c) 2013 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Christos Zoulas. + * + * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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 +__RCSID("$NetBSD: stpcpy_chk.c,v 1.6 2015/05/09 15:42:21 christos Exp $"); + +/*LINTLIBRARY*/ + +#include +#include + +#undef memcpy + +#if !__GNUC_PREREQ__(4, 8) +char *__stpcpy_chk(char * __restrict, const char * __restrict, size_t); +#endif + +char * +__stpcpy_chk(char * __restrict dst, const char * __restrict src, size_t slen) +{ + size_t len = strlen(src); + + if (len >= slen) + __chk_fail(); + + if (__ssp_overlap(src, dst, len)) + __chk_fail(); + + (void)memcpy(dst, src, len + 1); + return dst + len; +} diff --git a/newlib/libc/ssp/stpncpy_chk.c b/newlib/libc/ssp/stpncpy_chk.c new file mode 100644 index 000000000..756626153 --- /dev/null +++ b/newlib/libc/ssp/stpncpy_chk.c @@ -0,0 +1,56 @@ +/* $NetBSD: stpncpy_chk.c,v 1.3 2015/05/09 15:42:21 christos Exp $ */ + +/*- + * Copyright (c) 2013 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Christos Zoulas. + * + * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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 +__RCSID("$NetBSD: stpncpy_chk.c,v 1.3 2015/05/09 15:42:21 christos Exp $"); + +/*LINTLIBRARY*/ + +#include +#include + +#undef stpncpy + +#if !__GNUC_PREREQ__(4, 8) +char *__stpncpy_chk(char * __restrict, const char * __restrict, size_t, size_t); +#endif + +char * +__stpncpy_chk(char * __restrict dst, const char * __restrict src, size_t len, + size_t slen) +{ + if (len > slen) + __chk_fail(); + + if (__ssp_overlap(src, dst, len)) + __chk_fail(); + + return stpncpy(dst, src, len); +} diff --git a/newlib/libc/ssp/strcat_chk.c b/newlib/libc/ssp/strcat_chk.c new file mode 100644 index 000000000..d57f9559b --- /dev/null +++ b/newlib/libc/ssp/strcat_chk.c @@ -0,0 +1,62 @@ +/* $NetBSD: strcat_chk.c,v 1.5 2014/09/17 00:39:28 joerg Exp $ */ + +/*- + * Copyright (c) 2006 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Christos Zoulas. + * + * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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 +__RCSID("$NetBSD: strcat_chk.c,v 1.5 2014/09/17 00:39:28 joerg Exp $"); + +/*LINTLIBRARY*/ + +#include +#include + +char *__strcat_chk(char * __restrict, const char * __restrict, size_t); + +char * +__strcat_chk(char * __restrict dst, const char * __restrict src, size_t slen) +{ + char *d; + + for (d = dst; *d; d++) { + if (slen-- == 0) + __chk_fail(); + } + + while (*src) { + if (slen-- == 0) + __chk_fail(); + *d++ = *src++; + } + + if (slen-- == 0) + __chk_fail(); + + *d = '\0'; + return dst; +} diff --git a/newlib/libc/ssp/strcpy_chk.c b/newlib/libc/ssp/strcpy_chk.c new file mode 100644 index 000000000..cef160a62 --- /dev/null +++ b/newlib/libc/ssp/strcpy_chk.c @@ -0,0 +1,55 @@ +/* $NetBSD: strcpy_chk.c,v 1.8 2015/05/09 15:42:21 christos Exp $ */ + +/*- + * Copyright (c) 2006 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Christos Zoulas. + * + * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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 +__RCSID("$NetBSD: strcpy_chk.c,v 1.8 2015/05/09 15:42:21 christos Exp $"); + +/*LINTLIBRARY*/ + +#include +#include + +#undef memcpy + +char *__strcpy_chk(char * __restrict, const char * __restrict, size_t); + +char * +__strcpy_chk(char * __restrict dst, const char * __restrict src, size_t slen) +{ + size_t len = strlen(src) + 1; + + if (len > slen) + __chk_fail(); + + if (__ssp_overlap(src, dst, len)) + __chk_fail(); + + return memcpy(dst, src, len); +} diff --git a/newlib/libc/ssp/strncat_chk.c b/newlib/libc/ssp/strncat_chk.c new file mode 100644 index 000000000..5ce5a9ef6 --- /dev/null +++ b/newlib/libc/ssp/strncat_chk.c @@ -0,0 +1,73 @@ +/* $NetBSD: strncat_chk.c,v 1.5 2014/09/17 00:39:28 joerg Exp $ */ + +/*- + * Copyright (c) 2006 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Christos Zoulas. + * + * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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 +__RCSID("$NetBSD: strncat_chk.c,v 1.5 2014/09/17 00:39:28 joerg Exp $"); + +/*LINTLIBRARY*/ + +#include +#include +#include + +char *__strncat_chk(char * __restrict, const char * __restrict, size_t, + size_t); + +char * +__strncat_chk(char * __restrict dst, const char * __restrict src, size_t len, + size_t slen) +{ + char *d; + + if (len == 0) + return dst; + + if (len > slen) + __chk_fail(); + + for (d = dst; *d; d++) { + if (slen-- == 0) + __chk_fail(); + } + + do { + if ((*d = *src++) == '\0') + break; + if (slen-- == 0) + __chk_fail(); + d++; + } while (--len != 0); + + if (slen-- == 0) + __chk_fail(); + + *d = '\0'; + return dst; +} diff --git a/newlib/libc/ssp/strncpy_chk.c b/newlib/libc/ssp/strncpy_chk.c new file mode 100644 index 000000000..591157a25 --- /dev/null +++ b/newlib/libc/ssp/strncpy_chk.c @@ -0,0 +1,55 @@ +/* $NetBSD: strncpy_chk.c,v 1.6 2015/05/09 15:42:21 christos Exp $ */ + +/*- + * Copyright (c) 2006 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Christos Zoulas. + * + * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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 +__RCSID("$NetBSD: strncpy_chk.c,v 1.6 2015/05/09 15:42:21 christos Exp $"); + +/*LINTLIBRARY*/ + +#include +#include + +#undef strncpy + +char *__strncpy_chk(char * __restrict, const char * __restrict, size_t, + size_t); + +char * +__strncpy_chk(char * __restrict dst, const char * __restrict src, size_t len, + size_t slen) +{ + if (len > slen) + __chk_fail(); + + if (__ssp_overlap(src, dst, len)) + __chk_fail(); + + return strncpy(dst, src, len); +} From patchwork Wed Nov 29 00:21:37 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yaakov Selkowitz X-Patchwork-Id: 119918 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp2404265qgn; Tue, 28 Nov 2017 16:31:55 -0800 (PST) X-Google-Smtp-Source: AGs4zMYjKbblYLesnMddV1tJMWjYSEjFGpncJw1hc5lfc8ZMn/sa4Opv8gkfTTOfY0x5it6vE+8n X-Received: by 10.159.240.138 with SMTP id p10mr1009473plr.360.1511915515307; Tue, 28 Nov 2017 16:31:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511915515; cv=none; d=google.com; s=arc-20160816; b=IrlpNqFj9Z/qDRT/S/2SFBAkJIMpVHP89UIKMp4b8ZAtuXONnJq2cXm+QwAKqph1XG 9O0KAAlO0WdGwGQJ/VdBXzIxel7UySpRnw+y0iAgxwaWfusSQXO7XJR5ZRxzXCzQ5YrV gjfu9BK7JHNFbzT86A7NPSJTs6eUDL0vpdtjE7sMCG5z+my2TMVqwMGsVAxb152ynoLY UWpX29E3tJQCdBrj2klTVt4wnkM1kM/4c7AmIBj8Wf9RPEYRtLh1TLg3fl4WoeM85m4e bydCqcLSd42uT/Fv4tqK4SQiHogX0mSem+537h3Tcur2N2+KhAs4UyuX6tjHJrlOYoUx hhMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:to:from:delivered-to :sender:list-help:list-post:list-archive:list-subscribe :list-unsubscribe:list-id:precedence:mailing-list:dkim-signature :domainkey-signature:arc-authentication-results; bh=AXfYNCaHkrx3RcBZbrOJjfSPzkllnVBDQUjRiVEL0ts=; b=N6CBaEFQ89ThZpD8+qok4Ct2xhdFmgh65xrChdDfXrdnEUOwXXCv5Dzz7Le56TVz+V iZ0SMqvjSlVTs7ZahVpkQTadhXuLunSDix+x0OCEBlD2BZ9RiTCn/daSZ0wuWNqKqvLQ i9263nAQGINwvLWp0HIydvemyIOEHvMkYl2ZF3qPtTt/TlS/BZAdC32F+7qyXkSy+YNx hVFCpx8sbatNbN0HLf15JXdREGDvCkUoMj5Fk1rvNqUcLL6e4ZvlaIRygoiZJ9NVP1DJ 061S0iEO8uHRbCg9/sqvPEkg9PYoTBdKKYRY/j3SahwsFlV2lIwrZLu8IlPhvN6gUYcc BE1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=JE0zMHjd; spf=pass (google.com: domain of newlib-return-15396-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=newlib-return-15396-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id q29si298444pgc.765.2017.11.28.16.31.54 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 28 Nov 2017 16:31:55 -0800 (PST) Received-SPF: pass (google.com: domain of newlib-return-15396-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=JE0zMHjd; spf=pass (google.com: domain of newlib-return-15396-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=newlib-return-15396-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=s06u9OozOEbIojzQiTMgMQEOuxYZau4 Rl4ywxQ+GPNoIqSKGH7YCq8Ktels569+Iu6FwseIZDIvByXl3pwj6HQrPZl7ytHk ItNo2W9l1Eu/srlXnfcx9UR+cO2sgdewhA68NQe/1IryZ9BZicCapISYyZJt73FO cZNT4b0pdQcc= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; s=default; bh=l2FfgCiS8bmvo4ONMR1UG5Z54sE=; b=JE0zM HjdivuBzsJrhGJhX2zvMtOy6NEbi/vmFyaZQywrCvdsjWhM3HYMNh07oslNjOiwI SQjVlQZ7xDvf7MBJMtJVuCk5sk0geZF5C2SSZyTcngHsdtyn9i3sNmXuBKc+DcSb XBnhD7Hw06c57ggYc8z5P3uoIzRCQEyy/F0V/w= Received: (qmail 13816 invoked by alias); 29 Nov 2017 00:31:39 -0000 Mailing-List: contact newlib-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: newlib-owner@sourceware.org Delivered-To: mailing list newlib@sourceware.org Received: (qmail 13760 invoked by uid 89); 29 Nov 2017 00:31:38 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.7 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, KB_WAM_FROM_NAME_SINGLEWORD, SPF_HELO_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=Hx-languages-length:3647 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 29 Nov 2017 00:31:37 +0000 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CC2E281DED for ; Wed, 29 Nov 2017 00:21:54 +0000 (UTC) Received: from localhost.localdomain (ovpn-120-11.rdu2.redhat.com [10.10.120.11]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6179B600D1 for ; Wed, 29 Nov 2017 00:21:54 +0000 (UTC) From: Yaakov Selkowitz To: newlib@sourceware.org Subject: [PATCH v4 04/10] ssp: add Object Size Checking for strings.h functions Date: Tue, 28 Nov 2017 18:21:37 -0600 Message-Id: <20171129002143.12500-5-yselkowi@redhat.com> In-Reply-To: <20171129002143.12500-1-yselkowi@redhat.com> References: <20171129002143.12500-1-yselkowi@redhat.com> The implementation is from NetBSD, with the addition of explicit_bzero for parity with glibc. Signed-off-by: Yaakov Selkowitz --- newlib/libc/include/ssp/strings.h | 55 +++++++++++++++++++++++++++++++++++++++ newlib/libc/include/strings.h | 6 ++++- 2 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 newlib/libc/include/ssp/strings.h -- 2.15.0 diff --git a/newlib/libc/include/ssp/strings.h b/newlib/libc/include/ssp/strings.h new file mode 100644 index 000000000..13adba175 --- /dev/null +++ b/newlib/libc/include/ssp/strings.h @@ -0,0 +1,55 @@ +/* $NetBSD: strings.h,v 1.3 2008/04/28 20:22:54 martin Exp $ */ + +/*- + * Copyright (c) 2007 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Christos Zoulas. + * + * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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. + */ +#ifndef _SSP_STRINGS_H_ +#define _SSP_STRINGS_H_ + +#include + +#if __SSP_FORTIFY_LEVEL > 0 + +#if __BSD_VISIBLE || __POSIX_VISIBLE <= 200112 +#define bcopy(src, dst, len) \ + ((__ssp_bos0(dst) != (size_t)-1) ? \ + __builtin___memmove_chk(dst, src, len, __ssp_bos0(dst)) : \ + __memmove_ichk(dst, src, len)) +#define bzero(dst, len) \ + ((__ssp_bos0(dst) != (size_t)-1) ? \ + __builtin___memset_chk(dst, 0, len, __ssp_bos0(dst)) : \ + __memset_ichk(dst, 0, len)) +#endif + +#if __BSD_VISIBLE +__ssp_redirect0(void, explicit_bzero, (void *__buf, size_t __len), \ + (__buf, __len)); +#endif + +#endif /* __SSP_FORTIFY_LEVEL > 0 */ +#endif /* _SSP_STRINGS_H_ */ diff --git a/newlib/libc/include/strings.h b/newlib/libc/include/strings.h index 50a304215..38a84a220 100644 --- a/newlib/libc/include/strings.h +++ b/newlib/libc/include/strings.h @@ -47,7 +47,7 @@ int bcmp(const void *, const void *, size_t) __pure; /* LEGACY */ void bcopy(const void *, void *, size_t); /* LEGACY */ void bzero(void *, size_t); /* LEGACY */ #endif -#if __BSD_VISIBLE +#if __BSD_VISIBLE && !__SSP_FORTIFY_LEVEL void explicit_bzero(void *, size_t); #endif #if __MISC_VISIBLE || __POSIX_VISIBLE < 200809 || __XSI_VISIBLE >= 700 @@ -73,4 +73,8 @@ int strncasecmp_l (const char *, const char *, size_t, locale_t); #endif __END_DECLS +#if __SSP_FORTIFY_LEVEL > 0 +#include +#endif + #endif /* _STRINGS_H_ */ From patchwork Wed Nov 29 00:21:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yaakov Selkowitz X-Patchwork-Id: 119915 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp2401725qgn; Tue, 28 Nov 2017 16:29:13 -0800 (PST) X-Google-Smtp-Source: AGs4zMadGoa8WVMV43CXWvpK+6nBMaugmtReEJy7MXWctybvMRXP9ciEhyzsuMu75Hy/kT7HMTo8 X-Received: by 10.98.185.8 with SMTP id z8mr1026769pfe.166.1511915352941; Tue, 28 Nov 2017 16:29:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511915352; cv=none; d=google.com; s=arc-20160816; b=LQnshL3vO/NXzW7sXOQ4YngCkj3Q+1V5UwSGrAhxRFkhujpBI/DNvgX9KNA6m67UDw mnwvUQuvYr3ZdVQgv5AEjMa55LEvPluGgqhUg5Lq9QfTBrAzgGbnqfZkP5Le2FQ/rUm3 /BIcuINEmF/gyjdLA/v/CYIPUGcJHiPfNoMQ3hOsgJqK+nbvgSyCSTb5lQgrwpspK3WU lPMuw2gmZ827ZEncGRRY/1B6UPW0sNrHTnbJhqy4jVFbzgH81M9/+sx6eQ4+aeEn9V/t B4rfmpHpssfznyOW6/AX8EIobwxUemNgN9n3h1TlKWwMcgTOHLm+byWrWJ5IrtakrVW3 elQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:to:from:delivered-to :sender:list-help:list-post:list-archive:list-subscribe :list-unsubscribe:list-id:precedence:mailing-list:dkim-signature :domainkey-signature:arc-authentication-results; bh=WODpfnjt/HdSVYvu3YDNXGmkqyDDlkL5idcQdZRpPu0=; b=rFQGEJKbVVCWO2EIVsshWjSixu/jHO35Mik6G5zCxXNADPisWh+qCAuciRJQEgvmNq 9gYgT6nUQpCfCLc+hUTKT73roJzqmyw125S6WABsKHXNq3fkB9FB6MJX5lygGPfOfWbR A5ueAr8z5yzJywTYsB2v7r9yq/9wJ4AoemhRERrheSNtdoFicAbsC8KK7EyHqCtCGFnQ 96FgUvlbkixTh48WLxOiQWqEuS+GFWahKKBSL1dn51SkBsRNTZ7S98TBVLNuQi84GKyu CWLgyFHoFNw42ZGVTfF15y1X5RVr6ZIGJuqfLCeTrJcmBBTcZrOdf8M37qOhc6bfgjYv tCBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=eMxfhivU; spf=pass (google.com: domain of newlib-return-15393-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=newlib-return-15393-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id c5si299196plr.407.2017.11.28.16.29.12 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 28 Nov 2017 16:29:12 -0800 (PST) Received-SPF: pass (google.com: domain of newlib-return-15393-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=eMxfhivU; spf=pass (google.com: domain of newlib-return-15393-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=newlib-return-15393-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=NwAQjkfajGAX/hgwyzoBaMtuxHIIWXi WjJ3FYjj4oiY7aWBSa39DjEmCbuZsI4g3NyitRsEO8XWyIdV20nOushUKLdXc3lz nSz06Y0U+dGwGCH7tXGUaGF1s8YIH/544VovquWnWTzuXeMC+SrGICYTgjxqrTWw 3d/cieZ6FVlA= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; s=default; bh=wZcDhGCv6/zGt4rlI+JfNBDuqEs=; b=eMxfh ivUdMAq7lN9FNyBIOxqAalwHWQMveDk+GtZYuSoZKcbXUtbNhxban6H+Ru/18gdr 4MxhYiBXp7ZbBZpkkSVo51TMP8vdTcvQZk0a6dhVg2f01unfJV0NoeSYCjnxZznh BqxvK4m5L5flA1FoLY2W+xhZ/OEJWxNTTPByC8= Received: (qmail 6911 invoked by alias); 29 Nov 2017 00:29:03 -0000 Mailing-List: contact newlib-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: newlib-owner@sourceware.org Delivered-To: mailing list newlib@sourceware.org Received: (qmail 6589 invoked by uid 89); 29 Nov 2017 00:29:03 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.2 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_NUMSUBJECT, KB_WAM_FROM_NAME_SINGLEWORD, SPF_HELO_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy= X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 29 Nov 2017 00:29:00 +0000 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9FE787CB84 for ; Wed, 29 Nov 2017 00:21:55 +0000 (UTC) Received: from localhost.localdomain (ovpn-120-11.rdu2.redhat.com [10.10.120.11]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 12AD7600D1 for ; Wed, 29 Nov 2017 00:21:54 +0000 (UTC) From: Yaakov Selkowitz To: newlib@sourceware.org Subject: [PATCH v4 05/10] ssp: add Object Size Checking for stdio.h functions, part 1 Date: Tue, 28 Nov 2017 18:21:38 -0600 Message-Id: <20171129002143.12500-6-yselkowi@redhat.com> In-Reply-To: <20171129002143.12500-1-yselkowi@redhat.com> References: <20171129002143.12500-1-yselkowi@redhat.com> The implementation is mostly from NetBSD, except for switching fgets to pure inline, and the addition of fgets_unlocked, fread, and fread_unlocked for parity with glibc. The following functions are also guarded in glibc: asprintf, dprintf, fprintf, printf, vasprintf, vdprintf, vfprintf, vprintf. Signed-off-by: Yaakov Selkowitz --- newlib/libc/include/ssp/stdio.h | 101 ++++++++++++++++++++++++++++++++++++++++ newlib/libc/include/stdio.h | 12 +++++ newlib/libc/ssp/gets_chk.c | 78 +++++++++++++++++++++++++++++++ newlib/libc/ssp/snprintf_chk.c | 59 +++++++++++++++++++++++ newlib/libc/ssp/sprintf_chk.c | 63 +++++++++++++++++++++++++ newlib/libc/ssp/vsnprintf_chk.c | 51 ++++++++++++++++++++ newlib/libc/ssp/vsprintf_chk.c | 60 ++++++++++++++++++++++++ 7 files changed, 424 insertions(+) create mode 100644 newlib/libc/include/ssp/stdio.h create mode 100644 newlib/libc/ssp/gets_chk.c create mode 100644 newlib/libc/ssp/snprintf_chk.c create mode 100644 newlib/libc/ssp/sprintf_chk.c create mode 100644 newlib/libc/ssp/vsnprintf_chk.c create mode 100644 newlib/libc/ssp/vsprintf_chk.c -- 2.15.0 diff --git a/newlib/libc/include/ssp/stdio.h b/newlib/libc/include/ssp/stdio.h new file mode 100644 index 000000000..050b9d9ed --- /dev/null +++ b/newlib/libc/include/ssp/stdio.h @@ -0,0 +1,101 @@ +/* $NetBSD: stdio.h,v 1.5 2011/07/17 20:54:34 joerg Exp $ */ + +/*- + * Copyright (c) 2006 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Christos Zoulas. + * + * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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. + */ +#ifndef _SSP_STDIO_H_ +#define _SSP_STDIO_H_ + +#include + +__BEGIN_DECLS +int __sprintf_chk(char *__restrict, int, size_t, const char *__restrict, ...) + __printflike(4, 5); +int __vsprintf_chk(char *__restrict, int, size_t, const char *__restrict, + __va_list) + __printflike(4, 0); +int __snprintf_chk(char *__restrict, size_t, int, size_t, + const char *__restrict, ...) + __printflike(5, 6); +int __vsnprintf_chk(char *__restrict, size_t, int, size_t, + const char *__restrict, __va_list) + __printflike(5, 0); +char *__gets_chk(char *, size_t); +__END_DECLS + +#if __SSP_FORTIFY_LEVEL > 0 + + +#define sprintf(str, ...) \ + __builtin___sprintf_chk(str, 0, __ssp_bos(str), __VA_ARGS__) + +#define vsprintf(str, fmt, ap) \ + __builtin___vsprintf_chk(str, 0, __ssp_bos(str), fmt, ap) + +#define snprintf(str, len, ...) \ + __builtin___snprintf_chk(str, len, 0, __ssp_bos(str), __VA_ARGS__) + +#define vsnprintf(str, len, fmt, ap) \ + __builtin___vsnprintf_chk(str, len, 0, __ssp_bos(str), fmt, ap) + +#define gets(str) \ + __gets_chk(str, __ssp_bos(str)) + +__ssp_decl(char *, fgets, fgets, (char *__restrict __buf, int __len, FILE *__fp)) +{ + if (__len > 0) + __ssp_check(__buf, (size_t)__len, __ssp_bos); + return __ssp_real_fgets(__buf, __len, __fp); +} + +#if __GNU_VISIBLE +__ssp_decl(char *, fgets_unlocked, fgets_unlocked, (char *__restrict __buf, int __len, FILE *__fp)) +{ + if (__len > 0) + __ssp_check(__buf, (size_t)__len, __ssp_bos); + return __ssp_real_fgets_unlocked(__buf, __len, __fp); +} +#endif /* __GNU_VISIBLE */ + +__ssp_decl(size_t, fread, fread, (void *__restrict __ptr, size_t __size, size_t __n, FILE *__restrict __fp)) +{ + __ssp_check(__ptr, __size * __n, __ssp_bos0); + return __ssp_real_fread(__ptr, __size, __n, __fp); +} + +#if __MISC_VISIBLE +__ssp_decl(size_t, fread_unlocked, fread_unlocked, (void *__restrict __ptr, size_t __size, size_t __n, FILE *__restrict __fp)) +{ + __ssp_check(__ptr, __size * __n, __ssp_bos0); + return __ssp_real_fread_unlocked(__ptr, __size, __n, __fp); +} +#endif /* __MISC_VISIBLE */ + +#endif /* __SSP_FORTIFY_LEVEL > 0 */ + +#endif /* _SSP_STDIO_H_ */ diff --git a/newlib/libc/include/stdio.h b/newlib/libc/include/stdio.h index ee0f612c4..e0490485e 100644 --- a/newlib/libc/include/stdio.h +++ b/newlib/libc/include/stdio.h @@ -210,7 +210,9 @@ int _EXFUN(vprintf, (const char *, __VALIST) int _EXFUN(vsprintf, (char *__restrict, const char *__restrict, __VALIST) _ATTRIBUTE ((__format__ (__printf__, 2, 0)))); int _EXFUN(fgetc, (FILE *)); +#if !__SSP_FORTIFY_LEVEL char * _EXFUN(fgets, (char *__restrict, int, FILE *__restrict)); +#endif int _EXFUN(fputc, (int, FILE *)); int _EXFUN(fputs, (const char *__restrict, FILE *__restrict)); int _EXFUN(getc, (FILE *)); @@ -220,7 +222,9 @@ int _EXFUN(putc, (int, FILE *)); int _EXFUN(putchar, (int)); int _EXFUN(puts, (const char *)); int _EXFUN(ungetc, (int, FILE *)); +#if !__SSP_FORTIFY_LEVEL size_t _EXFUN(fread, (_PTR __restrict, size_t _size, size_t _n, FILE *__restrict)); +#endif size_t _EXFUN(fwrite, (const _PTR __restrict , size_t _size, size_t _n, FILE *)); #ifdef _COMPILING_NEWLIB int _EXFUN(fgetpos, (FILE *, _fpos_t *)); @@ -539,12 +543,16 @@ int _EXFUN(fileno_unlocked, (FILE *)); int _EXFUN(fflush_unlocked, (FILE *)); int _EXFUN(fgetc_unlocked, (FILE *)); int _EXFUN(fputc_unlocked, (int, FILE *)); +#if !__SSP_FORTIFY_LEVEL size_t _EXFUN(fread_unlocked, (_PTR __restrict, size_t _size, size_t _n, FILE *__restrict)); +#endif size_t _EXFUN(fwrite_unlocked, (const _PTR __restrict , size_t _size, size_t _n, FILE *)); #endif #if __GNU_VISIBLE +#if !__SSP_FORTIFY_LEVEL char * _EXFUN(fgets_unlocked, (char *__restrict, int, FILE *__restrict)); +#endif int _EXFUN(fputs_unlocked, (const char *__restrict, FILE *__restrict)); #endif @@ -796,4 +804,8 @@ _putchar_unlocked(int _c) _END_STD_C +#if __SSP_FORTIFY_LEVEL > 0 +#include +#endif + #endif /* _STDIO_H_ */ diff --git a/newlib/libc/ssp/gets_chk.c b/newlib/libc/ssp/gets_chk.c new file mode 100644 index 000000000..b4f7015bc --- /dev/null +++ b/newlib/libc/ssp/gets_chk.c @@ -0,0 +1,78 @@ +/* $NetBSD: gets_chk.c,v 1.7 2013/10/04 20:49:16 christos Exp $ */ + +/*- + * Copyright (c) 2006 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Christos Zoulas. + * + * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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 +__RCSID("$NetBSD: gets_chk.c,v 1.7 2013/10/04 20:49:16 christos Exp $"); + +/*LINTLIBRARY*/ + +#include +#include +#include +#include +#include +#include + +extern char *__gets(char *); +#undef gets +#ifdef __NEWLIB__ +#define __gets gets +#endif + +char * +__gets_chk(char * __restrict buf, size_t slen) +{ + char *abuf; + size_t len; + + if (slen >= (size_t)INT_MAX) + return __gets(buf); + + if ((abuf = malloc(slen + 1)) == NULL) + return __gets(buf); + + if (fgets(abuf, (int)(slen + 1), stdin) == NULL) { + free(abuf); + return NULL; + } + + len = strlen(abuf); + if (len > 0 && abuf[len - 1] == '\n') + --len; + + if (len >= slen) + __chk_fail(); + + (void)memcpy(buf, abuf, len); + + buf[len] = '\0'; + free(abuf); + return buf; +} diff --git a/newlib/libc/ssp/snprintf_chk.c b/newlib/libc/ssp/snprintf_chk.c new file mode 100644 index 000000000..cede5a4bd --- /dev/null +++ b/newlib/libc/ssp/snprintf_chk.c @@ -0,0 +1,59 @@ +/* $NetBSD: snprintf_chk.c,v 1.5 2008/04/28 20:23:00 martin Exp $ */ + +/*- + * Copyright (c) 2006 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Christos Zoulas. + * + * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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 +__RCSID("$NetBSD: snprintf_chk.c,v 1.5 2008/04/28 20:23:00 martin Exp $"); + +/*LINTLIBRARY*/ + +#include +#include +#include +#include + +#undef vsnprintf + +/*ARGSUSED*/ +int +__snprintf_chk(char * __restrict buf, size_t len, int flags, size_t slen, + const char * __restrict fmt, ...) +{ + va_list ap; + int rv; + + if (len > slen) + __chk_fail(); + + va_start(ap, fmt); + rv = vsnprintf(buf, len, fmt, ap); + va_end(ap); + + return rv; +} diff --git a/newlib/libc/ssp/sprintf_chk.c b/newlib/libc/ssp/sprintf_chk.c new file mode 100644 index 000000000..1e924799b --- /dev/null +++ b/newlib/libc/ssp/sprintf_chk.c @@ -0,0 +1,63 @@ +/* $NetBSD: sprintf_chk.c,v 1.6 2009/02/05 05:40:36 lukem Exp $ */ + +/*- + * Copyright (c) 2006 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Christos Zoulas. + * + * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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 +__RCSID("$NetBSD: sprintf_chk.c,v 1.6 2009/02/05 05:40:36 lukem Exp $"); + +/*LINTLIBRARY*/ + +#include +#include +#include +#include +#include + +#undef vsnprintf +#undef vsprintf + +int +/*ARGSUSED*/ +__sprintf_chk(char * __restrict buf, int flags, size_t slen, + const char * __restrict fmt, ...) +{ + va_list ap; + int rv; + + va_start(ap, fmt); + if (slen > (size_t)INT_MAX) + rv = vsprintf(buf, fmt, ap); + else { + if ((rv = vsnprintf(buf, slen, fmt, ap)) >= 0 && (size_t)rv >= slen) + __chk_fail(); + } + va_end(ap); + + return rv; +} diff --git a/newlib/libc/ssp/vsnprintf_chk.c b/newlib/libc/ssp/vsnprintf_chk.c new file mode 100644 index 000000000..2b8802908 --- /dev/null +++ b/newlib/libc/ssp/vsnprintf_chk.c @@ -0,0 +1,51 @@ +/* $NetBSD: vsnprintf_chk.c,v 1.5 2008/04/28 20:23:00 martin Exp $ */ + +/*- + * Copyright (c) 2006 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Christos Zoulas. + * + * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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 +__RCSID("$NetBSD: vsnprintf_chk.c,v 1.5 2008/04/28 20:23:00 martin Exp $"); + +/*LINTLIBRARY*/ + +#include +#include +#include +#include + +#undef vsnprintf + +int +__vsnprintf_chk(char * __restrict buf, size_t len, int flags, size_t slen, + const char * __restrict fmt, va_list ap) +{ + if (len > slen) + __chk_fail(); + + return vsnprintf(buf, len, fmt, ap); +} diff --git a/newlib/libc/ssp/vsprintf_chk.c b/newlib/libc/ssp/vsprintf_chk.c new file mode 100644 index 000000000..fec8a18c7 --- /dev/null +++ b/newlib/libc/ssp/vsprintf_chk.c @@ -0,0 +1,60 @@ +/* $NetBSD: vsprintf_chk.c,v 1.6 2009/02/05 05:39:38 lukem Exp $ */ + +/*- + * Copyright (c) 2006 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Christos Zoulas. + * + * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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 +__RCSID("$NetBSD: vsprintf_chk.c,v 1.6 2009/02/05 05:39:38 lukem Exp $"); + +/*LINTLIBRARY*/ + +#include +#include +#include +#include +#include + +#undef vsprintf +#undef vsnprintf + +/*ARGSUSED*/ +int +__vsprintf_chk(char * __restrict buf, int flags, size_t slen, + const char * __restrict fmt, va_list ap) +{ + int rv; + + if (slen > (size_t)INT_MAX) + rv = vsprintf(buf, fmt, ap); + else { + if ((rv = vsnprintf(buf, slen, fmt, ap)) >= 0 && (size_t)rv >= slen) + __chk_fail(); + } + + return rv; +} From patchwork Wed Nov 29 00:21:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yaakov Selkowitz X-Patchwork-Id: 119910 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp2395756qgn; Tue, 28 Nov 2017 16:22:20 -0800 (PST) X-Google-Smtp-Source: AGs4zMa+9DsY3Ulyhm53sA4s403pwXkzIWKYU91ZAUzU5KpweiA62+ONDJykGDPi5blqsXMXGNkj X-Received: by 10.101.96.74 with SMTP id b10mr916319pgv.155.1511914940279; Tue, 28 Nov 2017 16:22:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511914940; cv=none; d=google.com; s=arc-20160816; b=w54OUcpTyNtAO3Smo1EqpAzTXpjKE51IrPfPVKk7yPqZPF/0miCY/N3eNTS0Jkwpip Dtzn5VcpHsyqdO4OseTXm0vxXbuYVo1xJLM8VGss6bbvI2UcwZCPzJny7P54zU/jNO+v y0TvLZlrIpPG3APq+KsgxRa3SKitobKnH9gkUjHUwQYjDj1j9NYEwBKXyFcPlNFSKwH/ QICG17P47gqk4eNotbhgZ0nX2io0FOBAGSKUY1ipLq+SoAUAEWCjmpAlPjCWmK6p4kGc +a4l088MnZIUvm/WInZ/j+SYVm5QFNhJpeaVA0vlvMIqAwjqNvI+VsH0UlvyhoK+yAt6 h4mw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:to:from:delivered-to :sender:list-help:list-post:list-archive:list-subscribe :list-unsubscribe:list-id:precedence:mailing-list:dkim-signature :domainkey-signature:arc-authentication-results; bh=58lQyXAfk2/jWmd2EWhDNF9Z3uNkvXlfL4CgygxY0OI=; b=ZP4E9rg9xnMb4oWuU1AGdy7rsLfQqFiw7NpFRrXwMxpxOeOA1wo8Q/yKPUgp9ehATt JEa76vJO4TZWWXp96lwaHyY6DWODcIyPq4JqkMXMYX4nwtj7PMbTC7TpIH5mEhRqkGH0 0A8QP3/YXr3R1LMW29XPSdZQk8+c3A6rqCpaUS3QxMmDgoswm6Lt5BNvxJABHA/05l+L H6uTMKqRw2Vy2vzg1vBDVNhuqvw89fFDhclooPlQlCeZG9MLgua9MDDpsSb0EIurPsDE SnVG8uUnMHV628cVwfLNhETPiaMGar2OmchTxgFbgZ4+y8tDaGl2x3W/9gFSyc44DRjN 61yw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=tIbuX1BX; spf=pass (google.com: domain of newlib-return-15388-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=newlib-return-15388-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id a3si309780pgc.64.2017.11.28.16.22.20 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 28 Nov 2017 16:22:20 -0800 (PST) Received-SPF: pass (google.com: domain of newlib-return-15388-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=tIbuX1BX; spf=pass (google.com: domain of newlib-return-15388-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=newlib-return-15388-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=oz1lrUgwaBB0Viow+hHzWtxM1ibVg0O 3wbOCxyNmpXZg5y2tUyf9XTcznmNE1ElZyvqj/xrXBF6iyndGQA0zkxT67XLP/TQ LJlyCq85hyfjMm3v8dbOPGoa9xwLNia3mvcGswenV6A06dV1Cw7Z7FhnmXBuZn0L npOnx0kBa9L0= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; s=default; bh=qJibNWF6GIGkr3ZD5zJN8zqRl/M=; b=tIbuX 1BXqhEHlFeBLXxfdAhfXE4hYw3D6JePneO7ME4e2SrugMJp/Tqgn0Fnpi/NCodAm BqD2iY8Vxq6fdIMquEjIlhAv1bga5+MMeEL9Ih92Z+JT2M88sznFe4b2KYeHGS3h EawET0i0RJv7btfgsgAwte7QGz/YrEkLCNOgpE= Received: (qmail 65885 invoked by alias); 29 Nov 2017 00:21:59 -0000 Mailing-List: contact newlib-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: newlib-owner@sourceware.org Delivered-To: mailing list newlib@sourceware.org Received: (qmail 65712 invoked by uid 89); 29 Nov 2017 00:21:59 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.2 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_NUMSUBJECT, KB_WAM_FROM_NAME_SINGLEWORD, SPF_HELO_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy= X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 29 Nov 2017 00:21:57 +0000 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4D0DF7F3ED for ; Wed, 29 Nov 2017 00:21:56 +0000 (UTC) Received: from localhost.localdomain (ovpn-120-11.rdu2.redhat.com [10.10.120.11]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DA53A600D1 for ; Wed, 29 Nov 2017 00:21:55 +0000 (UTC) From: Yaakov Selkowitz To: newlib@sourceware.org Subject: [PATCH v4 06/10] ssp: add Object Size Checking for unistd.h functions, part 1 Date: Tue, 28 Nov 2017 18:21:39 -0600 Message-Id: <20171129002143.12500-7-yselkowi@redhat.com> In-Reply-To: <20171129002143.12500-1-yselkowi@redhat.com> References: <20171129002143.12500-1-yselkowi@redhat.com> The implementation is from NetBSD, with the addition of feature test macros for readlink. glibc also wraps the following functions: confstr, getdomainname, getgroups, gethostname, getlogin_r, getwd, pread, readlinkat, ttyname_r. Signed-off-by: Yaakov Selkowitz --- newlib/libc/include/ssp/unistd.h | 53 ++++++++++++++++++++++++++++++++++++++++ newlib/libc/include/sys/unistd.h | 11 +++++++++ 2 files changed, 64 insertions(+) create mode 100644 newlib/libc/include/ssp/unistd.h -- 2.15.0 diff --git a/newlib/libc/include/ssp/unistd.h b/newlib/libc/include/ssp/unistd.h new file mode 100644 index 000000000..8430db644 --- /dev/null +++ b/newlib/libc/include/ssp/unistd.h @@ -0,0 +1,53 @@ +/* $NetBSD: unistd.h,v 1.7 2015/06/25 18:41:03 joerg Exp $ */ + +/*- + * Copyright (c) 2006 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Christos Zoulas. + * + * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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. + */ +#ifndef _SSP_UNISTD_H_ +#define _SSP_UNISTD_H_ + +#include + +#if __SSP_FORTIFY_LEVEL > 0 +__BEGIN_DECLS + +__ssp_redirect0(ssize_t, read, (int __fd, void *__buf, size_t __len), \ + (__fd, __buf, __len)); + +#if __BSD_VISIBLE || __POSIX_VISIBLE >= 200112 || __XSI_VISIBLE >= 4 +__ssp_redirect(ssize_t, readlink, (const char *__restrict __path, \ + char *__restrict __buf, size_t __len), (__path, __buf, __len)); +#endif + +__ssp_redirect_raw(char *, getcwd, getcwd, (char *__buf, size_t __len), + (__buf, __len), __buf != 0, __ssp_bos); + +__END_DECLS + +#endif /* __SSP_FORTIFY_LEVEL > 0 */ +#endif /* _SSP_UNISTD_H_ */ diff --git a/newlib/libc/include/sys/unistd.h b/newlib/libc/include/sys/unistd.h index 75f8a51df..bfd3b3811 100644 --- a/newlib/libc/include/sys/unistd.h +++ b/newlib/libc/include/sys/unistd.h @@ -93,7 +93,9 @@ int _EXFUN(fdatasync, (int __fd)); #if __GNU_VISIBLE char * _EXFUN(get_current_dir_name, (void)); #endif +#if !__SSP_FORTIFY_LEVEL char * _EXFUN(getcwd, (char *__buf, size_t __size )); +#endif #if __BSD_VISIBLE || (__XSI_VISIBLE && __XSI_VISIBLE < 500) int _EXFUN(getdomainname ,(char *__name, size_t __len)); #endif @@ -170,7 +172,9 @@ int _EXFUN(pipe2, (int __fildes[2], int flags)); #endif ssize_t _EXFUN(pread, (int __fd, void *__buf, size_t __nbytes, off_t __offset)); ssize_t _EXFUN(pwrite, (int __fd, const void *__buf, size_t __nbytes, off_t __offset)); +#if !__SSP_FORTIFY_LEVEL _READ_WRITE_RETURN_TYPE _EXFUN(read, (int __fd, void *__buf, size_t __nbyte )); +#endif #if __BSD_VISIBLE int _EXFUN(rresvport, (int *__alport)); int _EXFUN(revoke, (char *__path)); @@ -290,8 +294,10 @@ void _EXFUN(sync, (void)); #endif #if __BSD_VISIBLE || __POSIX_VISIBLE >= 200112 || __XSI_VISIBLE >= 4 +#if !__SSP_FORTIFY_LEVEL ssize_t _EXFUN(readlink, (const char *__restrict __path, char *__restrict __buf, size_t __buflen)); +#endif int _EXFUN(symlink, (const char *__name1, const char *__name2)); #endif #if __ATFILE_VISIBLE @@ -567,4 +573,9 @@ int _EXFUN(unlinkat, (int, const char *, int)); #ifdef __cplusplus } #endif + +#if __SSP_FORTIFY_LEVEL > 0 +#include +#endif + #endif /* _SYS_UNISTD_H */ From patchwork Wed Nov 29 00:21:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yaakov Selkowitz X-Patchwork-Id: 119911 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp2395898qgn; Tue, 28 Nov 2017 16:22:27 -0800 (PST) X-Google-Smtp-Source: AGs4zMbdcApUU1vax3Ge+tLUWRT0+faCSuK7Lg8X9ZrjOf3ip7ns2jmcdfyr22qtKoLI2rCWciH9 X-Received: by 10.98.152.147 with SMTP id d19mr973586pfk.95.1511914947738; Tue, 28 Nov 2017 16:22:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511914947; cv=none; d=google.com; s=arc-20160816; b=NkWfMIbOwFeyzME4ayhjPZVoTHH/OakZZaUlHVyZ1bawXLJMHBsVIyLe5+/cHMVXrV XF6ZSbl+W9VzfG58Dj8nMeJgvKRkJGWgx76w7qOLeXQSV4U9K2O2mkfbNFFNLQ5yN7Oi V6J1Ii1J72Ksw+pByVErY82bAeAXrV5wE8LrVeUc4MmJvnShooRRn2c5oJbf29oOAZ9P BhABm+cDxjqLyupgLRtjEH1pKPwsC51aTCX1Aut+QATAzqU0+3JaQHmbf6ZU7HJLcY3p 9gH1BvCKKX5OD540U/4gX1v0RnJTturPxJKLI1KShqdHX8ClyVIiW7rwXHpZ40/IWIyV rrng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:to:from:delivered-to :sender:list-help:list-post:list-archive:list-subscribe :list-unsubscribe:list-id:precedence:mailing-list:dkim-signature :domainkey-signature:arc-authentication-results; bh=LtnP41XGf1zbF+H8EW7Aip1JntKJpxJj3Di3UEn8Vog=; b=JkAztoFhMz9cluut0ySo10XTNe30/GIXaVL+z4cOqRTMl0rUqMuc87mrm8zLvUkVVl fxNfO2nWmvUOkD935j2N4/rMcz8caF7ylYIqeY2GR0zpFBSzPEZtfXKdLZ5Uk0GS0iNH yfkElDcCdbm/6gh5SDLUEA4PZ0A74HxiyjssVJcfkXPqjZBv4ssZ0H+F3pNan3URlgDe ic8XAlgnAiSbYUxCVjFeZUyRE3JeglRDtlJ7a7G1v6aAiGv68x5v+FRHInURsvQselBZ XNwqrRhfSRe9WhygC9/+XoegfM2frYMHNyftj7Z+iaRKzbefZVMdHcEFHIlV2+Tg2Kl+ 5BeQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=b64Zc5D4; spf=pass (google.com: domain of newlib-return-15389-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=newlib-return-15389-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id t18si295308plo.347.2017.11.28.16.22.27 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 28 Nov 2017 16:22:27 -0800 (PST) Received-SPF: pass (google.com: domain of newlib-return-15389-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=b64Zc5D4; spf=pass (google.com: domain of newlib-return-15389-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=newlib-return-15389-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=uXsbCmmo1hHz+XM0dLnlVeSRL5YP1dq zd65LMylbOVkXL7zfLHkcxzFxznjogWjRjvEV4kGndQsVmjOfiEen6tWW5V1DUVH jHmLULziMRinzr8qDoZdV+UuiH28sizWO1HN8r2ajYdiOfvZUdwSLCQIA8hfWdng GsG7O2BSBalw= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; s=default; bh=5MSVUgbxyytHbXWnBb3N8DiEXlE=; b=b64Zc 5D4lcFDOTW6/6kbTgC/JZ8M6cpDfcajAVTr07CpmWegNYPR0VNPbba27MdL7lD96 8cpgPpdwqL8qEj1FZauGVlC0Xqx5Dp1sgvdW6DouMYgoZ5XDQoy8BqJeeZ5mDhx2 mZm7REW2BXenMXKkLz3B2Hr7BPw+uQ4fSKQiDI= Received: (qmail 66016 invoked by alias); 29 Nov 2017 00:21:59 -0000 Mailing-List: contact newlib-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: newlib-owner@sourceware.org Delivered-To: mailing list newlib@sourceware.org Received: (qmail 65852 invoked by uid 89); 29 Nov 2017 00:21:59 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.7 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KB_WAM_FROM_NAME_SINGLEWORD, SPF_HELO_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy= X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 29 Nov 2017 00:21:58 +0000 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EE59F85550 for ; Wed, 29 Nov 2017 00:21:56 +0000 (UTC) Received: from localhost.localdomain (ovpn-120-11.rdu2.redhat.com [10.10.120.11]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 89442600D1 for ; Wed, 29 Nov 2017 00:21:56 +0000 (UTC) From: Yaakov Selkowitz To: newlib@sourceware.org Subject: [PATCH v4 07/10] ssp: add documentation Date: Tue, 28 Nov 2017 18:21:40 -0600 Message-Id: <20171129002143.12500-8-yselkowi@redhat.com> In-Reply-To: <20171129002143.12500-1-yselkowi@redhat.com> References: <20171129002143.12500-1-yselkowi@redhat.com> Signed-off-by: Yaakov Selkowitz --- newlib/libc/libc.in.xml | 1 + newlib/libc/libc.texinfo | 1 + newlib/libc/ssp/ssp.tex | 44 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 46 insertions(+) create mode 100644 newlib/libc/ssp/ssp.tex -- 2.15.0 diff --git a/newlib/libc/libc.in.xml b/newlib/libc/libc.in.xml index 972696189..bf5f8a05f 100644 --- a/newlib/libc/libc.in.xml +++ b/newlib/libc/libc.in.xml @@ -35,6 +35,7 @@ + diff --git a/newlib/libc/libc.texinfo b/newlib/libc/libc.texinfo index 995e95e5c..f8c820baf 100644 --- a/newlib/libc/libc.texinfo +++ b/newlib/libc/libc.texinfo @@ -171,6 +171,7 @@ into another language, under the above conditions for modified versions. @ifset ICONV * Iconv:: @end ifset +* Overflow Protection:: * Document Index:: @end menu diff --git a/newlib/libc/ssp/ssp.tex b/newlib/libc/ssp/ssp.tex new file mode 100644 index 000000000..f8440bdf9 --- /dev/null +++ b/newlib/libc/ssp/ssp.tex @@ -0,0 +1,44 @@ +@node Overflow Protection +@chapter Overflow Protection + +@menu +* Stack Smashing Protection:: Checks enabled with -fstack-protector* +* Object Size Checking:: Checks enabled with _FORTIFY_SOURCE +@end menu + +@node Stack Smashing Protection +@section Stack Smashing Protection +Stack Smashing Protection is a compiler feature which emits extra code +to check for stack smashing attacks. It depends on a canary, which is +initialized with the process, and functions for process termination when +an overflow is detected. These are private entry points intended solely +for use by the compiler, and are used when any of the @code{-fstack-protector}, +@code{-fstack-protector-all}, @code{-fstack-protector-explicit}, or +@code{-fstack-protector-strong} compiler flags are enabled. + +@node Object Size Checking +@section Object Size Checking +Object Size Checking is a feature which wraps certain functions with checks +to prevent buffer overflows. These are enabled when compiling with +optimization (@code{-O1} and higher) and @code{_FORTIFY_SOURCE} defined +to 1, or for stricter checks, to 2. + +@cindex list of overflow protected functions +The following functions use object size checking to detect buffer overflows +when enabled: + +@example +@exdent @emph{String functions:} +bcopy memmove strcpy +bzero mempcpy strcat +explicit_bzero memset strncat +memcpy stpcpy strncpy + +@exdent @emph{Stdio functions:} +fgets fread_unlocked sprintf +fgets_unlocked gets vsnprintf +fread snprintf vsprintf + +@exdent @emph{System functions:} +getcwd read readlink +@end example From patchwork Wed Nov 29 00:21:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yaakov Selkowitz X-Patchwork-Id: 119916 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp2401882qgn; Tue, 28 Nov 2017 16:29:23 -0800 (PST) X-Google-Smtp-Source: AGs4zMY3FrDBjDhqGOfj1RSuBX8B+U/bjdHyl3sD42JGFICnzIOfNdT/rZ6VadojuRefrA73WfJV X-Received: by 10.98.144.141 with SMTP id q13mr1038175pfk.140.1511915362914; Tue, 28 Nov 2017 16:29:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511915362; cv=none; d=google.com; s=arc-20160816; b=J5Mk5meTWLWxhsRhgUKo14PfY900i9AQwYHjHknYF8+ZKXypAGJgHpkHn224+qJ8bn vhHcp/03p9iBorBAFgOqS1HThDPDsw/khZBC4CIZ/lB5opZskQV/eJ1KnbxIDhX/exff uLsg4VoOC2k19wRH03+ptJBkM1tv3tNGJBg7TQIYgCahKzryzsGeo92U32cwrLJTUWmy 0f0J+c43K5CmosVb1a7YuZImP8kIjf2DWrubI5QuTXMd2TXoeZOZpW0Z4k8iP1hmAAuE xng66/cdqqakUwLjMY3mrRQ3T8vf3AKKU+0ZnDmd/FQKf/ZvPIT4NfWpvLBxU4W0rUpS 9PDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:to:from:delivered-to :sender:list-help:list-post:list-archive:list-subscribe :list-unsubscribe:list-id:precedence:mailing-list:dkim-signature :domainkey-signature:arc-authentication-results; bh=qnUySQFT5IXyEkLKZiEVgJEGiMJUhuti1Nie4EuXhf4=; b=k1dMeXt5xpZlYnT8tGaJVUTBNjMgpwJAoyN5MQsUI1tL6FvYQ55aDdj8gFuJJF8AMD VUmNOzMtksz6YUDpczDqaJLsDpFpw8S5kuMV0S7AwFOeQbzPKPnF6/yn/go4T0eN4ciZ RHZhXU3mGs9w8mRYLqFAdVd9c/PoKbJjymBekhwb0O6akHnhGlib6p4JKTIHYpuQOjTw Y3wLzzrmwokFVc3q2ETzKTfFrFivlVsaQ6ftre66XmRkcsn9+WSFd7c8fGENV+LZOHcT MKl7YiVNXENeQkPWP0KlPsrc8M//Vy5G9R/bSTH5/iq+xfB8j2+6guUczXaTRA7zI+PU GWIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=F5lxbe9D; spf=pass (google.com: domain of newlib-return-15394-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=newlib-return-15394-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id p17si305735pgc.553.2017.11.28.16.29.22 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 28 Nov 2017 16:29:22 -0800 (PST) Received-SPF: pass (google.com: domain of newlib-return-15394-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=F5lxbe9D; spf=pass (google.com: domain of newlib-return-15394-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=newlib-return-15394-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=yUmRZSExgiDVx6bvLDrw0UaE6ve0GgG FZ/vnrw8IGeXYPSh4tDWYp45wKXre95KcFSy4iwu7/AIl97oT1lqOqlO06/rPzw5 pmYGm+NSdduQ402u9K+F6nRetsY3TmcRGDbkRncWE1cnBZsoOWeZNgDDQtUugVaa kiRPrUBfQlSo= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; s=default; bh=BY7lIJ8yIi1+CBMfldiH/uVuNEY=; b=F5lxb e9D8G9ZWLmTXk6LxAFy/96+KNHFd/LBy/LpzxiSZHIO82VakTmIMBuN3t6uMS1ns GOuMNDfGxPnf7q5BCJZ2xEHdrtUoskVAEzEljcb0pqEhiRG6uXe7I8xdO7VMLWc1 U8jUPhSElSIKNEY5ou4rswSHqHD22lLk2yhiBI= Received: (qmail 9416 invoked by alias); 29 Nov 2017 00:29:11 -0000 Mailing-List: contact newlib-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: newlib-owner@sourceware.org Delivered-To: mailing list newlib@sourceware.org Received: (qmail 9249 invoked by uid 89); 29 Nov 2017 00:29:10 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.7 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, KB_WAM_FROM_NAME_SINGLEWORD, SPF_HELO_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy= X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 29 Nov 2017 00:29:00 +0000 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 87B0A7CB93 for ; Wed, 29 Nov 2017 00:21:58 +0000 (UTC) Received: from localhost.localdomain (ovpn-120-11.rdu2.redhat.com [10.10.120.11]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 35B39600D1 for ; Wed, 29 Nov 2017 00:21:57 +0000 (UTC) From: Yaakov Selkowitz To: newlib@sourceware.org Subject: [PATCH v4 08/10] ssp: add build infrastructure Date: Tue, 28 Nov 2017 18:21:41 -0600 Message-Id: <20171129002143.12500-9-yselkowi@redhat.com> In-Reply-To: <20171129002143.12500-1-yselkowi@redhat.com> References: <20171129002143.12500-1-yselkowi@redhat.com> Signed-off-by: Yaakov Selkowitz --- newlib/Makefile.am | 4 + newlib/Makefile.in | 4 + newlib/libc/Makefile.am | 4 +- newlib/libc/Makefile.in | 15 +- newlib/libc/configure | 3 +- newlib/libc/configure.in | 2 +- newlib/libc/ssp/Makefile.am | 69 +++++ newlib/libc/ssp/Makefile.in | 706 ++++++++++++++++++++++++++++++++++++++++++++ 8 files changed, 798 insertions(+), 9 deletions(-) create mode 100644 newlib/libc/ssp/Makefile.am create mode 100644 newlib/libc/ssp/Makefile.in -- 2.15.0 diff --git a/newlib/Makefile.am b/newlib/Makefile.am index effa2adba..205705d88 100644 --- a/newlib/Makefile.am +++ b/newlib/Makefile.am @@ -324,6 +324,10 @@ endif for i in $(srcdir)/libc/include/rpc/*.h; do \ $(INSTALL_DATA) $$i $(DESTDIR)$(tooldir)/include/rpc/`basename $$i`; \ done; \ + $(mkinstalldirs) $(DESTDIR)$(tooldir)/include/ssp; \ + for i in $(srcdir)/libc/include/ssp/*.h; do \ + $(INSTALL_DATA) $$i $(DESTDIR)$(tooldir)/include/ssp/`basename $$i`; \ + done; \ $(mkinstalldirs) $(DESTDIR)$(tooldir)/include/sys; \ for i in $(srcdir)/libc/include/sys/*.h; do \ $(INSTALL_DATA) $$i $(DESTDIR)$(tooldir)/include/sys/`basename $$i`; \ diff --git a/newlib/Makefile.in b/newlib/Makefile.in index 7756e7066..3b35251a7 100644 --- a/newlib/Makefile.in +++ b/newlib/Makefile.in @@ -1071,6 +1071,10 @@ install-data-local: install-toollibLIBRARIES for i in $(srcdir)/libc/include/rpc/*.h; do \ $(INSTALL_DATA) $$i $(DESTDIR)$(tooldir)/include/rpc/`basename $$i`; \ done; \ + $(mkinstalldirs) $(DESTDIR)$(tooldir)/include/ssp; \ + for i in $(srcdir)/libc/include/ssp/*.h; do \ + $(INSTALL_DATA) $$i $(DESTDIR)$(tooldir)/include/ssp/`basename $$i`; \ + done; \ $(mkinstalldirs) $(DESTDIR)$(tooldir)/include/sys; \ for i in $(srcdir)/libc/include/sys/*.h; do \ $(INSTALL_DATA) $$i $(DESTDIR)$(tooldir)/include/sys/`basename $$i`; \ diff --git a/newlib/libc/Makefile.am b/newlib/libc/Makefile.am index 6e97bca52..e27ff5cf1 100644 --- a/newlib/libc/Makefile.am +++ b/newlib/libc/Makefile.am @@ -42,7 +42,7 @@ endif # Do not change the order without considering the doc impact. SUBDIRS = argz stdlib ctype search $(STDIO_SUBDIR) $(STDIO64_SUBDIR) string $(SIGNAL_SUBDIR) time locale sys reent \ $(extra_dir) errno misc machine $(UNIX_SUBDIR) $(POSIX_SUBDIR) $(SYSCALLS_SUBDIR) $(NEWLIB_ICONV_DIRS) \ - $(XDR_SUBDIR) . + $(XDR_SUBDIR) ssp . noinst_DATA = $(CRT0) @@ -64,6 +64,7 @@ SUBLIBS = \ $(LIBC_EXTRA_LIB) \ errno/liberrno.$(aext) \ misc/libmisc.$(aext) \ + ssp/libssp.$(aext) \ $(LIBC_UNIX_LIB) \ $(LIBC_POSIX_LIB) \ $(LIBC_SYSCALL_LIB) \ @@ -87,6 +88,7 @@ SUBLIBS = \ $(LIBC_EXTRA_LIB) \ errno/lib.$(aext) \ misc/lib.$(aext) \ + ssp/lib.$(aext) \ $(LIBC_UNIX_LIB) \ $(LIBC_POSIX_LIB) \ $(LIBC_SYSCALL_LIB) \ diff --git a/newlib/libc/Makefile.in b/newlib/libc/Makefile.in index a597c1d92..c3de3f600 100644 --- a/newlib/libc/Makefile.in +++ b/newlib/libc/Makefile.in @@ -90,9 +90,10 @@ am__DEPENDENCIES_1 = @USE_LIBTOOL_FALSE@ time/lib.$(aext) locale/lib.$(aext) \ @USE_LIBTOOL_FALSE@ reent/lib.$(aext) $(am__DEPENDENCIES_1) \ @USE_LIBTOOL_FALSE@ errno/lib.$(aext) misc/lib.$(aext) \ +@USE_LIBTOOL_FALSE@ ssp/lib.$(aext) $(am__DEPENDENCIES_1) \ @USE_LIBTOOL_FALSE@ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ -@USE_LIBTOOL_FALSE@ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_2) \ -@USE_LIBTOOL_FALSE@ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) +@USE_LIBTOOL_FALSE@ $(am__DEPENDENCIES_2) $(am__DEPENDENCIES_1) \ +@USE_LIBTOOL_FALSE@ $(am__DEPENDENCIES_1) @USE_LIBTOOL_TRUE@am__DEPENDENCIES_3 = argz/libargz.$(aext) \ @USE_LIBTOOL_TRUE@ stdlib/libstdlib.$(aext) \ @USE_LIBTOOL_TRUE@ ctype/libctype.$(aext) \ @@ -104,9 +105,9 @@ am__DEPENDENCIES_1 = @USE_LIBTOOL_TRUE@ locale/liblocale.$(aext) \ @USE_LIBTOOL_TRUE@ reent/libreent.$(aext) $(am__DEPENDENCIES_1) \ @USE_LIBTOOL_TRUE@ errno/liberrno.$(aext) misc/libmisc.$(aext) \ +@USE_LIBTOOL_TRUE@ ssp/libssp.$(aext) $(am__DEPENDENCIES_1) \ @USE_LIBTOOL_TRUE@ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ -@USE_LIBTOOL_TRUE@ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ -@USE_LIBTOOL_TRUE@ $(am__DEPENDENCIES_1) +@USE_LIBTOOL_TRUE@ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) am_libc_la_OBJECTS = libc_la_OBJECTS = $(am_libc_la_OBJECTS) libc_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ @@ -191,7 +192,7 @@ ETAGS = etags CTAGS = ctags DIST_SUBDIRS = argz stdlib ctype search stdio stdio64 string signal \ time locale sys reent @extra_dir@ errno misc machine unix \ - posix syscalls iconv xdr . + posix syscalls iconv xdr ssp . ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AR = @AR@ @@ -353,7 +354,7 @@ AUTOMAKE_OPTIONS = cygnus # Do not change the order without considering the doc impact. SUBDIRS = argz stdlib ctype search $(STDIO_SUBDIR) $(STDIO64_SUBDIR) string $(SIGNAL_SUBDIR) time locale sys reent \ $(extra_dir) errno misc machine $(UNIX_SUBDIR) $(POSIX_SUBDIR) $(SYSCALLS_SUBDIR) $(NEWLIB_ICONV_DIRS) \ - $(XDR_SUBDIR) . + $(XDR_SUBDIR) ssp . noinst_DATA = $(CRT0) @USE_LIBTOOL_TRUE@noinst_LTLIBRARIES = libc.la @@ -373,6 +374,7 @@ noinst_DATA = $(CRT0) @USE_LIBTOOL_FALSE@ $(LIBC_EXTRA_LIB) \ @USE_LIBTOOL_FALSE@ errno/lib.$(aext) \ @USE_LIBTOOL_FALSE@ misc/lib.$(aext) \ +@USE_LIBTOOL_FALSE@ ssp/lib.$(aext) \ @USE_LIBTOOL_FALSE@ $(LIBC_UNIX_LIB) \ @USE_LIBTOOL_FALSE@ $(LIBC_POSIX_LIB) \ @USE_LIBTOOL_FALSE@ $(LIBC_SYSCALL_LIB) \ @@ -396,6 +398,7 @@ noinst_DATA = $(CRT0) @USE_LIBTOOL_TRUE@ $(LIBC_EXTRA_LIB) \ @USE_LIBTOOL_TRUE@ errno/liberrno.$(aext) \ @USE_LIBTOOL_TRUE@ misc/libmisc.$(aext) \ +@USE_LIBTOOL_TRUE@ ssp/libssp.$(aext) \ @USE_LIBTOOL_TRUE@ $(LIBC_UNIX_LIB) \ @USE_LIBTOOL_TRUE@ $(LIBC_POSIX_LIB) \ @USE_LIBTOOL_TRUE@ $(LIBC_SYSCALL_LIB) \ diff --git a/newlib/libc/configure b/newlib/libc/configure index dabe44fd9..240c384d3 100755 --- a/newlib/libc/configure +++ b/newlib/libc/configure @@ -12121,7 +12121,7 @@ fi -ac_config_files="$ac_config_files Makefile argz/Makefile ctype/Makefile errno/Makefile locale/Makefile misc/Makefile reent/Makefile search/Makefile stdio/Makefile stdio64/Makefile stdlib/Makefile string/Makefile time/Makefile posix/Makefile signal/Makefile syscalls/Makefile unix/Makefile iconv/Makefile iconv/ces/Makefile iconv/ccs/Makefile iconv/ccs/binary/Makefile iconv/lib/Makefile xdr/Makefile" +ac_config_files="$ac_config_files Makefile argz/Makefile ctype/Makefile errno/Makefile locale/Makefile misc/Makefile reent/Makefile search/Makefile stdio/Makefile stdio64/Makefile stdlib/Makefile string/Makefile time/Makefile posix/Makefile signal/Makefile syscalls/Makefile unix/Makefile iconv/Makefile iconv/ces/Makefile iconv/ccs/Makefile iconv/ccs/binary/Makefile iconv/lib/Makefile ssp/Makefile xdr/Makefile" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure @@ -13240,6 +13240,7 @@ do "iconv/ccs/Makefile") CONFIG_FILES="$CONFIG_FILES iconv/ccs/Makefile" ;; "iconv/ccs/binary/Makefile") CONFIG_FILES="$CONFIG_FILES iconv/ccs/binary/Makefile" ;; "iconv/lib/Makefile") CONFIG_FILES="$CONFIG_FILES iconv/lib/Makefile" ;; + "ssp/Makefile") CONFIG_FILES="$CONFIG_FILES ssp/Makefile" ;; "xdr/Makefile") CONFIG_FILES="$CONFIG_FILES xdr/Makefile" ;; *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; diff --git a/newlib/libc/configure.in b/newlib/libc/configure.in index ac25a3933..d3b10a500 100644 --- a/newlib/libc/configure.in +++ b/newlib/libc/configure.in @@ -219,5 +219,5 @@ fi AC_SUBST(LIBC_MACHINE_LIB) AC_SUBST(machine_dir) -AC_CONFIG_FILES([Makefile argz/Makefile ctype/Makefile errno/Makefile locale/Makefile misc/Makefile reent/Makefile search/Makefile stdio/Makefile stdio64/Makefile stdlib/Makefile string/Makefile time/Makefile posix/Makefile signal/Makefile syscalls/Makefile unix/Makefile iconv/Makefile iconv/ces/Makefile iconv/ccs/Makefile iconv/ccs/binary/Makefile iconv/lib/Makefile xdr/Makefile]) +AC_CONFIG_FILES([Makefile argz/Makefile ctype/Makefile errno/Makefile locale/Makefile misc/Makefile reent/Makefile search/Makefile stdio/Makefile stdio64/Makefile stdlib/Makefile string/Makefile time/Makefile posix/Makefile signal/Makefile syscalls/Makefile unix/Makefile iconv/Makefile iconv/ces/Makefile iconv/ccs/Makefile iconv/ccs/binary/Makefile iconv/lib/Makefile ssp/Makefile xdr/Makefile]) AC_OUTPUT diff --git a/newlib/libc/ssp/Makefile.am b/newlib/libc/ssp/Makefile.am new file mode 100644 index 000000000..23754baf5 --- /dev/null +++ b/newlib/libc/ssp/Makefile.am @@ -0,0 +1,69 @@ +## Process this file with automake to generate Makefile.in + +AUTOMAKE_OPTIONS = cygnus + +INCLUDES = $(NEWLIB_CFLAGS) $(CROSS_CFLAGS) $(TARGET_CFLAGS) + +GENERAL_SOURCES = \ + chk_fail.c \ + stack_protector.c + +STRING_SOURCES = \ + memcpy_chk.c \ + memmove_chk.c \ + mempcpy_chk.c \ + memset_chk.c \ + stpcpy_chk.c \ + stpncpy_chk.c \ + strcat_chk.c \ + strcpy_chk.c \ + strncat_chk.c \ + strncpy_chk.c + +STDIO_SOURCES = \ + gets_chk.c \ + snprintf_chk.c \ + sprintf_chk.c \ + vsnprintf_chk.c \ + vsprintf_chk.c + +## None of these functions are specified by EL/IX +if ELIX_LEVEL_1 +ELIX_SOURCES = +else +if ELIX_LEVEL_2 +ELIX_SOURCES = +else +if ELIX_LEVEL_3 +ELIX_SOURCES = +else +if ELIX_LEVEL_4 +ELIX_SOURCES = +else +if HAVE_STDIO_DIR +ELIX_SOURCES = $(GENERAL_SOURCES) $(STRING_SOURCES) $(STDIO_SOURCES) +else +ELIX_SOURCES = $(GENERAL_SOURCES) $(STRING_SOURCES) +endif +endif +endif +endif +endif + +libssp_la_LDFLAGS = -Xcompiler -nostdlib + +if USE_LIBTOOL +noinst_LTLIBRARIES = libssp.la +libssp_la_SOURCES = $(ELIX_SOURCES) +noinst_DATA = objectlist.awk.in +else +noinst_LIBRARIES = lib.a +lib_a_SOURCES = $(ELIX_SOURCES) +lib_a_CFLAGS = $(AM_CFLAGS) +noinst_DATA = +endif # USE_LIBTOOL + +CHEWOUT_FILES = +CHAPTERS = ssp.tex + +include $(srcdir)/../../Makefile.shared diff --git a/newlib/libc/ssp/Makefile.in b/newlib/libc/ssp/Makefile.in new file mode 100644 index 000000000..7b5ca11ff --- /dev/null +++ b/newlib/libc/ssp/Makefile.in @@ -0,0 +1,706 @@ +# Makefile.in generated by automake 1.11.6 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software +# Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + + + +VPATH = @srcdir@ +am__make_dryrun = \ + { \ + am__dry=no; \ + case $$MAKEFLAGS in \ + *\\[\ \ ]*) \ + echo 'am--echo: ; @echo "AM" OK' | $(MAKE) -f - 2>/dev/null \ + | grep '^AM OK$$' >/dev/null || am__dry=yes;; \ + *) \ + for am__flg in $$MAKEFLAGS; do \ + case $$am__flg in \ + *=*|--*) ;; \ + *n*) am__dry=yes; break;; \ + esac; \ + done;; \ + esac; \ + test $$am__dry = yes; \ + } +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +DIST_COMMON = $(srcdir)/../../Makefile.shared $(srcdir)/Makefile.in \ + $(srcdir)/Makefile.am +subdir = ssp +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/../../libtool.m4 \ + $(top_srcdir)/../../ltoptions.m4 \ + $(top_srcdir)/../../ltsugar.m4 \ + $(top_srcdir)/../../ltversion.m4 \ + $(top_srcdir)/../../lt~obsolete.m4 \ + $(top_srcdir)/../acinclude.m4 $(top_srcdir)/configure.in +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(SHELL) $(top_srcdir)/../../mkinstalldirs +CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = +LIBRARIES = $(noinst_LIBRARIES) +ARFLAGS = cru +lib_a_AR = $(AR) $(ARFLAGS) +lib_a_LIBADD = +am__objects_1 = lib_a-chk_fail.$(OBJEXT) \ + lib_a-stack_protector.$(OBJEXT) +am__objects_2 = lib_a-memcpy_chk.$(OBJEXT) lib_a-memmove_chk.$(OBJEXT) \ + lib_a-mempcpy_chk.$(OBJEXT) lib_a-memset_chk.$(OBJEXT) \ + lib_a-stpcpy_chk.$(OBJEXT) lib_a-stpncpy_chk.$(OBJEXT) \ + lib_a-strcat_chk.$(OBJEXT) lib_a-strcpy_chk.$(OBJEXT) \ + lib_a-strncat_chk.$(OBJEXT) lib_a-strncpy_chk.$(OBJEXT) +am__objects_3 = lib_a-gets_chk.$(OBJEXT) lib_a-snprintf_chk.$(OBJEXT) \ + lib_a-sprintf_chk.$(OBJEXT) lib_a-vsnprintf_chk.$(OBJEXT) \ + lib_a-vsprintf_chk.$(OBJEXT) +@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@@ELIX_LEVEL_4_FALSE@@HAVE_STDIO_DIR_FALSE@am__objects_4 = $(am__objects_1) \ +@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@@ELIX_LEVEL_4_FALSE@@HAVE_STDIO_DIR_FALSE@ $(am__objects_2) +@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@@ELIX_LEVEL_4_FALSE@@HAVE_STDIO_DIR_TRUE@am__objects_4 = $(am__objects_1) \ +@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@@ELIX_LEVEL_4_FALSE@@HAVE_STDIO_DIR_TRUE@ $(am__objects_2) \ +@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@@ELIX_LEVEL_4_FALSE@@HAVE_STDIO_DIR_TRUE@ $(am__objects_3) +@USE_LIBTOOL_FALSE@am_lib_a_OBJECTS = $(am__objects_4) +lib_a_OBJECTS = $(am_lib_a_OBJECTS) +LTLIBRARIES = $(noinst_LTLIBRARIES) +libssp_la_LIBADD = +am__objects_5 = chk_fail.lo stack_protector.lo +am__objects_6 = memcpy_chk.lo memmove_chk.lo mempcpy_chk.lo \ + memset_chk.lo stpcpy_chk.lo stpncpy_chk.lo strcat_chk.lo \ + strcpy_chk.lo strncat_chk.lo strncpy_chk.lo +am__objects_7 = gets_chk.lo snprintf_chk.lo sprintf_chk.lo \ + vsnprintf_chk.lo vsprintf_chk.lo +@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@@ELIX_LEVEL_4_FALSE@@HAVE_STDIO_DIR_FALSE@am__objects_8 = $(am__objects_5) \ +@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@@ELIX_LEVEL_4_FALSE@@HAVE_STDIO_DIR_FALSE@ $(am__objects_6) +@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@@ELIX_LEVEL_4_FALSE@@HAVE_STDIO_DIR_TRUE@am__objects_8 = $(am__objects_5) \ +@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@@ELIX_LEVEL_4_FALSE@@HAVE_STDIO_DIR_TRUE@ $(am__objects_6) \ +@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@@ELIX_LEVEL_4_FALSE@@HAVE_STDIO_DIR_TRUE@ $(am__objects_7) +@USE_LIBTOOL_TRUE@am_libssp_la_OBJECTS = $(am__objects_8) +libssp_la_OBJECTS = $(am_libssp_la_OBJECTS) +libssp_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(libssp_la_LDFLAGS) $(LDFLAGS) -o $@ +@USE_LIBTOOL_TRUE@am_libssp_la_rpath = +DEFAULT_INCLUDES = -I.@am__isrc@ +depcomp = +am__depfiles_maybe = +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ + $(LDFLAGS) -o $@ +SOURCES = $(lib_a_SOURCES) $(libssp_la_SOURCES) +am__can_run_installinfo = \ + case $$AM_UPDATE_INFO_DIR in \ + n|no|NO) false;; \ + *) (install-info --version) >/dev/null 2>&1;; \ + esac +DATA = $(noinst_DATA) +ETAGS = etags +CTAGS = ctags +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AR = @AR@ +AS = @AS@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CC = @CC@ +CCAS = @CCAS@ +CCASFLAGS = @CCASFLAGS@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CRT0 = @CRT0@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DLLTOOL = @DLLTOOL@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +FGREP = @FGREP@ +GREP = @GREP@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBC_EXTRA_DEF = @LIBC_EXTRA_DEF@ +LIBC_EXTRA_LIB = @LIBC_EXTRA_LIB@ +LIBC_MACHINE_LIB = @LIBC_MACHINE_LIB@ +LIBC_POSIX_DEF = @LIBC_POSIX_DEF@ +LIBC_POSIX_LIB = @LIBC_POSIX_LIB@ +LIBC_SIGNAL_DEF = @LIBC_SIGNAL_DEF@ +LIBC_SIGNAL_LIB = @LIBC_SIGNAL_LIB@ +LIBC_STDIO64_DEF = @LIBC_STDIO64_DEF@ +LIBC_STDIO64_LIB = @LIBC_STDIO64_LIB@ +LIBC_STDIO_DEF = @LIBC_STDIO_DEF@ +LIBC_STDIO_LIB = @LIBC_STDIO_LIB@ +LIBC_SYSCALL_LIB = @LIBC_SYSCALL_LIB@ +LIBC_SYS_LIB = @LIBC_SYS_LIB@ +LIBC_UNIX_LIB = @LIBC_UNIX_LIB@ +LIBC_XDR_DEF = @LIBC_XDR_DEF@ +LIBC_XDR_LIB = @LIBC_XDR_LIB@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MKDIR_P = @MKDIR_P@ +NEWLIB_CFLAGS = @NEWLIB_CFLAGS@ +NM = @NM@ +NMEDIT = @NMEDIT@ +NO_INCLUDE_LIST = @NO_INCLUDE_LIST@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +RANLIB = @RANLIB@ +READELF = @READELF@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +VERSION = @VERSION@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +aext = @aext@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +extra_dir = @extra_dir@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +libm_machine_dir = @libm_machine_dir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +lpfx = @lpfx@ +machine_dir = @machine_dir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +newlib_basedir = @newlib_basedir@ +oext = @oext@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +subdirs = @subdirs@ +sys_dir = @sys_dir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +AUTOMAKE_OPTIONS = cygnus +INCLUDES = $(NEWLIB_CFLAGS) $(CROSS_CFLAGS) $(TARGET_CFLAGS) +GENERAL_SOURCES = \ + chk_fail.c \ + stack_protector.c + +STRING_SOURCES = \ + memcpy_chk.c \ + memmove_chk.c \ + mempcpy_chk.c \ + memset_chk.c \ + stpcpy_chk.c \ + stpncpy_chk.c \ + strcat_chk.c \ + strcpy_chk.c \ + strncat_chk.c \ + strncpy_chk.c + +STDIO_SOURCES = \ + gets_chk.c \ + snprintf_chk.c \ + sprintf_chk.c \ + vsnprintf_chk.c \ + vsprintf_chk.c + +@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@@ELIX_LEVEL_4_FALSE@@HAVE_STDIO_DIR_FALSE@ELIX_SOURCES = $(GENERAL_SOURCES) $(STRING_SOURCES) +@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@@ELIX_LEVEL_4_FALSE@@HAVE_STDIO_DIR_TRUE@ELIX_SOURCES = $(GENERAL_SOURCES) $(STRING_SOURCES) $(STDIO_SOURCES) +@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@@ELIX_LEVEL_4_TRUE@ELIX_SOURCES = +@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_TRUE@ELIX_SOURCES = +@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_TRUE@ELIX_SOURCES = +@ELIX_LEVEL_1_TRUE@ELIX_SOURCES = +libssp_la_LDFLAGS = -Xcompiler -nostdlib +@USE_LIBTOOL_TRUE@noinst_LTLIBRARIES = libssp.la +@USE_LIBTOOL_TRUE@libssp_la_SOURCES = $(ELIX_SOURCES) +@USE_LIBTOOL_FALSE@noinst_DATA = +@USE_LIBTOOL_TRUE@noinst_DATA = objectlist.awk.in +@USE_LIBTOOL_FALSE@noinst_LIBRARIES = lib.a +@USE_LIBTOOL_FALSE@lib_a_SOURCES = $(ELIX_SOURCES) +@USE_LIBTOOL_FALSE@lib_a_CFLAGS = $(AM_CFLAGS) +CHEWOUT_FILES = +CHAPTERS = ssp.tex + +# +# documentation rules +# +SUFFIXES = .def .xml +CHEW = ${top_builddir}/../doc/makedoc -f $(top_srcdir)/../doc/doc.str +DOCBOOK_CHEW = ${top_srcdir}/../doc/makedocbook.py +DOCBOOK_OUT_FILES = $(CHEWOUT_FILES:.def=.xml) +DOCBOOK_CHAPTERS = $(CHAPTERS:.tex=.xml) +CLEANFILES = $(CHEWOUT_FILES) $(CHEWOUT_FILES:.def=.ref) $(DOCBOOK_OUT_FILES) +all: all-am + +.SUFFIXES: +.SUFFIXES: .def .xml .c .lo .o .obj +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(srcdir)/../../Makefile.shared $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --cygnus ssp/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --cygnus ssp/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; +$(srcdir)/../../Makefile.shared: + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): + +clean-noinstLIBRARIES: + -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES) +lib.a: $(lib_a_OBJECTS) $(lib_a_DEPENDENCIES) $(EXTRA_lib_a_DEPENDENCIES) + -rm -f lib.a + $(lib_a_AR) lib.a $(lib_a_OBJECTS) $(lib_a_LIBADD) + $(RANLIB) lib.a + +clean-noinstLTLIBRARIES: + -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) + @list='$(noinst_LTLIBRARIES)'; for p in $$list; do \ + dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ + test "$$dir" != "$$p" || dir=.; \ + echo "rm -f \"$${dir}/so_locations\""; \ + rm -f "$${dir}/so_locations"; \ + done +libssp.la: $(libssp_la_OBJECTS) $(libssp_la_DEPENDENCIES) $(EXTRA_libssp_la_DEPENDENCIES) + $(libssp_la_LINK) $(am_libssp_la_rpath) $(libssp_la_OBJECTS) $(libssp_la_LIBADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +.c.o: + $(COMPILE) -c $< + +.c.obj: + $(COMPILE) -c `$(CYGPATH_W) '$<'` + +.c.lo: + $(LTCOMPILE) -c -o $@ $< + +lib_a-chk_fail.o: chk_fail.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-chk_fail.o `test -f 'chk_fail.c' || echo '$(srcdir)/'`chk_fail.c + +lib_a-chk_fail.obj: chk_fail.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-chk_fail.obj `if test -f 'chk_fail.c'; then $(CYGPATH_W) 'chk_fail.c'; else $(CYGPATH_W) '$(srcdir)/chk_fail.c'; fi` + +lib_a-stack_protector.o: stack_protector.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-stack_protector.o `test -f 'stack_protector.c' || echo '$(srcdir)/'`stack_protector.c + +lib_a-stack_protector.obj: stack_protector.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-stack_protector.obj `if test -f 'stack_protector.c'; then $(CYGPATH_W) 'stack_protector.c'; else $(CYGPATH_W) '$(srcdir)/stack_protector.c'; fi` + +lib_a-memcpy_chk.o: memcpy_chk.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-memcpy_chk.o `test -f 'memcpy_chk.c' || echo '$(srcdir)/'`memcpy_chk.c + +lib_a-memcpy_chk.obj: memcpy_chk.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-memcpy_chk.obj `if test -f 'memcpy_chk.c'; then $(CYGPATH_W) 'memcpy_chk.c'; else $(CYGPATH_W) '$(srcdir)/memcpy_chk.c'; fi` + +lib_a-memmove_chk.o: memmove_chk.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-memmove_chk.o `test -f 'memmove_chk.c' || echo '$(srcdir)/'`memmove_chk.c + +lib_a-memmove_chk.obj: memmove_chk.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-memmove_chk.obj `if test -f 'memmove_chk.c'; then $(CYGPATH_W) 'memmove_chk.c'; else $(CYGPATH_W) '$(srcdir)/memmove_chk.c'; fi` + +lib_a-mempcpy_chk.o: mempcpy_chk.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-mempcpy_chk.o `test -f 'mempcpy_chk.c' || echo '$(srcdir)/'`mempcpy_chk.c + +lib_a-mempcpy_chk.obj: mempcpy_chk.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-mempcpy_chk.obj `if test -f 'mempcpy_chk.c'; then $(CYGPATH_W) 'mempcpy_chk.c'; else $(CYGPATH_W) '$(srcdir)/mempcpy_chk.c'; fi` + +lib_a-memset_chk.o: memset_chk.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-memset_chk.o `test -f 'memset_chk.c' || echo '$(srcdir)/'`memset_chk.c + +lib_a-memset_chk.obj: memset_chk.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-memset_chk.obj `if test -f 'memset_chk.c'; then $(CYGPATH_W) 'memset_chk.c'; else $(CYGPATH_W) '$(srcdir)/memset_chk.c'; fi` + +lib_a-stpcpy_chk.o: stpcpy_chk.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-stpcpy_chk.o `test -f 'stpcpy_chk.c' || echo '$(srcdir)/'`stpcpy_chk.c + +lib_a-stpcpy_chk.obj: stpcpy_chk.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-stpcpy_chk.obj `if test -f 'stpcpy_chk.c'; then $(CYGPATH_W) 'stpcpy_chk.c'; else $(CYGPATH_W) '$(srcdir)/stpcpy_chk.c'; fi` + +lib_a-stpncpy_chk.o: stpncpy_chk.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-stpncpy_chk.o `test -f 'stpncpy_chk.c' || echo '$(srcdir)/'`stpncpy_chk.c + +lib_a-stpncpy_chk.obj: stpncpy_chk.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-stpncpy_chk.obj `if test -f 'stpncpy_chk.c'; then $(CYGPATH_W) 'stpncpy_chk.c'; else $(CYGPATH_W) '$(srcdir)/stpncpy_chk.c'; fi` + +lib_a-strcat_chk.o: strcat_chk.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-strcat_chk.o `test -f 'strcat_chk.c' || echo '$(srcdir)/'`strcat_chk.c + +lib_a-strcat_chk.obj: strcat_chk.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-strcat_chk.obj `if test -f 'strcat_chk.c'; then $(CYGPATH_W) 'strcat_chk.c'; else $(CYGPATH_W) '$(srcdir)/strcat_chk.c'; fi` + +lib_a-strcpy_chk.o: strcpy_chk.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-strcpy_chk.o `test -f 'strcpy_chk.c' || echo '$(srcdir)/'`strcpy_chk.c + +lib_a-strcpy_chk.obj: strcpy_chk.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-strcpy_chk.obj `if test -f 'strcpy_chk.c'; then $(CYGPATH_W) 'strcpy_chk.c'; else $(CYGPATH_W) '$(srcdir)/strcpy_chk.c'; fi` + +lib_a-strncat_chk.o: strncat_chk.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-strncat_chk.o `test -f 'strncat_chk.c' || echo '$(srcdir)/'`strncat_chk.c + +lib_a-strncat_chk.obj: strncat_chk.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-strncat_chk.obj `if test -f 'strncat_chk.c'; then $(CYGPATH_W) 'strncat_chk.c'; else $(CYGPATH_W) '$(srcdir)/strncat_chk.c'; fi` + +lib_a-strncpy_chk.o: strncpy_chk.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-strncpy_chk.o `test -f 'strncpy_chk.c' || echo '$(srcdir)/'`strncpy_chk.c + +lib_a-strncpy_chk.obj: strncpy_chk.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-strncpy_chk.obj `if test -f 'strncpy_chk.c'; then $(CYGPATH_W) 'strncpy_chk.c'; else $(CYGPATH_W) '$(srcdir)/strncpy_chk.c'; fi` + +lib_a-gets_chk.o: gets_chk.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-gets_chk.o `test -f 'gets_chk.c' || echo '$(srcdir)/'`gets_chk.c + +lib_a-gets_chk.obj: gets_chk.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-gets_chk.obj `if test -f 'gets_chk.c'; then $(CYGPATH_W) 'gets_chk.c'; else $(CYGPATH_W) '$(srcdir)/gets_chk.c'; fi` + +lib_a-snprintf_chk.o: snprintf_chk.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-snprintf_chk.o `test -f 'snprintf_chk.c' || echo '$(srcdir)/'`snprintf_chk.c + +lib_a-snprintf_chk.obj: snprintf_chk.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-snprintf_chk.obj `if test -f 'snprintf_chk.c'; then $(CYGPATH_W) 'snprintf_chk.c'; else $(CYGPATH_W) '$(srcdir)/snprintf_chk.c'; fi` + +lib_a-sprintf_chk.o: sprintf_chk.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-sprintf_chk.o `test -f 'sprintf_chk.c' || echo '$(srcdir)/'`sprintf_chk.c + +lib_a-sprintf_chk.obj: sprintf_chk.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-sprintf_chk.obj `if test -f 'sprintf_chk.c'; then $(CYGPATH_W) 'sprintf_chk.c'; else $(CYGPATH_W) '$(srcdir)/sprintf_chk.c'; fi` + +lib_a-vsnprintf_chk.o: vsnprintf_chk.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-vsnprintf_chk.o `test -f 'vsnprintf_chk.c' || echo '$(srcdir)/'`vsnprintf_chk.c + +lib_a-vsnprintf_chk.obj: vsnprintf_chk.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-vsnprintf_chk.obj `if test -f 'vsnprintf_chk.c'; then $(CYGPATH_W) 'vsnprintf_chk.c'; else $(CYGPATH_W) '$(srcdir)/vsnprintf_chk.c'; fi` + +lib_a-vsprintf_chk.o: vsprintf_chk.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-vsprintf_chk.o `test -f 'vsprintf_chk.c' || echo '$(srcdir)/'`vsprintf_chk.c + +lib_a-vsprintf_chk.obj: vsprintf_chk.c + $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-vsprintf_chk.obj `if test -f 'vsprintf_chk.c'; then $(CYGPATH_W) 'vsprintf_chk.c'; else $(CYGPATH_W) '$(srcdir)/vsprintf_chk.c'; fi` + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + set x; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && $(am__cd) $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) "$$here" + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags +check-am: +check: check-am +all-am: Makefile $(LIBRARIES) $(LTLIBRARIES) $(DATA) +installdirs: +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + if test -z '$(STRIP)'; then \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + install; \ + else \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ + fi +mostlyclean-generic: + +clean-generic: + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libtool clean-noinstLIBRARIES \ + clean-noinstLTLIBRARIES mostlyclean-am + +distclean: distclean-am + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ + clean-libtool clean-noinstLIBRARIES clean-noinstLTLIBRARIES \ + ctags distclean distclean-compile distclean-generic \ + distclean-libtool distclean-tags dvi dvi-am html html-am info \ + info-am install install-am install-data install-data-am \ + install-dvi install-dvi-am install-exec install-exec-am \ + install-html install-html-am install-info install-info-am \ + install-man install-pdf install-pdf-am install-ps \ + install-ps-am install-strip installcheck installcheck-am \ + installdirs maintainer-clean maintainer-clean-generic \ + mostlyclean mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool pdf pdf-am ps ps-am tags uninstall \ + uninstall-am + +objectlist.awk.in: $(noinst_LTLIBRARIES) + -rm -f objectlist.awk.in + for i in `ls *.lo` ; \ + do \ + echo $$i `pwd`/$$i >> objectlist.awk.in ; \ + done + +.c.def: + $(CHEW) < $< > $*.def 2> $*.ref + touch stmp-def + +TARGETDOC ?= ../tmp.texi + +doc: $(CHEWOUT_FILES) + for chapter in $(CHAPTERS) ; \ + do \ + cat $(srcdir)/$$chapter >> $(TARGETDOC) ; \ + done + +.c.xml: + $(DOCBOOK_CHEW) < $< > $*.xml || ( rm $*.xml && false ) + @touch stmp-xml + +docbook: $(DOCBOOK_OUT_FILES) + for chapter in $(DOCBOOK_CHAPTERS) ; \ + do \ + ${top_srcdir}/../doc/chapter-texi2docbook.py <$(srcdir)/$${chapter%.xml}.tex >../$$chapter ; \ + done + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: From patchwork Wed Nov 29 00:21:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yaakov Selkowitz X-Patchwork-Id: 119917 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp2404138qgn; Tue, 28 Nov 2017 16:31:46 -0800 (PST) X-Google-Smtp-Source: AGs4zMb93ujChujds84AzRdUREmoHUvZel92I6Xs2QRHUlIvKi91Cbjw4XsRi4GvRoVJD1UtgjuL X-Received: by 10.98.78.204 with SMTP id c195mr1032553pfb.51.1511915505964; Tue, 28 Nov 2017 16:31:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511915505; cv=none; d=google.com; s=arc-20160816; b=Fs2vZkSKLaYxNEJ2eJJeo/X4zIkdcUWpgBy8zgM+h8IYMxDP0tTBCuD0k0rkepsmkx 54EBXFEtPM4ZvyLmN3CrOyx9yGJDLo/AoLhoHZDYyD+ZqXYSpP0MEgFXg/sunyHDylPM G7zvesro6RDsZBrGPrgJu1/Uz7/kKV0CHlKni9gEhIvBodDsnTIh1z6tBbkviOB6eLK/ U/XEJxu0B7M6zJfqgyvvgRGGp1cnjYXPW0Iv0OMYXWLW80Gmyezf7GkBTXfgAFE61xXv aONoEgJHrR2XFkiv2sBysDas1mZlPnrWcJxYYw35rbEHCQUUdPUiCb075Tduk/6HTQvu RPRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:to:from:delivered-to :sender:list-help:list-post:list-archive:list-subscribe :list-unsubscribe:list-id:precedence:mailing-list:dkim-signature :domainkey-signature:arc-authentication-results; bh=Q+Y8SwVcVSjzR3O5EZiVPDmFo8zOO2li+Is1KL5+SLE=; b=EtdUaWx9vWSUCIYkzSJ8LMFsDt/YUelQXFyjHOGOawXgAOZqr2NqeKVd/0CkqXew6+ s6GtTxR7HG+CVHi9FbjLkVPs+egG9g4gq8gEy/KwPSHDbu780P0QbaPNhsCtAE7AShv1 aZDldkWEqMdFeA8OayJWCm9J8v5opscVWjvRw2l6UdJbJqUWq2cL0NVWA3N11VE6gykn AjZnieX5Q4XOPz3nAIc6PxtPVt9Ysh9QkBijkQlARqQVfI7gvm7lsuiit5YExrDmkBl9 R4fDh/qptVntOS0/ADE83K4LU12edwsBVIxTIWSN+kyJlJXA30r1HsTWU/yBUlTKMsMl UMvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=fQazq+tv; spf=pass (google.com: domain of newlib-return-15395-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=newlib-return-15395-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id r3si291782plb.814.2017.11.28.16.31.45 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 28 Nov 2017 16:31:45 -0800 (PST) Received-SPF: pass (google.com: domain of newlib-return-15395-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=fQazq+tv; spf=pass (google.com: domain of newlib-return-15395-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=newlib-return-15395-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=JCFAJcX7SGhHIKa2sYBLN2KwsiCJ/1M LGahz5rY6DS0ydTQvouMZPKoykkvpB54siOR1Prr3N+oRjWtnQlBotQ06Y1xpzFh UpPD+DXo+4p3Nt1H2pSd91h/39M7Dkbb7UEj1ojilFu/vXC4VA4NPpnlT+M+Vzcg KpOQwFJr83/w= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; s=default; bh=A0EQJ0VxZRu1Jm7Zt102D1gEyN0=; b=fQazq +tvD6T0DSBCLLIsL3h5DbvzkiHG/4cyasrawrhLOsIPmTYQacGxmKj0Qovau/6Fh PZdI6ijRhijledQtYR95OP5VuN0GfjJGvFw6D2RqFS+Gb48ckFcqeGGwOGlBFOoa KvC31+2rMD6JQHxoKcOIE7+8WD3ZHjes9azsJ8= Received: (qmail 13389 invoked by alias); 29 Nov 2017 00:31:35 -0000 Mailing-List: contact newlib-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: newlib-owner@sourceware.org Delivered-To: mailing list newlib@sourceware.org Received: (qmail 13376 invoked by uid 89); 29 Nov 2017 00:31:35 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.7 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, KB_WAM_FROM_NAME_SINGLEWORD, SPF_HELO_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy= X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 29 Nov 2017 00:31:34 +0000 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 371054E906 for ; Wed, 29 Nov 2017 00:21:59 +0000 (UTC) Received: from localhost.localdomain (ovpn-120-11.rdu2.redhat.com [10.10.120.11]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C2F23600D1 for ; Wed, 29 Nov 2017 00:21:58 +0000 (UTC) From: Yaakov Selkowitz To: newlib@sourceware.org Subject: [PATCH v4 09/10] cygwin: export SSP functions Date: Tue, 28 Nov 2017 18:21:42 -0600 Message-Id: <20171129002143.12500-10-yselkowi@redhat.com> In-Reply-To: <20171129002143.12500-1-yselkowi@redhat.com> References: <20171129002143.12500-1-yselkowi@redhat.com> Signed-off-by: Yaakov Selkowitz --- winsup/cygwin/common.din | 19 +++++++++++++++++++ winsup/cygwin/include/cygwin/version.h | 7 ++++++- 2 files changed, 25 insertions(+), 1 deletion(-) -- 2.15.0 diff --git a/winsup/cygwin/common.din b/winsup/cygwin/common.din index 55fa9b16c..a482cf2b7 100644 --- a/winsup/cygwin/common.din +++ b/winsup/cygwin/common.din @@ -7,6 +7,7 @@ __cygwin_user_data DATA __mb_cur_max DATA __progname DATA __rcmd_errstr DATA +__stack_chk_guard DATA _check_for_executable DATA _ctype_ DATA _daylight DATA @@ -42,6 +43,7 @@ __assertfail NOSIGFE __b64_ntop NOSIGFE __b64_pton NOSIGFE __bsd_qsort_r NOSIGFE +__chk_fail SIGFE __cxa_atexit = cygwin__cxa_atexit SIGFE __cxa_finalize SIGFE __dn_comp SIGFE @@ -62,6 +64,7 @@ __fwritable NOSIGFE __fwriting NOSIGFE __getpagesize = getpagesize SIGFE __getreent NOSIGFE +__gets_chk SIGFE __gnu_basename NOSIGFE __infinity NOSIGFE __isinfd = isinf NOSIGFE @@ -72,7 +75,11 @@ __locale_ctype_ptr NOSIGFE __locale_ctype_ptr_l NOSIGFE __locale_mb_cur_max NOSIGFE __main NOSIGFE +__memcpy_chk NOSIGFE +__memmove_chk NOSIGFE __mempcpy = mempcpy NOSIGFE +__mempcpy_chk NOSIGFE +__memset_chk NOSIGFE __opendir_with_d_ino SIGFE __res_close SIGFE __res_init SIGFE @@ -92,10 +99,22 @@ __res_state SIGFE __signbitd NOSIGFE __signbitf NOSIGFE __signgam NOSIGFE +__snprintf_chk SIGFE +__sprintf_chk SIGFE __srget SIGFE __srget_r SIGFE +__stack_chk_fail SIGFE +__stack_chk_fail_local = __stack_chk_fail SIGFE +__stpcpy_chk NOSIGFE +__stpncpy_chk NOSIGFE +__strcat_chk NOSIGFE +__strcpy_chk NOSIGFE +__strncat_chk NOSIGFE +__strncpy_chk NOSIGFE __swbuf SIGFE __swbuf_r SIGFE +__vsnprintf_chk SIGFE +__vsprintf_chk SIGFE __wrap__ZdaPv NOSIGFE # void operator delete[](void *p) throw() __wrap__ZdaPvRKSt9nothrow_t NOSIGFE # void operator delete[](void *p, const std::nothrow_t &nt) throw() __wrap__ZdlPv NOSIGFE # void operator delete(void *p) throw() diff --git a/winsup/cygwin/include/cygwin/version.h b/winsup/cygwin/include/cygwin/version.h index 8b85f863f..d8bb3ee44 100644 --- a/winsup/cygwin/include/cygwin/version.h +++ b/winsup/cygwin/include/cygwin/version.h @@ -484,12 +484,17 @@ details. */ 317: Export renameat2. 318: Export strnstr. 319: Define O_TMPFILE, O_NOATIME. + 320: Export __chk_fail, __gets_chk, __memcpy_chk, __memmove_chk, + __mempcpy_chk, __memset_chk, __snprintf_chk, __sprintf_chk, + __stack_chk_fail, __stack_chk_guard, __stpcpy_chk, __stpncpy_chk, + __strcat_chk, __strcpy_chk, __strncat_chk, __strncpy_chk, + __vsnprintf_chk, __vsprintf_chk. Note that we forgot to bump the api for ualarm, strtoll, strtoull, sigaltstack, sethostname. */ #define CYGWIN_VERSION_API_MAJOR 0 -#define CYGWIN_VERSION_API_MINOR 319 +#define CYGWIN_VERSION_API_MINOR 320 /* There is also a compatibity version number associated with the shared memory regions. It is incremented when incompatible changes are made to the shared From patchwork Wed Nov 29 00:21:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yaakov Selkowitz X-Patchwork-Id: 119913 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp2396168qgn; Tue, 28 Nov 2017 16:22:45 -0800 (PST) X-Google-Smtp-Source: AGs4zMYnQwtAe3ZeQ/HAoLYk8Jy6N3gLVtXcVAQuGpl6pTslZpEm78k8ZpQO4irAlBWZXcCsvBY0 X-Received: by 10.84.235.200 with SMTP id m8mr1013468plt.276.1511914965820; Tue, 28 Nov 2017 16:22:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511914965; cv=none; d=google.com; s=arc-20160816; b=AG6IHPjQVfQL+EpLQojmL6gcy54xgqKYfYt6aP8DyUZ0aBWZEJ/EmSDCpvm7+99t+t URS/WfV87+bVVexwosNMSBveU+A3B/BXrOHD3tpDyY1I8Yp2ipMUV9i8YmRR20+inZqh h17uc7aVrKY7lYskNY7SlCPGWKyz3NeZJnkU9wnmb920Yl3IQnl+a9rg+pZFHYlAXS76 Xa+xPhuF6VdUojfudGWvwYtCT10Fe+bMhIozbO+GoSokraw69pYLuo/nrbzZegz0MP5D BWLeMW0sDcaqrld/1z+fcVLiLvokcbH/6+wLfNaZLQXaNyxDKiOergcNlpUA0t6fr+5M /w+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:to:from:delivered-to :sender:list-help:list-post:list-archive:list-subscribe :list-unsubscribe:list-id:precedence:mailing-list:dkim-signature :domainkey-signature:arc-authentication-results; bh=emqbR8ziuclVeGEzdzDJ4m84ElguJEJK6wQ3P5hvrH4=; b=hNt4ngTIAr9O2Hmleap0NNEfcRwHx69drV6T+C0zcCOE0K6MUnEv00i40Q88GhM4Tt 2Y6ppe603kZFPQh09b08FYmHqPkcZQCaZq0tqo7NbWzMzzG2MvhI7Y77hbpmkJOuSMgG cAxJDfA+iH3wKFLVFOySA45vE8gpBnf8qHnUaIKyYRtjEuDqaWHMMcwD6dzV2DQr0n3B hVBPskgYNYaVrUemi1w4xqYgcBEaDrpQ3wdRKVLn5WpP9flEkMBFbd1bOfRrAWaqK83g tvQMmtGrxwTc9amxSJUy9GfAaDnKOerolMIDOagdVbouPhdvJYOi5gX/+bVT2SganM6I X3QQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=j9z72jCW; spf=pass (google.com: domain of newlib-return-15391-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=newlib-return-15391-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id r76si317949pfl.194.2017.11.28.16.22.45 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 28 Nov 2017 16:22:45 -0800 (PST) Received-SPF: pass (google.com: domain of newlib-return-15391-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=j9z72jCW; spf=pass (google.com: domain of newlib-return-15391-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=newlib-return-15391-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=dKrd+QP+Nghtk3eq2Fd8NtzopLw9kIn 9HyPpFhPLAIImzrCrK/dCIknqh24zURUgOUIIhh2mxYdJ3NWAxpKQ59nI3phbBg5 wA7nEGOZarZQsaasTjMjArtRefKpWkpekf65xqNsldd3dVdZmnQ6H2wG3gfpEYgz CjcFNitYrfQg= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; s=default; bh=bf30KUN/TXpUh/otIZuDUsehSWg=; b=j9z72 jCWjW76CXQHHcBXhPuGZwLUF2lEtjSaVaeczoyQcVEqnMG24VVDR6I1rhZHj8/hg ezHL97le7a465fPWYV5tbd0JXe2k9/wTKBz4jmxcK3PsIF+SPjI/PJLzWO2/DgBW 7EFoIaOM0ggfzRlMPkvGS9W1V+LFTMQbBaDaTU= Received: (qmail 67305 invoked by alias); 29 Nov 2017 00:22:02 -0000 Mailing-List: contact newlib-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: newlib-owner@sourceware.org Delivered-To: mailing list newlib@sourceware.org Received: (qmail 67155 invoked by uid 89); 29 Nov 2017 00:22:02 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.7 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KB_WAM_FROM_NAME_SINGLEWORD, SPF_HELO_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=Hx-languages-length:1154 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 29 Nov 2017 00:22:00 +0000 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D7F764E8AC for ; Wed, 29 Nov 2017 00:21:59 +0000 (UTC) Received: from localhost.localdomain (ovpn-120-11.rdu2.redhat.com [10.10.120.11]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 71615600D1 for ; Wed, 29 Nov 2017 00:21:59 +0000 (UTC) From: Yaakov Selkowitz To: newlib@sourceware.org Subject: [PATCH v4 10/10] cygwin: create libssp compatibility import library Date: Tue, 28 Nov 2017 18:21:43 -0600 Message-Id: <20171129002143.12500-11-yselkowi@redhat.com> In-Reply-To: <20171129002143.12500-1-yselkowi@redhat.com> References: <20171129002143.12500-1-yselkowi@redhat.com> Signed-off-by: Yaakov Selkowitz --- winsup/cygwin/Makefile.in | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) -- 2.15.0 diff --git a/winsup/cygwin/Makefile.in b/winsup/cygwin/Makefile.in index a70f28dfc..c1de26c1b 100644 --- a/winsup/cygwin/Makefile.in +++ b/winsup/cygwin/Makefile.in @@ -540,7 +540,7 @@ endif API_VER:=$(srcdir)/include/cygwin/version.h LIB_NAME:=libcygwin.a -SUBLIBS:=libpthread.a libutil.a ${CURDIR}/libm.a ${CURDIR}/libc.a libdl.a libresolv.a librt.a libacl.a +SUBLIBS:=libpthread.a libutil.a ${CURDIR}/libm.a ${CURDIR}/libc.a libdl.a libresolv.a librt.a libacl.a libssp.a EXTRALIBS:=libautomode.a libbinmode.a libtextmode.a libtextreadmode.a INSTOBJS:=automode.o binmode.o textmode.o textreadmode.o TARGET_LIBS:=$(LIB_NAME) $(CYGWIN_START) $(GMON_START) $(LIBGMON_A) $(SUBLIBS) $(INSTOBJS) $(EXTRALIBS) @@ -745,6 +745,9 @@ librt.a: ${LIB_NAME} posix_ipc.o libacl.a: ${LIB_NAME} sec_posixacl.o ${speclib} ${@F} +libssp.a: ${LIB_NAME} $(newlib_build)/libc/ssp/lib.a + ${speclib} ${@F} + ${EXTRALIBS}: lib%.a: %.o $(AR) cru $@ $?