Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 19 May 2024 04:39:59 +0000 (UTC)
From:      Pedro Giffuni <pfg@freebsd.org>
To:        Kyle Evans <kevans@freebsd.org>
Cc:        "src-committers@freebsd.org" <src-committers@freebsd.org>,  "dev-commits-src-all@freebsd.org" <dev-commits-src-all@freebsd.org>,  "dev-commits-src-main@freebsd.org" <dev-commits-src-main@freebsd.org>
Subject:   Re: git: be04fec42638 - main - Import _FORTIFY_SOURCE implementation from NetBSD
Message-ID:  <1413980952.1357400.1716093599901@mail.yahoo.com>
In-Reply-To: <6276b721-6c7b-41cd-9d1b-4169e86ec5e9@FreeBSD.org>
References:  <02326b5e-a1fe-4411-a869-d21f9a76130c@email.android.com> <999469960.1638478.1716080957814@mail.yahoo.com> <6276b721-6c7b-41cd-9d1b-4169e86ec5e9@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help
------=_Part_1357399_2058372477.1716093599883
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

 FWIW .. and let me be clear I haven't worked on this in ages and I am not =
planning to retake this either...
clang just couldn't do the static=C2=A0 fortify_source checks=C2=A0 due to =
the way llvm uses an intermediate representation; the size just couldn't be=
 handled in the preprocessor. Google did spend some time adding extra attri=
butes to clang to improve the debugging and you can see that implemented in=
 bionic libc but that was it. musl didn't even try.
fortify_source does replace some key libc functions with memory checking al=
ternatives and that turns out to be annoying when debugging. In a way it br=
eaks that principle C programmers once had, where developers are expected t=
o know what they are doing, and if the error is caught at runtime by the st=
ack protector anyways it ends up being redundant.
One more thing about the static checks. Most of the linux distributions out=
 there indeed have built their software packages with GCC and fortify_sourc=
e >=3D2. As a consequence, when we ran an exp-run on the ports tree (with G=
CC), fortify_source didn't find anything: it was basically a waste of time.
Another reason for not setting it by default is performance. And here I ans=
wer Shawn's comment on why not enable stack-protector-all and safestack and=
 fortify_source at the same time: running unnecessary checks over and over =
again wastes energy and can have some performance hit. The later may seem n=
egligible in modern processors, but why do them if they bring no benefit? (=
No need to answer ... just left as food for thought)
Pedro.
    On Saturday, May 18, 2024 at 09:08:52 PM GMT-5, Kyle Evans <kevans@free=
bsd.org> wrote: =20
=20
=20

On 5/18/24 20:09, Pedro Giffuni wrote:
> (sorry for top posting .. my mailer just sucks)
> Hi;
>=20
> I used to like the limited static checking FORTIFY_SOURCE provides and=20
> when I ran it over FreeBSD it did find a couple of minor issues. It only=
=20
> works for GCC though.
>=20

I don't think this is particularly true anymore; I haven't found a case=20
yet where __builtin_object_size(3) doesn't give me the correct size=20
while GCC did.=C2=A0 I'd welcome counter-examples here, though -- we have=
=20
funding to both finish the project (widen the _FORTIFY_SOURCE net to=20
more of libc/libsys) and add tests to demonstrate that it's both=20
functional and correct.=C2=A0 It would be useful to also document=20
deficiencies in the tests.

> I guess it doesn't really hurt to have FORTIFY_SOURCE around and NetBSD=
=20
> had the least intrusive implementation the last time I checked but I=20
> would certainly request it should never be activated by default,=20
> specially with clang. The GCC version has seen more development on glibc=
=20
> but I still think its a dead end.
>=20

I don't see a compelling reason to avoid enabling it by default; see=20
above, the functionality that we need in clang appears to be just fine=20
(and, iirc, was also fine when I checked at the beginning of working on=20
this in 2021) and it provides useful

> What I would like to see working on FreeBSD is Safestack as a=20
> replacement for the stack protector, which we were so very slow to adopt=
=20
> even when it was originally developed in FreeBSD. I think other projects=
=20
> based on FreeBSD (Chimera and hardenedBSD) have been using it but I=20
> don't know the details.
>=20

No comment there, though I think Shawn Webb / HardenedBSD had been=20
playing around with SafeStack (and might have enabled it? I haven't=20
actually looked in a while now).

> This is just all my $0.02
>=20
> Pedro.

Thanks,

Kyle Evans

>=20
> On Saturday, May 18, 2024 at 05:54:42 PM GMT-5, Kyle Evans=20
> <kaevans@fastmail.com> wrote:
>=20
>=20
>=20
>=20
> On May 18, 2024 13:42, Pedro Giffuni <pfg@freebsd.org> wrote:
>=20
>=C2=A0 =C2=A0 Oh no .. please not...
>=20
>=C2=A0 =C2=A0 We went into that in a GSoC:
>=20
>=C2=A0 =C2=A0 https://wiki.freebsd.org/SummerOfCode2015/FreeBSDLibcSecurit=
yExtensions <https://wiki.freebsd.org/SummerOfCode2015/FreeBSDLibcSecurityE=
xtensions>
>=20
>=20
>=C2=A0 =C2=A0 Ultimately it proved to be useless since stack-protector-str=
ong.
>=20
>=20
> Respectfully, I disagree with your conclusion here:
>=20
> 1.) _FORTIFY_SOURCE provides more granular detection of overflow; I=20
> don't have to overflow all the way into the canary at the end of the=20
> frame to be detected, so my minor bug now can be caught before something=
=20
> causes the stack frame to be rearranged and turn it into a security=20
> issue later
>=20
> 2.) __builtin_object_size doesn't work on heap objects, but it actually=
=20
> can work on subobjects from a heap allocation (e.g., &foo->name), so the=
=20
> coverage extends beyond the stack into starting to detect other kinds of=
=20
> overflow
>=20
> While the security value over stack-protector-strong may be marginal (I=
=20
> won't debate this specifically), the feature still has value in general.
>=20
> Thanks,
>=20
> Kyle Evans
>=20
>=C2=A0 =C2=A0 The NetBSD code was not well adapted to clang either.
>=20
>=C2=A0 =C2=A0 Ask me more if you really want to dig into it, but we don't =
want this.
>=20
>=C2=A0 =C2=A0 Pedro.
>=20
>=20
>=C2=A0 =C2=A0 On Monday, May 13, 2024 at 12:24:13 AM GMT-5, Kyle Evans
>=C2=A0 =C2=A0 <kevans@freebsd.org> wrote:
>=20
>=20
>=C2=A0 =C2=A0 The branch main has been updated by kevans:
>=20
>=C2=A0 =C2=A0 URL:
>=C2=A0 =C2=A0 https://cgit.FreeBSD.org/src/commit/?id=3Dbe04fec42638f30f50=
b5b55fd8e3634c0fb89928 <https://cgit.FreeBSD.org/src/commit/?id=3Dbe04fec42=
638f30f50b5b55fd8e3634c0fb89928>
>=20
>=C2=A0 =C2=A0 commit be04fec42638f30f50b5b55fd8e3634c0fb89928
>=C2=A0 =C2=A0 Author:=C2=A0 =C2=A0 Kyle Evans <kevans@FreeBSD.org <mailto:=
kevans@FreeBSD.org>>
>=C2=A0 =C2=A0 AuthorDate: 2024-05-13 05:23:49 +0000
>=C2=A0 =C2=A0 Commit:=C2=A0 =C2=A0 Kyle Evans <kevans@FreeBSD.org <mailto:=
kevans@FreeBSD.org>>
>=C2=A0 =C2=A0 CommitDate: 2024-05-13 05:23:49 +0000
>=20
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Import _FORTIFY_SOURCE implementation f=
rom NetBSD
>=20
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 This is a mostly-unmodified copy of the=
 various *_chk
>=C2=A0 =C2=A0 implementations
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 and headers from NetBSD, without yet mo=
difying system headers
>=C2=A0 =C2=A0 to start
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 actually including them.=C2=A0 A future=
 commit will also apply the
>=C2=A0 =C2=A0 needed
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 bits to fix ssp/unistd.h.
>=20
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Reviewed by:=C2=A0 =C2=A0 imp, pauamma_=
gundo.com (both previous
>=C2=A0 =C2=A0 versions), kib
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Sponsored by:=C2=A0 Stormshield
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Sponsored by:=C2=A0 Klara, Inc.
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 Differential Revision: https://reviews.=
freebsd.org/D32306
>=C2=A0 =C2=A0 <https://reviews.freebsd.org/D32306>;
>=C2=A0 =C2=A0 ---
>=C2=A0 =C2=A0 etc/mtree/BSD.include.dist=C2=A0 =C2=A0 =C2=A0 =C2=A0 |=C2=
=A0 2 +
>=C2=A0 =C2=A0 include/Makefile=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 |=C2=A0 2 +-
>=C2=A0 =C2=A0 include/ssp/Makefile=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 |=C2=A0 6 ++
>=C2=A0 =C2=A0 include/ssp/ssp.h=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 |=C2=A0 91 ++++++++++++++++++++++++++
>=C2=A0 =C2=A0 include/ssp/stdio.h=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=
 =C2=A0 =C2=A0 |=C2=A0 93 ++++++++++++++++++++++++++
>=C2=A0 =C2=A0 include/ssp/string.h=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 | 129
>=C2=A0 =C2=A0 ++++++++++++++++++++++++++++++++++++
>=C2=A0 =C2=A0 include/ssp/strings.h=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 |=C2=A0 67 +++++++++++++++++++
>=C2=A0 =C2=A0 include/ssp/unistd.h=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 |=C2=A0 54 +++++++++++++++
>=C2=A0 =C2=A0 lib/libc/secure/Makefile.inc=C2=A0 =C2=A0 =C2=A0 |=C2=A0 11 =
++++
>=C2=A0 =C2=A0 lib/libc/secure/Symbol.map=C2=A0 =C2=A0 =C2=A0 =C2=A0 |=C2=
=A0 18 +++++
>=C2=A0 =C2=A0 lib/libc/secure/fgets_chk.c=C2=A0 =C2=A0 =C2=A0 =C2=A0 |=C2=
=A0 54 +++++++++++++++
>=C2=A0 =C2=A0 lib/libc/secure/gets_chk.c=C2=A0 =C2=A0 =C2=A0 =C2=A0 |=C2=
=A0 74 +++++++++++++++++++++
>=C2=A0 =C2=A0 lib/libc/secure/memcpy_chk.c=C2=A0 =C2=A0 =C2=A0 |=C2=A0 53 =
+++++++++++++++
>=C2=A0 =C2=A0 lib/libc/secure/memmove_chk.c=C2=A0 =C2=A0 =C2=A0 |=C2=A0 47=
 +++++++++++++
>=C2=A0 =C2=A0 lib/libc/secure/memset_chk.c=C2=A0 =C2=A0 =C2=A0 |=C2=A0 46 =
+++++++++++++
>=C2=A0 =C2=A0 lib/libc/secure/snprintf_chk.c=C2=A0 =C2=A0 |=C2=A0 56 +++++=
+++++++++++
>=C2=A0 =C2=A0 lib/libc/secure/sprintf_chk.c=C2=A0 =C2=A0 =C2=A0 |=C2=A0 61=
 +++++++++++++++++
>=C2=A0 =C2=A0 lib/libc/secure/ssp_internal.h=C2=A0 =C2=A0 |=C2=A0 37 +++++=
++++++
>=C2=A0 =C2=A0 lib/libc/secure/stpcpy_chk.c=C2=A0 =C2=A0 =C2=A0 |=C2=A0 55 =
++++++++++++++++
>=C2=A0 =C2=A0 lib/libc/secure/stpncpy_chk.c=C2=A0 =C2=A0 =C2=A0 |=C2=A0 53=
 +++++++++++++++
>=C2=A0 =C2=A0 lib/libc/secure/strcat_chk.c=C2=A0 =C2=A0 =C2=A0 |=C2=A0 60 =
+++++++++++++++++
>=C2=A0 =C2=A0 lib/libc/secure/strcpy_chk.c=C2=A0 =C2=A0 =C2=A0 |=C2=A0 54 =
+++++++++++++++
>=C2=A0 =C2=A0 lib/libc/secure/strncat_chk.c=C2=A0 =C2=A0 =C2=A0 |=C2=A0 70=
 ++++++++++++++++++++
>=C2=A0 =C2=A0 lib/libc/secure/strncpy_chk.c=C2=A0 =C2=A0 =C2=A0 |=C2=A0 53=
 +++++++++++++++
>=C2=A0 =C2=A0 lib/libc/secure/vsnprintf_chk.c=C2=A0 =C2=A0 |=C2=A0 49 ++++=
++++++++++
>=C2=A0 =C2=A0 lib/libc/secure/vsprintf_chk.c=C2=A0 =C2=A0 |=C2=A0 58 +++++=
+++++++++++
>=C2=A0 =C2=A0 lib/libssp/Makefile=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=
 =C2=A0 =C2=A0 |=C2=A0 20 +++++-
>=C2=A0 =C2=A0 lib/libssp/Symbol.map=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 |=C2=A0 12 ++--
>=C2=A0 =C2=A0 lib/libssp/Versions.def=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 |=C2=A0 5 ++
>=C2=A0 =C2=A0 lib/libssp/__builtin_object_size.3 | 110 +++++++++++++++++++=
++++++++++++
>=C2=A0 =C2=A0 lib/libssp/fortify_stubs.c=C2=A0 =C2=A0 =C2=A0 =C2=A0 | 131
>=C2=A0 =C2=A0 -------------------------------------
>=C2=A0 =C2=A0 lib/libssp/ssp.3=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 | 130
>=C2=A0 =C2=A0 ++++++++++++++++++++++++++++++++++++
>=C2=A0 =C2=A0 32 files changed, 1621 insertions(+), 140 deletions(-)
>=20
>=C2=A0 =C2=A0 diff --git a/etc/mtree/BSD.include.dist b/etc/mtree/BSD.incl=
ude.dist
>=C2=A0 =C2=A0 index a6bd5880bf61..f8c83d6dde7a 100644
>=C2=A0 =C2=A0 --- a/etc/mtree/BSD.include.dist
>=C2=A0 =C2=A0 +++ b/etc/mtree/BSD.include.dist
>=C2=A0 =C2=A0 @@ -372,6 +372,8 @@
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 mac_veriexec
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ..
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ..
>=C2=A0 =C2=A0 +=C2=A0 =C2=A0 ssp
>=C2=A0 =C2=A0 +=C2=A0 =C2=A0 ..
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 sys
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 disk
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ..
>=C2=A0 =C2=A0 diff --git a/include/Makefile b/include/Makefile
>=C2=A0 =C2=A0 index 19e6beb95203..32774419f162 100644
>=C2=A0 =C2=A0 --- a/include/Makefile
>=C2=A0 =C2=A0 +++ b/include/Makefile
>=C2=A0 =C2=A0 @@ -4,7 +4,7 @@
>=20
>=C2=A0 =C2=A0 PACKAGE=3Dclibs
>=C2=A0 =C2=A0 CLEANFILES=3D osreldate.h version
>=C2=A0 =C2=A0 -SUBDIR=3D arpa protocols rpcsvc rpc xlocale
>=C2=A0 =C2=A0 +SUBDIR=3D arpa protocols rpcsvc rpc ssp xlocale
>=C2=A0 =C2=A0 .if ${MACHINE_CPUARCH} =3D=3D "amd64"
>=C2=A0 =C2=A0 SUBDIR+=3D=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 i386
>=C2=A0 =C2=A0 INCLUDE_SUBDIRS+=3D=C2=A0=C2=A0=C2=A0 i386
>=C2=A0 =C2=A0 diff --git a/include/ssp/Makefile b/include/ssp/Makefile
>=C2=A0 =C2=A0 new file mode 100644
>=C2=A0 =C2=A0 index 000000000000..dff19f43c920
>=C2=A0 =C2=A0 --- /dev/null
>=C2=A0 =C2=A0 +++ b/include/ssp/Makefile
>=C2=A0 =C2=A0 @@ -0,0 +1,6 @@
>=C2=A0 =C2=A0 +# $FreeBSD$
>=C2=A0 =C2=A0 +
>=C2=A0 =C2=A0 +INCS=3D=C2=A0=C2=A0=C2=A0 ssp.h stdio.h string.h strings.h =
unistd.h
>=C2=A0 =C2=A0 +INCSDIR=3D=C2=A0=C2=A0=C2=A0 ${INCLUDEDIR}/ssp
>=C2=A0 =C2=A0 +
>=C2=A0 =C2=A0 +.include <bsd.prog.mk>
>=C2=A0 =C2=A0 diff --git a/include/ssp/ssp.h b/include/ssp/ssp.h
>=C2=A0 =C2=A0 new file mode 100644
>=C2=A0 =C2=A0 index 000000000000..35a9aeee02df
>=C2=A0 =C2=A0 --- /dev/null
>=C2=A0 =C2=A0 +++ b/include/ssp/ssp.h
>=C2=A0 =C2=A0 @@ -0,0 +1,91 @@
>=C2=A0 =C2=A0 +/*=C2=A0=C2=A0=C2=A0 $NetBSD: ssp.h,v 1.13 2015/09/03 20:43=
:47 plunky Exp $=C2=A0=C2=A0=C2=A0 */
>=C2=A0 =C2=A0 +
>=C2=A0 =C2=A0 +/*-
>=C2=A0 =C2=A0 + *
>=C2=A0 =C2=A0 + * SPDX-License-Identifier: BSD-2-Clause
>=C2=A0 =C2=A0 + *
>=C2=A0 =C2=A0 + * Copyright (c) 2006, 2011 The NetBSD Foundation, Inc.
>=C2=A0 =C2=A0 + * All rights reserved.
>=C2=A0 =C2=A0 + *
>=C2=A0 =C2=A0 + * This code is derived from software contributed to The Ne=
tBSD
>=C2=A0 =C2=A0 Foundation
>=C2=A0 =C2=A0 + * by Christos Zoulas.
>=C2=A0 =C2=A0 + *
>=C2=A0 =C2=A0 + * Redistribution and use in source and binary forms, with =
or without
>=C2=A0 =C2=A0 + * modification, are permitted provided that the following =
conditions
>=C2=A0 =C2=A0 + * are met:
>=C2=A0 =C2=A0 + * 1. Redistributions of source code must retain the above =
copyright
>=C2=A0 =C2=A0 + *=C2=A0 =C2=A0 notice, this list of conditions and the fol=
lowing disclaimer.
>=C2=A0 =C2=A0 + * 2. Redistributions in binary form must reproduce the abo=
ve copyright
>=C2=A0 =C2=A0 + *=C2=A0 =C2=A0 notice, this list of conditions and the fol=
lowing disclaimer
>=C2=A0 =C2=A0 in the
>=C2=A0 =C2=A0 + *=C2=A0 =C2=A0 documentation and/or other materials provid=
ed with the
>=C2=A0 =C2=A0 distribution.
>=C2=A0 =C2=A0 + *
>=C2=A0 =C2=A0 + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC.=
 AND
>=C2=A0 =C2=A0 CONTRIBUTORS
>=C2=A0 =C2=A0 + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDI=
NG, BUT
>=C2=A0 =C2=A0 NOT LIMITED
>=C2=A0 =C2=A0 + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNES=
S FOR A
>=C2=A0 =C2=A0 PARTICULAR
>=C2=A0 =C2=A0 + * PURPOSE ARE DISCLAIMED.=C2=A0 IN NO EVENT SHALL THE FOUN=
DATION OR
>=C2=A0 =C2=A0 CONTRIBUTORS
>=C2=A0 =C2=A0 + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
>=C2=A0 =C2=A0 EXEMPLARY, OR
>=C2=A0 =C2=A0 + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PR=
OCUREMENT OF
>=C2=A0 =C2=A0 + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROF=
ITS; OR
>=C2=A0 =C2=A0 BUSINESS
>=C2=A0 =C2=A0 + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABIL=
ITY,
>=C2=A0 =C2=A0 WHETHER IN
>=C2=A0 =C2=A0 + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENC=
E OR
>=C2=A0 =C2=A0 OTHERWISE)
>=C2=A0 =C2=A0 + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN=
 IF
>=C2=A0 =C2=A0 ADVISED OF THE
>=C2=A0 =C2=A0 + * POSSIBILITY OF SUCH DAMAGE.
>=C2=A0 =C2=A0 + */
>=C2=A0 =C2=A0 +#ifndef _SSP_SSP_H_
>=C2=A0 =C2=A0 +#define _SSP_SSP_H_
>=C2=A0 =C2=A0 +
>=C2=A0 =C2=A0 +#include <sys/cdefs.h>
>=C2=A0 =C2=A0 +
>=C2=A0 =C2=A0 +#if !defined(__cplusplus)
>=C2=A0 =C2=A0 +# if defined(_FORTIFY_SOURCE) && _FORTIFY_SOURCE > 0 && \
>=C2=A0 =C2=A0 +=C2=A0 =C2=A0 (__OPTIMIZE__ > 0 || defined(__clang__))
>=C2=A0 =C2=A0 +#=C2=A0 if _FORTIFY_SOURCE > 1
>=C2=A0 =C2=A0 +#=C2=A0 define __SSP_FORTIFY_LEVEL 2
>=C2=A0 =C2=A0 +#=C2=A0 else
>=C2=A0 =C2=A0 +#=C2=A0 define __SSP_FORTIFY_LEVEL 1
>=C2=A0 =C2=A0 +#=C2=A0 endif
>=C2=A0 =C2=A0 +# else
>=C2=A0 =C2=A0 +#=C2=A0 define __SSP_FORTIFY_LEVEL 0
>=C2=A0 =C2=A0 +# endif
>=C2=A0 =C2=A0 +#else
>=C2=A0 =C2=A0 +# define __SSP_FORTIFY_LEVEL 0
>=C2=A0 =C2=A0 +#endif
>=C2=A0 =C2=A0 +
>=C2=A0 =C2=A0 +#define=C2=A0=C2=A0=C2=A0 __ssp_var(type)=C2=A0=C2=A0=C2=A0=
 __CONCAT(__ssp_ ## type, __COUNTER__)
>=C2=A0 =C2=A0 +
>=C2=A0 =C2=A0 +/* __ssp_real is used by the implementation in libc */
>=C2=A0 =C2=A0 +#if __SSP_FORTIFY_LEVEL =3D=3D 0
>=C2=A0 =C2=A0 +#define __ssp_real_(fun)=C2=A0=C2=A0=C2=A0 fun
>=C2=A0 =C2=A0 +#else
>=C2=A0 =C2=A0 +#define __ssp_real_(fun)=C2=A0=C2=A0=C2=A0 __ssp_real_ ## f=
un
>=C2=A0 =C2=A0 +#endif
>=C2=A0 =C2=A0 +#define __ssp_real(fun)=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=
=A0 __ssp_real_(fun)
>=C2=A0 =C2=A0 +
>=C2=A0 =C2=A0 +#define __ssp_inline static __inline __attribute__((__alway=
s_inline__))
>=C2=A0 =C2=A0 +
>=C2=A0 =C2=A0 +#define __ssp_bos(ptr) __builtin_object_size(ptr,
>=C2=A0 =C2=A0 __SSP_FORTIFY_LEVEL > 1)
>=C2=A0 =C2=A0 +#define __ssp_bos0(ptr) __builtin_object_size(ptr, 0)
>=C2=A0 =C2=A0 +
>=C2=A0 =C2=A0 +#define __ssp_check(buf, len, bos) \
>=C2=A0 =C2=A0 +=C2=A0=C2=A0=C2=A0 if (bos(buf) !=3D (size_t)-1 && len > bo=
s(buf)) \
>=C2=A0 =C2=A0 +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 __chk_fail()
>=C2=A0 =C2=A0 +#define __ssp_redirect_raw(rtype, fun, symbol, args, call, =
cond, bos) \
>=C2=A0 =C2=A0 +rtype __ssp_real_(fun) args __RENAME(symbol); \
>=C2=A0 =C2=A0 +__ssp_inline rtype fun args __RENAME(__ssp_protected_ ## fu=
n); \
>=C2=A0 =C2=A0 +__ssp_inline rtype fun args { \
>=C2=A0 =C2=A0 +=C2=A0=C2=A0=C2=A0 if (cond) \
>=C2=A0 =C2=A0 +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 __ssp_check(__buf, __=
len, bos); \
>=C2=A0 =C2=A0 +=C2=A0=C2=A0=C2=A0 return __ssp_real_(fun) call; \
>=C2=A0 =C2=A0 +}
>=C2=A0 =C2=A0 +
>=C2=A0 =C2=A0 +#define __ssp_redirect(rtype, fun, args, call) \
>=C2=A0 =C2=A0 +=C2=A0 =C2=A0 __ssp_redirect_raw(rtype, fun, fun, args, cal=
l, 1, __ssp_bos)
>=C2=A0 =C2=A0 +#define __ssp_redirect0(rtype, fun, args, call) \
>=C2=A0 =C2=A0 +=C2=A0 =C2=A0 __ssp_redirect_raw(rtype, fun, fun, args, cal=
l, 1, __ssp_bos0)
>=C2=A0 =C2=A0 +
>=C2=A0 =C2=A0 +__BEGIN_DECLS
>=C2=A0 =C2=A0 +void __stack_chk_fail(void) __dead2;
>=C2=A0 =C2=A0 +void __chk_fail(void) __dead2;
>=C2=A0 =C2=A0 +__END_DECLS
>=C2=A0 =C2=A0 +
>=C2=A0 =C2=A0 +#endif /* _SSP_SSP_H_ */
>=C2=A0 =C2=A0 diff --git a/include/ssp/stdio.h b/include/ssp/stdio.h
>=C2=A0 =C2=A0 new file mode 100644
>=C2=A0 =C2=A0 index 000000000000..72e3236eac80
>=C2=A0 =C2=A0 --- /dev/null
>=C2=A0 =C2=A0 +++ b/include/ssp/stdio.h
>=C2=A0 =C2=A0 @@ -0,0 +1,93 @@
>=C2=A0 =C2=A0 +/*=C2=A0=C2=A0=C2=A0 $NetBSD: stdio.h,v 1.5 2011/07/17 20:5=
4:34 joerg Exp $=C2=A0=C2=A0=C2=A0 */
>=C2=A0 =C2=A0 +
>=C2=A0 =C2=A0 +/*-
>=C2=A0 =C2=A0 + *
>=C2=A0 =C2=A0 + * SPDX-License-Identifier: BSD-2-Clause
>=C2=A0 =C2=A0 + *
>=C2=A0 =C2=A0 + * Copyright (c) 2006 The NetBSD Foundation, Inc.
>=C2=A0 =C2=A0 + * All rights reserved.
>=C2=A0 =C2=A0 + *
>=C2=A0 =C2=A0 + * This code is derived from software contributed to The Ne=
tBSD
>=C2=A0 =C2=A0 Foundation
>=C2=A0 =C2=A0 + * by Christos Zoulas.
>=C2=A0 =C2=A0 + *
>=C2=A0 =C2=A0 + * Redistribution and use in source and binary forms, with =
or without
>=C2=A0 =C2=A0 + * modification, are permitted provided that the following =
conditions
>=C2=A0 =C2=A0 + * are met:
>=C2=A0 =C2=A0 + * 1. Redistributions of source code must retain the above =
copyright
>=C2=A0 =C2=A0 + *=C2=A0 =C2=A0 notice, this list of conditions and the fol=
lowing disclaimer.
>=C2=A0 =C2=A0 + * 2. Redistributions in binary form must reproduce the abo=
ve copyright
>=C2=A0 =C2=A0 + *=C2=A0 =C2=A0 notice, this list of conditions and the fol=
lowing disclaimer
>=C2=A0 =C2=A0 in the
>=C2=A0 =C2=A0 + *=C2=A0 =C2=A0 documentation and/or other materials provid=
ed with the
>=C2=A0 =C2=A0 distribution.
>=C2=A0 =C2=A0 + *
>=C2=A0 =C2=A0 + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC.=
 AND
>=C2=A0 =C2=A0 CONTRIBUTORS
>=C2=A0 =C2=A0 + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDI=
NG, BUT
>=C2=A0 =C2=A0 NOT LIMITED
>=C2=A0 =C2=A0 + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNES=
S FOR A
>=C2=A0 =C2=A0 PARTICULAR
>=C2=A0 =C2=A0 + * PURPOSE ARE DISCLAIMED.=C2=A0 IN NO EVENT SHALL THE FOUN=
DATION OR
>=C2=A0 =C2=A0 CONTRIBUTORS
>=C2=A0 =C2=A0 + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
>=C2=A0 =C2=A0 EXEMPLARY, OR
>=C2=A0 =C2=A0 + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PR=
OCUREMENT OF
>=C2=A0 =C2=A0 + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROF=
ITS; OR
>=C2=A0 =C2=A0 BUSINESS
>=C2=A0 =C2=A0 + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABIL=
ITY,
>=C2=A0 =C2=A0 WHETHER IN
>=C2=A0 =C2=A0 + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENC=
E OR
>=C2=A0 =C2=A0 OTHERWISE)
>=C2=A0 =C2=A0 + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN=
 IF
>=C2=A0 =C2=A0 ADVISED OF THE
>=C2=A0 =C2=A0 + * POSSIBILITY OF SUCH DAMAGE.
>=C2=A0 =C2=A0 + */
>=C2=A0 =C2=A0 +#ifndef _SSP_STDIO_H_
>=C2=A0 =C2=A0 +#define _SSP_STDIO_H_
>=C2=A0 =C2=A0 +
>=C2=A0 =C2=A0 +#include <ssp/ssp.h>
>=C2=A0 =C2=A0 +
>=C2=A0 =C2=A0 +__BEGIN_DECLS
>=C2=A0 =C2=A0 +int __sprintf_chk(char *__restrict, int, size_t, const char
>=C2=A0 =C2=A0 *__restrict, ...)
>=C2=A0 =C2=A0 +=C2=A0 =C2=A0 __printflike(4, 5);
>=C2=A0 =C2=A0 +int __vsprintf_chk(char *__restrict, int, size_t, const cha=
r
>=C2=A0 =C2=A0 *__restrict,
>=C2=A0 =C2=A0 +=C2=A0 =C2=A0 __va_list)
>=C2=A0 =C2=A0 +=C2=A0 =C2=A0 __printflike(4, 0);
>=C2=A0 =C2=A0 +int __snprintf_chk(char *__restrict, size_t, int, size_t,
>=C2=A0 =C2=A0 +=C2=A0 =C2=A0 const char *__restrict, ...)
>=C2=A0 =C2=A0 +=C2=A0 =C2=A0 __printflike(5, 6);
>=C2=A0 =C2=A0 +int __vsnprintf_chk(char *__restrict, size_t, int, size_t,
>=C2=A0 =C2=A0 +=C2=A0 =C2=A0 const char *__restrict, __va_list)
>=C2=A0 =C2=A0 +=C2=A0 =C2=A0 __printflike(5, 0);
>=C2=A0 =C2=A0 +char *__gets_chk(char *, size_t);
>=C2=A0 =C2=A0 +char *__fgets_chk(char *, int, size_t, FILE *);
>=C2=A0 =C2=A0 +__END_DECLS
>=C2=A0 =C2=A0 +
>=C2=A0 =C2=A0 +#if __SSP_FORTIFY_LEVEL > 0
>=C2=A0 =C2=A0 +
>=C2=A0 =C2=A0 +#define sprintf(str, ...) ({=C2=A0=C2=A0=C2=A0 \
>=C2=A0 =C2=A0 +=C2=A0 =C2=A0 char *_ssp_str =3D (str);=C2=A0=C2=A0=C2=A0 \
>=C2=A0 =C2=A0 +=C2=A0 =C2=A0 __builtin___sprintf_chk(_ssp_str, 0, __ssp_bo=
s(_ssp_str),=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 \
>=C2=A0 =C2=A0 +=C2=A0 =C2=A0 =C2=A0 =C2=A0 __VA_ARGS__); \
>=C2=A0 =C2=A0 +})
>=C2=A0 =C2=A0 +
>=C2=A0 =C2=A0 +#define vsprintf(str, fmt, ap) ({=C2=A0=C2=A0=C2=A0 \
>=C2=A0 =C2=A0 +=C2=A0 =C2=A0 char *_ssp_str =3D (str);=C2=A0=C2=A0=C2=A0 =
=C2=A0=C2=A0=C2=A0 \
>=C2=A0 =C2=A0 +=C2=A0 =C2=A0 __builtin___vsprintf_chk(_ssp_str, 0, __ssp_b=
os(_ssp_str),
>=C2=A0 =C2=A0 fmt,=C2=A0=C2=A0=C2=A0 \
>=C2=A0 =C2=A0 +=C2=A0 =C2=A0 =C2=A0 =C2=A0 ap);=C2=A0=C2=A0=C2=A0 =C2=A0=
=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 \
>=C2=A0 =C2=A0 +})
>=C2=A0 =C2=A0 +
>=C2=A0 =C2=A0 +#define snprintf(str, len, ...) ({=C2=A0=C2=A0=C2=A0 \
>=C2=A0 =C2=A0 +=C2=A0 =C2=A0 char *_ssp_str =3D (str);=C2=A0=C2=A0=C2=A0 =
=C2=A0=C2=A0=C2=A0 \
>=C2=A0 =C2=A0 +=C2=A0 =C2=A0 __builtin___snprintf_chk(_ssp_str, len, 0,
>=C2=A0 =C2=A0 __ssp_bos(_ssp_str),=C2=A0=C2=A0=C2=A0 \
>=C2=A0 =C2=A0 +=C2=A0 =C2=A0 =C2=A0 =C2=A0 __VA_ARGS__);=C2=A0=C2=A0=C2=A0=
 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 \
>=C2=A0 =C2=A0 +})
>=C2=A0 =C2=A0 +
>=C2=A0 =C2=A0 +#define vsnprintf(str, len, fmt, ap) ({=C2=A0=C2=A0=C2=A0 \
>=C2=A0 =C2=A0 +=C2=A0 =C2=A0 char *_ssp_str =3D (str);=C2=A0=C2=A0=C2=A0 =
=C2=A0=C2=A0=C2=A0 \
>=C2=A0 =C2=A0 +=C2=A0 =C2=A0 __builtin___vsnprintf_chk(_ssp_str, len, 0,
>=C2=A0 =C2=A0 __ssp_bos(_ssp_str),=C2=A0=C2=A0=C2=A0 \
>=C2=A0 =C2=A0 +=C2=A0 =C2=A0 =C2=A0 =C2=A0 fmt, ap);=C2=A0=C2=A0=C2=A0 =C2=
=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 \
>=C2=A0 =C2=A0 +})
>=C2=A0 =C2=A0 +
>=C2=A0 =C2=A0 +#define gets(str) ({=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =
=C2=A0=C2=A0=C2=A0 \
>=C2=A0 =C2=A0 +=C2=A0 char *_ssp_str =3D (str);=C2=A0=C2=A0=C2=A0 =C2=A0=
=C2=A0=C2=A0 \
>=C2=A0 =C2=A0 +=C2=A0 =C2=A0 __gets_chk(_ssp_str, __ssp_bos(_ssp_str));=C2=
=A0=C2=A0=C2=A0 \
>=C2=A0 =C2=A0 +})
>=C2=A0 =C2=A0 +
>=C2=A0 =C2=A0 +#define fgets(str, len, fp) ({=C2=A0=C2=A0=C2=A0 =C2=A0=C2=
=A0=C2=A0 \
>=C2=A0 =C2=A0 +=C2=A0 =C2=A0 char *_ssp_str =3D (str);=C2=A0=C2=A0=C2=A0 =
=C2=A0=C2=A0=C2=A0 \
>=C2=A0 =C2=A0 +=C2=A0 =C2=A0 __fgets_chk(_ssp_str, len, __ssp_bos(_ssp_str=
), fp);=C2=A0=C2=A0=C2=A0 \
>=C2=A0 =C2=A0 +})
>=C2=A0 =C2=A0 +
>=C2=A0 =C2=A0 +#endif /* __SSP_FORTIFY_LEVEL > 0 */
>=C2=A0 =C2=A0 +
>=C2=A0 =C2=A0 +#endif /* _SSP_STDIO_H_ */
>=C2=A0 =C2=A0 diff --git a/include/ssp/string.h b/include/ssp/string.h
>=C2=A0 =C2=A0 new file mode 100644
>=C2=A0 =C2=A0 index 000000000000..996020fda778
>=C2=A0 =C2=A0 --- /dev/null
>=C2=A0 =C2=A0 +++ b/include/ssp/string.h
>=C2=A0 =C2=A0 @@ -0,0 +1,129 @@
>=C2=A0 =C2=A0 +/*=C2=A0=C2=A0=C2=A0 $NetBSD: string.h,v 1.14 2020/09/05 13=
:37:59 mrg Exp $=C2=A0=C2=A0=C2=A0 */
>=C2=A0 =C2=A0 +
>=C2=A0 =C2=A0 +/*-
>=C2=A0 =C2=A0 + *
>=C2=A0 =C2=A0 + * SPDX-License-Identifier: BSD-2-Clause
>=C2=A0 =C2=A0 + *
>=C2=A0 =C2=A0 + * Copyright (c) 2006 The NetBSD Foundation, Inc.
>=C2=A0 =C2=A0 + * All rights reserved.
>=C2=A0 =C2=A0 + *
>=C2=A0 =C2=A0 + * This code is derived from software contributed to The Ne=
tBSD
>=C2=A0 =C2=A0 Foundation
>=C2=A0 =C2=A0 + * by Christos Zoulas.
>=C2=A0 =C2=A0 + *
>=C2=A0 =C2=A0 + * Redistribution and use in source and binary forms, with =
or without
>=C2=A0 =C2=A0 + * modification, are permitted provided that the following =
conditions
>=C2=A0 =C2=A0 + * are met:
>=C2=A0 =C2=A0 + * 1. Redistributions of source code must retain the above =
copyright
>=C2=A0 =C2=A0 + *=C2=A0 =C2=A0 notice, this list of conditions and the fol=
lowing disclaimer.
>=C2=A0 =C2=A0 + * 2. Redistributions in binary form must reproduce the abo=
ve copyright
>=C2=A0 =C2=A0 + *=C2=A0 =C2=A0 notice, this list of conditions and the fol=
lowing disclaimer
>=C2=A0 =C2=A0 in the
>=C2=A0 =C2=A0 + *=C2=A0 =C2=A0 documentation and/or other materials provid=
ed with the
>=C2=A0 =C2=A0 distribution.
>=C2=A0 =C2=A0 + *
>=C2=A0 =C2=A0 + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC.=
 AND
>=C2=A0 =C2=A0 CONTRIBUTORS
>=C2=A0 =C2=A0 + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDI=
NG, BUT
>=C2=A0 =C2=A0 NOT LIMITED
>=C2=A0 =C2=A0 + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNES=
S FOR A
>=C2=A0 =C2=A0 PARTICULAR
>=C2=A0 =C2=A0 + * PURPOSE ARE DISCLAIMED.=C2=A0 IN NO EVENT SHALL THE FOUN=
DATION OR
>=C2=A0 =C2=A0 CONTRIBUTORS
>=C2=A0 =C2=A0 + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
>=C2=A0 =C2=A0 EXEMPLARY, OR
>=C2=A0 =C2=A0 + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PR=
OCUREMENT OF
>=C2=A0 =C2=A0 + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROF=
ITS; OR
>=C2=A0 =C2=A0 BUSINESS
>=C2=A0 =C2=A0 + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABIL=
ITY,
>=C2=A0 =C2=A0 WHETHER IN
>=C2=A0 =C2=A0 + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENC=
E OR
>=C2=A0 =C2=A0 OTHERWISE)
>=C2=A0 =C2=A0 + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN=
 IF
>=C2=A0 =C2=A0 ADVISED OF THE
>=C2=A0 =C2=A0 + * POSSIBILITY OF SUCH DAMAGE.
>=C2=A0 =C2=A0 + */
>=C2=A0 =C2=A0 +#ifndef _SSP_STRING_H_
>=C2=A0 =C2=A0 +#define _SSP_STRING_H_
>=C2=A0 =C2=A0 +
>=C2=A0 =C2=A0 +#include <ssp/ssp.h>
>=C2=A0 =C2=A0 +
>=C2=A0 =C2=A0 +__BEGIN_DECLS
>=C2=A0 =C2=A0 +void *__memcpy_chk(void *, const void *, size_t, size_t);
>=C2=A0 =C2=A0 +void *__memmove_chk(void *, const void *, size_t, size_t);
>=C2=A0 =C2=A0 +void *__memset_chk(void *, int, size_t, size_t);
>=C2=A0 =C2=A0 +char *__stpcpy_chk(char *, const char *, size_t);
>=C2=A0 =C2=A0 +char *__stpncpy_chk(char *, const char *, size_t, size_t);
>=C2=A0 =C2=A0 +char *__strcat_chk(char *, const char *, size_t);
>=C2=A0 =C2=A0 +char *__strcpy_chk(char *, const char *, size_t);
>=C2=A0 =C2=A0 +char *__strncat_chk(char *, const char *, size_t, size_t);
>=C2=A0 =C2=A0 +char *__strncpy_chk(char *, const char *, size_t, size_t);
>=C2=A0 =C2=A0 +__END_DECLS
>=C2=A0 =C2=A0 +
>=C2=A0 =C2=A0 +#if __SSP_FORTIFY_LEVEL > 0
>=C2=A0 =C2=A0 +
>=C2=A0 =C2=A0 +#define __ssp_bos_check3_typed_var(fun, dsttype, dsrvar, ds=
t,
>=C2=A0 =C2=A0 srctype, srcvar, \
>=C2=A0 =C2=A0 +=C2=A0 =C2=A0 src, lenvar, len) ({=C2=A0=C2=A0=C2=A0 =C2=A0=
=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 \
>=C2=A0 =C2=A0 +=C2=A0 =C2=A0 srctype srcvar =3D (src);=C2=A0=C2=A0=C2=A0 =
=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 \
>=C2=A0 =C2=A0 +=C2=A0 =C2=A0 dsttype dstvar =3D (dst);=C2=A0=C2=A0=C2=A0 =
=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 \
>=C2=A0 =C2=A0 +=C2=A0 =C2=A0 size_t lenvar =3D (len);=C2=A0=C2=A0=C2=A0 =
=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 \
>=C2=A0 =C2=A0 +=C2=A0 =C2=A0 ((__ssp_bos0(dstvar) !=3D (size_t)-1) ?=C2=A0=
=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 \
>=C2=A0 =C2=A0 +=C2=A0 =C2=A0 __builtin___ ## fun ## _chk(dstvar, srcvar, l=
envar,=C2=A0=C2=A0=C2=A0 \
>=C2=A0 =C2=A0 +=C2=A0 =C2=A0 =C2=A0 =C2=A0 __ssp_bos0(dstvar)) :=C2=A0=C2=
=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 \
>=C2=A0 =C2=A0 +=C2=A0 =C2=A0 __ ## fun ## _ichk(dstvar, srcvar, lenvar));=
=C2=A0=C2=A0=C2=A0 \
>=C2=A0 =C2=A0 +})
>=C2=A0 =C2=A0 +
>=C2=A0 =C2=A0 +#define __ssp_bos_check3_typed(fun, dsttype, dst, srctype, =
src,
>=C2=A0 =C2=A0 len)=C2=A0=C2=A0=C2=A0 \
>=C2=A0 =C2=A0 +=C2=A0 =C2=A0 __ssp_bos_check3_typed_var(fun, dsttype, __ss=
p_var(dstv), dst,=C2=A0=C2=A0=C2=A0 \
>=C2=A0 =C2=A0 +=C2=A0 =C2=A0 =C2=A0 =C2=A0 srctype, __ssp_var(srcv), src, =
__ssp_var(lenv), len)
>=C2=A0 =C2=A0 +
>=C2=A0 =C2=A0 +#define __ssp_bos_check3(fun, dst, src, len)=C2=A0=C2=A0=C2=
=A0 =C2=A0=C2=A0=C2=A0 \
>=C2=A0 =C2=A0 +=C2=A0 =C2=A0 __ssp_bos_check3_typed_var(fun, void *, __ssp=
_var(dstv), dst,=C2=A0=C2=A0=C2=A0 \
>=C2=A0 =C2=A0 +=C2=A0 =C2=A0 =C2=A0 =C2=A0 const void *, __ssp_var(srcv), =
src, __ssp_var(lenv), len)
>=C2=A0 =C2=A0 +
>=C2=A0 =C2=A0 +#define __ssp_bos_check2_var(fun, dstvar, dst, srcvar, src)=
 ({=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 \
>=C2=A0 =C2=A0 +=C2=A0 =C2=A0 const void *srcvar =3D (src);=C2=A0=C2=A0=C2=
=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 \
>=C2=A0 =C2=A0 +=C2=A0 =C2=A0 void *dstvar =3D (dst);=C2=A0=C2=A0=C2=A0 =C2=
=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 \
>=C2=A0 =C2=A0 +=C2=A0 =C2=A0 ((__ssp_bos0(dstvar) !=3D (size_t)-1) ?=C2=A0=
=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 \
>=C2=A0 =C2=A0 +=C2=A0 =C2=A0 __builtin___ ## fun ## _chk(dstvar, srcvar,=
=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 \
>=C2=A0 =C2=A0 +=C2=A0 =C2=A0 =C2=A0 =C2=A0 __ssp_bos0(dstvar)) :=C2=A0=C2=
=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 \
>=C2=A0 =C2=A0 +=C2=A0 =C2=A0 __ ## fun ## _ichk(dstvar, srcvar));=C2=A0=C2=
=A0=C2=A0 =C2=A0=C2=A0=C2=A0 \
>=C2=A0 =C2=A0 +})
>=C2=A0 =C2=A0 +
>=C2=A0 =C2=A0 +#define __ssp_bos_check2(fun, dst, src)=C2=A0=C2=A0=C2=A0 =
=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 \
>=C2=A0 =C2=A0 +=C2=A0 =C2=A0 __ssp_bos_check2_var(fun, __ssp_var(dstv), ds=
t,
>=C2=A0 =C2=A0 __ssp_var(srcv), src)
>=C2=A0 =C2=A0 +
>=C2=A0 =C2=A0 +#define __ssp_bos_icheck3_restrict(fun, type1, type2) \
>=C2=A0 =C2=A0 +static __inline type1 __ ## fun ## _ichk(type1 __restrict, =
type2
>=C2=A0 =C2=A0 __restrict, size_t); \
>=C2=A0 =C2=A0 +static __inline __attribute__((__always_inline__)) type1 \
>=C2=A0 =C2=A0 +__ ## fun ## _ichk(type1 __restrict dst, type2 __restrict s=
rc,
>=C2=A0 =C2=A0 size_t len) { \
>=C2=A0 =C2=A0 +=C2=A0=C2=A0=C2=A0 return __builtin___ ## fun ## _chk(dst, =
src, len,
>=C2=A0 =C2=A0 __ssp_bos0(dst)); \
>=C2=A0 =C2=A0 +}
>=C2=A0 =C2=A0 +
>=C2=A0 =C2=A0 +#define __ssp_bos_icheck3(fun, type1, type2) \
>=C2=A0 =C2=A0 +static __inline type1 __ ## fun ## _ichk(type1, type2, size=
_t); \
>=C2=A0 =C2=A0 +static __inline __attribute__((__always_inline__)) type1 \
>=C2=A0 =C2=A0 +__ ## fun ## _ichk(type1 dst, type2 src, size_t len) { \
>=C2=A0 =C2=A0 +=C2=A0=C2=A0=C2=A0 return __builtin___ ## fun ## _chk(dst, =
src, len,
>=C2=A0 =C2=A0 __ssp_bos0(dst)); \
>=C2=A0 =C2=A0 +}
>=C2=A0 =C2=A0 +
>=C2=A0 =C2=A0 +#define __ssp_bos_icheck2_restrict(fun, type1, type2) \
>=C2=A0 =C2=A0 +static __inline type1 __ ## fun ## _ichk(type1, type2); \
>=C2=A0 =C2=A0 +static __inline __attribute__((__always_inline__)) type1 \
>=C2=A0 =C2=A0 +__ ## fun ## _ichk(type1 __restrict dst, type2 __restrict s=
rc) { \
>=C2=A0 =C2=A0 +=C2=A0=C2=A0=C2=A0 return __builtin___ ## fun ## _chk(dst, =
src, __ssp_bos0(dst)); \
>=C2=A0 =C2=A0 +}
>=C2=A0 =C2=A0 +
>=C2=A0 =C2=A0 +__BEGIN_DECLS
>=C2=A0 =C2=A0 +__ssp_bos_icheck3_restrict(memcpy, void *, const void *)
>=C2=A0 =C2=A0 +__ssp_bos_icheck3(memmove, void *, const void *)
>=C2=A0 =C2=A0 +__ssp_bos_icheck3(memset, void *, int)
>=C2=A0 =C2=A0 +__ssp_bos_icheck2_restrict(stpcpy, char *, const char *)
>=C2=A0 =C2=A0 +__ssp_bos_icheck3_restrict(stpncpy, char *, const char *)
>=C2=A0 =C2=A0 +__ssp_bos_icheck2_restrict(strcpy, char *, const char *)
>=C2=A0 =C2=A0 +__ssp_bos_icheck2_restrict(strcat, char *, const char *)
>=C2=A0 =C2=A0 +__ssp_bos_icheck3_restrict(strncpy, char *, const char *)
>=C2=A0 =C2=A0 +__ssp_bos_icheck3_restrict(strncat, char *, const char *)
>=C2=A0 =C2=A0 +__END_DECLS
>=C2=A0 =C2=A0 +
>=C2=A0 =C2=A0 +#define memcpy(dst, src, len) __ssp_bos_check3(memcpy, dst,=
 src, len)
>=C2=A0 =C2=A0 +#define memmove(dst, src, len) __ssp_bos_check3(memmove, ds=
t, src, len)
>=C2=A0 =C2=A0 +#define memset(dst, val, len) \
>=C2=A0 =C2=A0 +=C2=A0 =C2=A0 __ssp_bos_check3_typed(memset, void *, dst, i=
nt, val, len)
>=C2=A0 =C2=A0 +#define stpcpy(dst, src) __ssp_bos_check2(stpcpy, dst, src)
>=C2=A0 =C2=A0 +#define stpncpy(dst, src, len) __ssp_bos_check3(stpncpy, ds=
t, src, len)
>=C2=A0 =C2=A0 +#define strcpy(dst, src) __ssp_bos_check2(strcpy, dst, src)
>=C2=A0 =C2=A0 +#define strcat(dst, src) __ssp_bos_check2(strcat, dst, src)
>=C2=A0 =C2=A0 +#define strncpy(dst, src, len) __ssp_bos_check3(strncpy, ds=
t, src, len)
>=C2=A0 =C2=A0 +#define strncat(dst, src, len) __ssp_bos_check3(strncat, ds=
t, src, len)
>=C2=A0 =C2=A0 +
>=C2=A0 =C2=A0 +#endif /* __SSP_FORTIFY_LEVEL > 0 */
>=C2=A0 =C2=A0 +#endif /* _SSP_STRING_H_ */
>=C2=A0 =C2=A0 diff --git a/include/ssp/strings.h b/include/ssp/strings.h
>=C2=A0 =C2=A0 new file mode 100644
>=C2=A0 =C2=A0 index 000000000000..06c9c7cc0a09
>=C2=A0 =C2=A0 --- /dev/null
>=C2=A0 =C2=A0 +++ b/include/ssp/strings.h
>=C2=A0 =C2=A0 @@ -0,0 +1,67 @@
>=C2=A0 =C2=A0 +/*=C2=A0=C2=A0=C2=A0 $NetBSD: strings.h,v 1.3 2008/04/28 20=
:22:54 martin Exp $=C2=A0=C2=A0=C2=A0 */
>=C2=A0 =C2=A0 +
>=C2=A0 =C2=A0 +/*-
>=C2=A0 =C2=A0 + *
>=C2=A0 =C2=A0 + * SPDX-License-Identifier: BSD-2-Clause
>=C2=A0 =C2=A0 + *
>=C2=A0 =C2=A0 + * Copyright (c) 2007 The NetBSD Foundation, Inc.
>=C2=A0 =C2=A0 + * All rights reserved.
>=C2=A0 =C2=A0 + *
>=C2=A0 =C2=A0 + * This code is derived from software contributed to The Ne=
tBSD
>=C2=A0 =C2=A0 Foundation
>=C2=A0 =C2=A0 + * by Christos Zoulas.
>=C2=A0 =C2=A0 + *
>=C2=A0 =C2=A0 + * Redistribution and use in source and binary forms, with =
or without
>=C2=A0 =C2=A0 + * modification, are permitted provided that the following =
conditions
>=C2=A0 =C2=A0 + * are met:
>=C2=A0 =C2=A0 + * 1. Redistributions of source code must retain the above =
copyright
>=C2=A0 =C2=A0 + *=C2=A0 =C2=A0 notice, this list of conditions and the fol=
lowing disclaimer.
>=C2=A0 =C2=A0 + * 2. Redistributions in binary form must reproduce the abo=
ve copyright
>=C2=A0 =C2=A0 + *=C2=A0 =C2=A0 notice, this list of conditions and the fol=
lowing disclaimer
>=C2=A0 =C2=A0 in the
>=C2=A0 =C2=A0 + *=C2=A0 =C2=A0 documentation and/or other materials provid=
ed with the
>=C2=A0 =C2=A0 distribution.
>=C2=A0 =C2=A0 + *
>=C2=A0 =C2=A0 + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC.=
 AND
>=C2=A0 =C2=A0 CONTRIBUTORS
>=C2=A0 =C2=A0 + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDI=
NG, BUT
>=C2=A0 =C2=A0 NOT LIMITED
>=C2=A0 =C2=A0 + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNES=
S FOR A
>=C2=A0 =C2=A0 PARTICULAR
>=C2=A0 =C2=A0 + * PURPOSE ARE DISCLAIMED.=C2=A0 IN NO EVENT SHALL THE FOUN=
DATION OR
>=C2=A0 =C2=A0 CONTRIBUTORS
>=C2=A0 =C2=A0 + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
>=C2=A0 =C2=A0 EXEMPLARY, OR
>=C2=A0 =C2=A0 + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PR=
OCUREMENT OF
>=C2=A0 =C2=A0 + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROF=
ITS; OR
>=C2=A0 =C2=A0 BUSINESS
>=C2=A0 =C2=A0 + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABIL=
ITY,
>=C2=A0 =C2=A0 WHETHER IN
>=C2=A0 =C2=A0 + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENC=
E OR
>=C2=A0 =C2=A0 OTHERWISE)
>=C2=A0 =C2=A0 + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN=
 IF
>=C2=A0 =C2=A0 ADVISED OF THE
>=C2=A0 =C2=A0 + * POSSIBILITY OF SUCH DAMAGE.
>=C2=A0 =C2=A0 + */
>=C2=A0 =C2=A0 +#ifndef _SSP_STRINGS_H_
>=C2=A0 =C2=A0 +#define _SSP_STRINGS_H_
>=C2=A0 =C2=A0 +
>=C2=A0 =C2=A0 +#include <ssp/ssp.h>
>=C2=A0 =C2=A0 +#include <string.h>
>=C2=A0 =C2=A0 +
>=C2=A0 =C2=A0 +#if __SSP_FORTIFY_LEVEL > 0
>=C2=A0 =C2=A0 +
>=C2=A0 =C2=A0 +#define _ssp_bcopy(srcvar, src, dstvar, dst, lenvar,=C2=A0 =
len) ({=C2=A0=C2=A0=C2=A0 \
>=C2=A0 =C2=A0 +=C2=A0 =C2=A0 const void *srcvar =3D (src);=C2=A0=C2=A0=C2=
=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 \
>=C2=A0 =C2=A0 +=C2=A0 =C2=A0 void *dstvar =3D (dst);=C2=A0=C2=A0=C2=A0 =C2=
=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 \
>=C2=A0 =C2=A0 +=C2=A0 =C2=A0 size_t lenvar =3D (len);=C2=A0=C2=A0=C2=A0 =
=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 \
>=C2=A0 =C2=A0 +=C2=A0 =C2=A0 ((__ssp_bos0(dstvar) !=3D (size_t)-1) ?=C2=A0=
=C2=A0=C2=A0 \
>=C2=A0 =C2=A0 +=C2=A0 =C2=A0 __builtin___memmove_chk(dstvar, srcvar, lenva=
r,=C2=A0=C2=A0=C2=A0 \
>=C2=A0 =C2=A0 +=C2=A0 =C2=A0 =C2=A0 =C2=A0 __ssp_bos0(dstvar)) :=C2=A0=C2=
=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 \
>=C2=A0 =C2=A0 +=C2=A0 =C2=A0 __memmove_ichk(dstvar, srcvar, lenvar));=C2=
=A0=C2=A0=C2=A0 \
>=C2=A0 =C2=A0 +})
>=C2=A0 =C2=A0 +
>=C2=A0 =C2=A0 +#define=C2=A0=C2=A0=C2=A0 bcopy(src, dst, len)=C2=A0=C2=A0=
=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 \
>=C2=A0 =C2=A0 +=C2=A0 =C2=A0 _ssp_bcopy(__ssp_var(srcv), src, __ssp_var(ds=
tv), dst,
>=C2=A0 =C2=A0 __ssp_var(lenv), len)
>=C2=A0 =C2=A0 +
>=C2=A0 =C2=A0 +#define _ssp_bzero(dstvar, dst, lenvar, len) ({=C2=A0=C2=A0=
=C2=A0 =C2=A0=C2=A0=C2=A0 \
>=C2=A0 =C2=A0 +=C2=A0 =C2=A0 void *dstvar =3D (dst);=C2=A0=C2=A0=C2=A0 =C2=
=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 \
>=C2=A0 =C2=A0 +=C2=A0 =C2=A0 size_t lenvar =3D (len);=C2=A0=C2=A0=C2=A0 =
=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 \
>=C2=A0 =C2=A0 +=C2=A0 =C2=A0 ((__ssp_bos0(dstvar) !=3D (size_t)-1) ?=C2=A0=
=C2=A0=C2=A0 \
>=C2=A0 =C2=A0 +=C2=A0 =C2=A0 __builtin___memset_chk(dstvar, 0, lenvar,=C2=
=A0=C2=A0=C2=A0 \
>=C2=A0 =C2=A0 +=C2=A0 =C2=A0 =C2=A0 =C2=A0 __ssp_bos0(dstvar)) : \
>=C2=A0 =C2=A0 +=C2=A0 =C2=A0 __memset_ichk(dstvar, 0, lenvar));=C2=A0=C2=
=A0=C2=A0 =C2=A0=C2=A0=C2=A0 \
>=C2=A0 =C2=A0 +})
>=C2=A0 =C2=A0 +
>=C2=A0 =C2=A0 +#define=C2=A0=C2=A0=C2=A0 bzero(dst, len)=C2=A0=C2=A0=C2=A0=
 _ssp_bzero(__ssp_var(dstv), dst,
>=C2=A0 =C2=A0 __ssp_var(lenv), len)
>=C2=A0 =C2=A0 +
>=C2=A0 =C2=A0 +#endif /* __SSP_FORTIFY_LEVEL > 0 */
>=C2=A0 =C2=A0 +#endif /* _SSP_STRINGS_H_ */
>=C2=A0 =C2=A0 diff --git a/include/ssp/unistd.h b/include/ssp/unistd.h
>=C2=A0 =C2=A0 new file mode 100644
>=C2=A0 =C2=A0 index 000000000000..2414e2baa96b
>=C2=A0 =C2=A0 --- /dev/null
>=C2=A0 =C2=A0 +++ b/include/ssp/unistd.h
>=C2=A0 =C2=A0 @@ -0,0 +1,54 @@
>=C2=A0 =C2=A0 +/*=C2=A0=C2=A0=C2=A0 $NetBSD: unistd.h,v 1.7 2015/06/25 18:=
41:03 joerg Exp $=C2=A0=C2=A0=C2=A0 */
>=C2=A0 =C2=A0 +
>=C2=A0 =C2=A0 +/*-
>=C2=A0 =C2=A0 + *
>=C2=A0 =C2=A0 + * SPDX-License-Identifier: BSD-2-Clause
>=C2=A0 =C2=A0 + *
>=C2=A0 =C2=A0 + * Copyright (c) 2006 The NetBSD Foundation, Inc.
>=C2=A0 =C2=A0 + * All rights reserved.
>=C2=A0 =C2=A0 + *
>=C2=A0 =C2=A0 + * This code is derived from software contributed to The Ne=
tBSD
>=C2=A0 =C2=A0 Foundation
>=C2=A0 =C2=A0 + * by Christos Zoulas.
>=C2=A0 =C2=A0 + *
>=C2=A0 =C2=A0 + * Redistribution and use in source and binary forms, with =
or without
>=C2=A0 =C2=A0 + * modification, are permitted provided that the following =
conditions
>=C2=A0 =C2=A0 + * are met:
>=C2=A0 =C2=A0 + * 1. Redistributions of source code must retain the above =
copyright
>=C2=A0 =C2=A0 + *=C2=A0 =C2=A0 notice, this list of conditions and the fol=
lowing disclaimer.
>=C2=A0 =C2=A0 + * 2. Redistributions in binary form must reproduce the abo=
ve copyright
>=C2=A0 =C2=A0 + *=C2=A0 =C2=A0 notice, this list of conditions and the fol=
lowing disclaimer
>=C2=A0 =C2=A0 in the
>=C2=A0 =C2=A0 + *=C2=A0 =C2=A0 documentation and/or other materials provid=
ed with the
>=C2=A0 =C2=A0 distribution.
>=C2=A0 =C2=A0 + *
>=C2=A0 =C2=A0 + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC.=
 AND
>=C2=A0 =C2=A0 CONTRIBUTORS
>=C2=A0 =C2=A0 + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDI=
NG, BUT
>=C2=A0 =C2=A0 NOT LIMITED
>=C2=A0 =C2=A0 + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNES=
S FOR A
>=C2=A0 =C2=A0 PARTICULAR
>=C2=A0 =C2=A0 + * PURPOSE ARE DISCLAIMED.=C2=A0 IN NO EVENT SHALL THE FOUN=
DATION OR
>=C2=A0 =C2=A0 CONTRIBUTORS
>=C2=A0 =C2=A0 + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
>=C2=A0 =C2=A0 EXEMPLARY, OR
>=C2=A0 =C2=A0 + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PR=
OCUREMENT OF
>=C2=A0 =C2=A0 + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROF=
ITS; OR
>=C2=A0 =C2=A0 BUSINESS
>=C2=A0 =C2=A0 + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABIL=
ITY,
>=C2=A0 =C2=A0 WHETHER IN
>=C2=A0 =C2=A0 + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENC=
E OR
>=C2=A0 =C2=A0 OTHERWISE)
>=C2=A0 =C2=A0 + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN=
 IF
>=C2=A0 =C2=A0 ADVISED OF THE
>=C2=A0 =C2=A0 + * POSSIBILITY OF SUCH DAMAGE.
>=C2=A0 =C2=A0 + */
>=C2=A0 =C2=A0 +#ifndef _SSP_UNISTD_H_
>=C2=A0 =C2=A0 +#define _SSP_UNISTD_H_
>=C2=A0 =C2=A0 +
>=C2=A0 =C2=A0 +#include <ssp/ssp.h>
>=C2=A0 =C2=A0 +
>=C2=A0 =C2=A0 +#if __SSP_FORTIFY_LEVEL > 0
>=C2=A0 =C2=A0 +__BEGIN_DECLS
>=C2=A0 =C2=A0 +
>=C2=A0 =C2=A0 +__ssp_redirect0(ssize_t, read, (int __fd, void *__buf, size=
_t __len), \
>=C2=A0 =C2=A0 +=C2=A0 =C2=A0 (__fd, __buf, __len));
>=C2=A0 =C2=A0 +
>=C2=A0 =C2=A0 +__ssp_redirect(ssize_t, readlink, (const char *__restrict _=
_path, \
>=C2=A0 =C2=A0 +=C2=A0 =C2=A0 char *__restrict __buf, size_t __len), (__pat=
h, __buf, __len));
>=C2=A0 =C2=A0 +
>=C2=A0 =C2=A0 +__ssp_redirect_raw(char *, getcwd, getcwd, (char *__buf, si=
ze_t __len),
>=C2=A0 =C2=A0 +=C2=A0 =C2=A0 (__buf, __len), __buf !=3D 0, __ssp_bos);
>=C2=A0 =C2=A0 +
>=C2=A0 =C2=A0 +__END_DECLS
>=C2=A0 =C2=A0 +
>=C2=A0 =C2=A0 +#endif /* __SSP_FORTIFY_LEVEL > 0 */
>=C2=A0 =C2=A0 +#endif /* _SSP_UNISTD_H_ */
>=C2=A0 =C2=A0 diff --git a/lib/libc/secure/Makefile.inc b/lib/libc/secure/=
Makefile.inc
>=C2=A0 =C2=A0 index 8574c5a05dc5..3b1ad879c715 100644
>=C2=A0 =C2=A0 --- a/lib/libc/secure/Makefile.inc
>=C2=A0 =C2=A0 +++ b/lib/libc/secure/Makefile.inc
>=C2=A0 =C2=A0 @@ -3,6 +3,17 @@
>=20
>=C2=A0 =C2=A0 .PATH: ${LIBC_SRCTOP}/secure
>=20
>=C2=A0 =C2=A0 +# _FORTIFY_SOURCE
>=C2=A0 =C2=A0 +SRCS+=3D=C2=A0=C2=A0=C2=A0 gets_chk.c fgets_chk.c memcpy_ch=
k.c memmove_chk.c
>=C2=A0 =C2=A0 memset_chk.c \
>=C2=A0 =C2=A0 +=C2=A0=C2=A0=C2=A0 snprintf_chk.c sprintf_chk.c stpcpy_chk.=
c stpncpy_chk.c \
>=C2=A0 =C2=A0 +=C2=A0=C2=A0=C2=A0 strcat_chk.c strcpy_chk.c strncat_chk.c =
strncpy_chk.c \
>=C2=A0 =C2=A0 +=C2=A0=C2=A0=C2=A0 vsnprintf_chk.c vsprintf_chk.c
>=C2=A0 =C2=A0 +
>=C2=A0 =C2=A0 +CFLAGS.snprintf_chk.c+=3D=C2=A0=C2=A0=C2=A0 -Wno-unused-par=
ameter
>=C2=A0 =C2=A0 +CFLAGS.sprintf_chk.c+=3D=C2=A0=C2=A0=C2=A0 -Wno-unused-para=
meter
>=C2=A0 =C2=A0 +CFLAGS.vsnprintf_chk.c+=3D=C2=A0=C2=A0=C2=A0 -Wno-unused-pa=
rameter
>=C2=A0 =C2=A0 +CFLAGS.vsprintf_chk.c+=3D=C2=A0=C2=A0=C2=A0 -Wno-unused-par=
ameter
>=C2=A0 =C2=A0 +
>=C2=A0 =C2=A0 # Sources common to both syscall interfaces:
>=C2=A0 =C2=A0 SRCS+=3D=C2=A0=C2=A0=C2=A0 stack_protector.c \
>=C2=A0 =C2=A0 =C2=A0 =C2=A0=C2=A0=C2=A0 stack_protector_compat.c
>=C2=A0 =C2=A0 diff --git a/lib/libc/secure/Symbol.map b/lib/libc/secure/Sy=
mbol.map
>=C2=A0 =C2=A0 index 641f451b5421..7859fcee3821 100644
>=C2=A0 =C2=A0 --- a/lib/libc/secure/Symbol.map
>=C2=A0 =C2=A0 +++ b/lib/libc/secure/Symbol.map
>=C2=A0 =C2=A0 @@ -3,3 +3,21 @@ FBSD_1.0 {
>=C2=A0 =C2=A0 =C2=A0 =C2=A0=C2=A0=C2=A0 __stack_chk_fail;
>=C2=A0 =C2=A0 =C2=A0 =C2=A0=C2=A0=C2=A0 __stack_chk_guard;
>=C2=A0 =C2=A0 };
>=C2=A0 =C2=A0 +
>=C2=A0 =C2=A0 +FBSD_1.8 {
>=C2=A0 =C2=A0 +=C2=A0=C2=A0=C2=A0 __gets_chk;
>=C2=A0 =C2=A0 +=C2=A0=C2=A0=C2=A0 __fgets_chk;
>=C2=A0 =C2=A0 +=C2=A0=C2=A0=C2=A0 __memcpy_chk;
>=C2=A0 =C2=A0 +=C2=A0=C2=A0=C2=A0 __memmove_chk;
>=C2=A0 =C2=A0 +=C2=A0=C2=A0=C2=A0 __memset_chk;
>=C2=A0 =C2=A0 +=C2=A0=C2=A0=C2=A0 __snprintf_chk;
>=C2=A0 =C2=A0 +=C2=A0=C2=A0=C2=A0 __sprintf_chk;
>=C2=A0 =C2=A0 +=C2=A0=C2=A0=C2=A0 __stpcpy_chk;
>=C2=A0 =C2=A0 +=C2=A0=C2=A0=C2=A0 __stpncpy_chk;
>=C2=A0 =C2=A0 +=C2=A0=C2=A0=C2=A0 __strcat_chk;
>=C2=A0 =C2=A0 +=C2=A0=C2=A0=C2=A0 __strcpy_chk;
>=C2=A0 =C2=A0 +=C2=A0=C2=A0=C2=A0 __strncat_chk;
>=C2=A0 =C2=A0 +=C2=A0=C2=A0=C2=A0 __strncpy_chk;
>=C2=A0 =C2=A0 +=C2=A0=C2=A0=C2=A0 __vsnprintf_chk;
>=C2=A0 =C2=A0 +=C2=A0=C2=A0=C2=A0 __vsprintf_chk;
>=C2=A0 =C2=A0 +};
>=C2=A0 =C2=A0 diff --git a/lib/libc/secure/fgets_chk.c b/lib/libc/secure/f=
gets_chk.c
>=C2=A0 =C2=A0 new file mode 100644
>=C2=A0 =C2=A0 index 000000000000..72aa1d816ce1
>=C2=A0 =C2=A0 --- /dev/null
>=C2=A0 =C2=A0 +++ b/lib/libc/secure/fgets_chk.c
>=C2=A0 =C2=A0 @@ -0,0 +1,54 @@
>=C2=A0 =C2=A0 +/*-
>=C2=A0 =C2=A0 + *
>=C2=A0 =C2=A0 + * SPDX-License-Identifier: BSD-2-Clause
>=C2=A0 =C2=A0 + *
>=C2=A0 =C2=A0 + * Copyright (c) 2006 The NetBSD Foundation, Inc.
>=C2=A0 =C2=A0 + * All rights reserved.
>=C2=A0 =C2=A0 + *
>=C2=A0 =C2=A0 + * This code is derived from software contributed to The Ne=
tBSD
>=C2=A0 =C2=A0 Foundation
>=C2=A0 =C2=A0 + * by Christos Zoulas.
>=C2=A0 =C2=A0 + *
>=C2=A0 =C2=A0 + * Redistribution and use in source and binary forms, with =
or without
>=C2=A0 =C2=A0 + * modification, are permitted provided that the following =
conditions
>=C2=A0 =C2=A0 + * are met:
>=C2=A0 =C2=A0 + * 1. Redistributions of source code must retain the above =
copyright
>=C2=A0 =C2=A0 + *=C2=A0 =C2=A0 notice, this list of conditions and the fol=
lowing disclaimer.
>=C2=A0 =C2=A0 + * 2. Redistributions in binary form must reproduce the abo=
ve copyright
>=C2=A0 =C2=A0 + *=C2=A0 =C2=A0 notice, this list of conditions and the fol=
lowing disclaimer
>=C2=A0 =C2=A0 in the
>=C2=A0 =C2=A0 + *=C2=A0 =C2=A0 documentation and/or other materials provid=
ed with the
>=C2=A0 =C2=A0 distribution.
>=C2=A0 =C2=A0 + *
>=C2=A0 =C2=A0 + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC.=
 AND
>=C2=A0 =C2=A0 CONTRIBUTORS
>=C2=A0 =C2=A0 + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDI=
NG, BUT
>=C2=A0 =C2=A0 NOT LIMITED
>=C2=A0 =C2=A0 + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNES=
S FOR A
>=C2=A0 =C2=A0 PARTICULAR
>=C2=A0 =C2=A0 + * PURPOSE ARE DISCLAIMED.=C2=A0 IN NO EVENT SHALL THE FOUN=
DATION OR
>=C2=A0 =C2=A0 CONTRIBUTORS
>=C2=A0 =C2=A0 + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
>=C2=A0 =C2=A0 EXEMPLARY, OR
>=C2=A0 =C2=A0 + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PR=
OCUREMENT OF
>=C2=A0 =C2=A0 + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROF=
ITS; OR
>=C2=A0 =C2=A0 BUSINESS
>=C2=A0 =C2=A0 + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABIL=
ITY,
>=C2=A0 =C2=A0 WHETHER IN
>=C2=A0 =C2=A0 + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENC=
E OR
>=C2=A0 =C2=A0 OTHERWISE)
>=C2=A0 =C2=A0 + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN=
 IF
>=C2=A0 =C2=A0 ADVISED OF THE
>=C2=A0 =C2=A0 + * POSSIBILITY OF SUCH DAMAGE.
>=C2=A0 =C2=A0 + */
>=C2=A0 =C2=A0 +#include <sys/cdefs.h>
>=C2=A0 =C2=A0 +__RCSID("$NetBSD: fgets_chk.c,v 1.6 2009/02/05 05:41:51 luk=
em Exp $");
>=C2=A0 =C2=A0 +
>=C2=A0 =C2=A0 +#include <limits.h>
>=C2=A0 =C2=A0 +#include <stdio.h>
>=C2=A0 =C2=A0 +#include <stdlib.h>
>=C2=A0 =C2=A0 +#include <string.h>
>=C2=A0 =C2=A0 +
>=C2=A0 =C2=A0 +#include <ssp/stdio.h>
>=C2=A0 =C2=A0 +#include <ssp/string.h>
>=C2=A0 =C2=A0 +#undef fgets
>=C2=A0 =C2=A0 +
>=C2=A0 =C2=A0 +char *
>=C2=A0 =C2=A0 +__fgets_chk(char * __restrict buf, int len, size_t slen, FI=
LE *fp)
>=C2=A0 =C2=A0 +{
>=C2=A0 =C2=A0 +=C2=A0=C2=A0=C2=A0 if (slen >=3D (size_t)INT_MAX)
>=C2=A0 =C2=A0 +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 return (fgets(buf, le=
n, fp));
>=C2=A0 =C2=A0 +
>=C2=A0 =C2=A0 +=C2=A0=C2=A0=C2=A0 if (len >=3D 0 && (size_t)len > slen)
>=C2=A0 =C2=A0 +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 __chk_fail();
>=C2=A0 =C2=A0 +
>=C2=A0 =C2=A0 +=C2=A0=C2=A0=C2=A0 return (fgets(buf, len, fp));
>=C2=A0 =C2=A0 +}
>=C2=A0 =C2=A0 diff --git a/lib/libc/secure/gets_chk.c b/lib/libc/secure/ge=
ts_chk.c
>=C2=A0 =C2=A0 new file mode 100644
>=C2=A0 =C2=A0 index 000000000000..18c1e2d18f43
>=C2=A0 =C2=A0 --- /dev/null
>=C2=A0 =C2=A0 +++ b/lib/libc/secure/gets_chk.c
>=C2=A0 =C2=A0 @@ -0,0 +1,74 @@
>=C2=A0 =C2=A0 +/*-
>=C2=A0 =C2=A0 + *
>=C2=A0 =C2=A0 + * SPDX-License-Identifier: BSD-2-Clause
>=C2=A0 =C2=A0 + *
>=C2=A0 =C2=A0 + * Copyright (c) 2006 The NetBSD Foundation, Inc.
>=C2=A0 =C2=A0 + * All rights reserved.
>=C2=A0 =C2=A0 + *
>=C2=A0 =C2=A0 + * This code is derived from software contributed to The Ne=
tBSD
>=C2=A0 =C2=A0 Foundation
>=C2=A0 =C2=A0 + * by Christos Zoulas.
>=C2=A0 =C2=A0 + *
>=C2=A0 =C2=A0 + * Redistribution and use in source and binary forms, with =
or without
>=C2=A0 =C2=A0 + * modification, are permitted provided that the following =
conditions
>=C2=A0 =C2=A0 + * are met:
>=C2=A0 =C2=A0 + * 1. Redistributions of source code must retain the above =
copyright
>=C2=A0 =C2=A0 + *=C2=A0 =C2=A0 notice, this list of conditions and the fol=
lowing disclaimer.
>=C2=A0 =C2=A0 + * 2. Redistributions in binary form must reproduce the abo=
ve copyright
>=C2=A0 =C2=A0 + *=C2=A0 =C2=A0 notice, this list of conditions and the fol=
lowing disclaimer
>=C2=A0 =C2=A0 in the
>=C2=A0 =C2=A0 + *=C2=A0 =C2=A0 documentation and/or other materials provid=
ed with the
>=C2=A0 =C2=A0 distribution.
>=C2=A0 =C2=A0 + *
>=C2=A0 =C2=A0 + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC.=
 AND
>=C2=A0 =C2=A0 CONTRIBUTORS
>=C2=A0 =C2=A0 + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDI=
NG, BUT
>=C2=A0 =C2=A0 NOT LIMITED
>=C2=A0 =C2=A0 + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNES=
S FOR A
>=C2=A0 =C2=A0 PARTICULAR
>=C2=A0 =C2=A0 + * PURPOSE ARE DISCLAIMED.=C2=A0 IN NO EVENT SHALL THE FOUN=
DATION OR
>=C2=A0 =C2=A0 CONTRIBUTORS
>=C2=A0 =C2=A0 + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
>=C2=A0 =C2=A0 EXEMPLARY, OR
>=C2=A0 =C2=A0 + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PR=
OCUREMENT OF
>=C2=A0 =C2=A0 + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROF=
ITS; OR
>=C2=A0 =C2=A0 BUSINESS
>=C2=A0 =C2=A0 + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABIL=
ITY,
>=C2=A0 =C2=A0 WHETHER IN
>=C2=A0 =C2=A0 + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENC=
E OR
>=C2=A0 =C2=A0 OTHERWISE)
>=C2=A0 =C2=A0 + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN=
 IF
>=C2=A0 =C2=A0 ADVISED OF THE
>=C2=A0 =C2=A0 + * POSSIBILITY OF SUCH DAMAGE.
>=C2=A0 =C2=A0 + */
>=C2=A0 =C2=A0 +#include <sys/cdefs.h>
>=C2=A0 =C2=A0 +__RCSID("$NetBSD: gets_chk.c,v 1.7 2013/10/04 20:49:16 chri=
stos Exp
>=C2=A0 =C2=A0 $");
>=C2=A0 =C2=A0 +
>=C2=A0 =C2=A0 +#include <limits.h>
>=C2=A0 =C2=A0 +#include <stdio.h>
>=C2=A0 =C2=A0 +#include <stdlib.h>
>=C2=A0 =C2=A0 +#include <string.h>
>=C2=A0 =C2=A0 +
>=C2=A0 =C2=A0 +#include <ssp/stdio.h>
>=C2=A0 =C2=A0 +#include <ssp/string.h>
>=C2=A0 =C2=A0 +
>=C2=A0 =C2=A0 +char *__gets_unsafe(char *);
>=C2=A0 =C2=A0 +
>=C2=A0 =C2=A0 +char *
>=C2=A0 =C2=A0 +__gets_chk(char * __restrict buf, size_t slen)
>=C2=A0 =C2=A0 +{
>=C2=A0 =C2=A0 +=C2=A0=C2=A0=C2=A0 char *abuf;
>=C2=A0 =C2=A0 +=C2=A0=C2=A0=C2=A0 size_t len;
>=C2=A0 =C2=A0 +
>=C2=A0 =C2=A0 +=C2=A0=C2=A0=C2=A0 if (slen >=3D (size_t)INT_MAX)
>=C2=A0 =C2=A0 +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 return (__gets_unsafe=
(buf));
>=C2=A0 =C2=A0 +
>=C2=A0 =C2=A0 +=C2=A0=C2=A0=C2=A0 if ((abuf =3D malloc(slen + 1)) =3D=3D N=
ULL)
>=C2=A0 =C2=A0 +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 return (__gets_unsafe=
(buf));
>=C2=A0 =C2=A0 +
>=C2=A0 =C2=A0 +=C2=A0=C2=A0=C2=A0 if (fgets(abuf, (int)(slen + 1), stdin) =
=3D=3D NULL) {
>=C2=A0 =C2=A0 +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 free(abuf);
>=C2=A0 =C2=A0 +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 return (NULL);
>=C2=A0 =C2=A0 +=C2=A0=C2=A0=C2=A0 }
>=C2=A0 =C2=A0 +
>=C2=A0 =C2=A0 +=C2=A0=C2=A0=C2=A0 len =3D strlen(abuf);
>=C2=A0 =C2=A0 +=C2=A0=C2=A0=C2=A0 if (len > 0 && abuf[len - 1] =3D=3D '\n'=
)
>=C2=A0 =C2=A0 +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 --len;
>=C2=A0 =C2=A0 +
>=C2=A0 =C2=A0 +=C2=A0=C2=A0=C2=A0 if (len >=3D slen)
>=C2=A0 =C2=A0 +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 __chk_fail();
>=C2=A0 =C2=A0 +
>=C2=A0 =C2=A0 +=C2=A0=C2=A0=C2=A0 (void)memcpy(buf, abuf, len);
>=C2=A0 =C2=A0 +
>=C2=A0 =C2=A0 +=C2=A0=C2=A0=C2=A0 buf[len] =3D '\0';
>=C2=A0 =C2=A0 +=C2=A0=C2=A0=C2=A0 free(abuf);
>=C2=A0 =C2=A0 +=C2=A0=C2=A0=C2=A0 return (buf);
>=C2=A0 =C2=A0 +}
>=C2=A0 =C2=A0 diff --git a/lib/libc/secure/memcpy_chk.c b/lib/libc/secure/=
memcpy_chk.c
>=C2=A0 =C2=A0 new file mode 100644
>=C2=A0 =C2=A0 index 000000000000..99cf2d5f13ff
>=C2=A0 =C2=A0 --- /dev/null
>=C2=A0 =C2=A0 +++ b/lib/libc/secure/memcpy_chk.c
>=C2=A0 =C2=A0 @@ -0,0 +1,53 @@
>=C2=A0 =C2=A0 +/*-
>=C2=A0 =C2=A0 + *
>=C2=A0 =C2=A0 + * SPDX-License-Identifier: BSD-2-Clause
>=C2=A0 =C2=A0 + *
>=C2=A0 =C2=A0 + * Copyright (c) 2006 The NetBSD Foundation, Inc.
>=C2=A0 =C2=A0 + * All rights reserved.
>=C2=A0 =C2=A0 + *
>=C2=A0 =C2=A0 + * This code is derived from software contributed to The Ne=
tBSD
>=C2=A0 =C2=A0 Foundation
>=C2=A0 =C2=A0 + * by Christos Zoulas.
>=C2=A0 =C2=A0 + *
>=C2=A0 =C2=A0 + * Redistribution and use in source and binary forms, with =
or without
>=C2=A0 =C2=A0 + * modification, are permitted provided that the following =
conditions
>=C2=A0 =C2=A0 + * are met:
>=C2=A0 =C2=A0 + * 1. Redistributions of source code must retain the above =
copyright
>=C2=A0 =C2=A0 + *=C2=A0 =C2=A0 notice, this list of conditions and the fol=
lowing disclaimer.
>=C2=A0 =C2=A0 + * 2. Redistributions in binary form must reproduce the abo=
ve copyright
>=C2=A0 =C2=A0 + *=C2=A0 =C2=A0 notice, this list of conditions and the fol=
lowing disclaimer
>=C2=A0 =C2=A0 in the
>=C2=A0 =C2=A0 + *=C2=A0 =C2=A0 documentation and/or other materials provid=
ed with the
>=C2=A0 =C2=A0 distribution.
>=C2=A0 =C2=A0 + *
>=C2=A0 =C2=A0 + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC.=
 AND
>=C2=A0 =C2=A0 CONTRIBUTORS
>=C2=A0 =C2=A0 + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDI=
NG, BUT
>=C2=A0 =C2=A0 NOT LIMITED
>=C2=A0 =C2=A0 + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNES=
S FOR A
>=C2=A0 =C2=A0 PARTICULAR
>=C2=A0 =C2=A0 + * PURPOSE ARE DISCLAIMED.=C2=A0 IN NO EVENT SHALL THE FOUN=
DATION OR
>=C2=A0 =C2=A0 CONTRIBUTORS
>=C2=A0 =C2=A0 + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
>=C2=A0 =C2=A0 EXEMPLARY, OR
>=C2=A0 =C2=A0 + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PR=
OCUREMENT OF
>=C2=A0 =C2=A0 + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROF=
ITS; OR
>=C2=A0 =C2=A0 BUSINESS
>=C2=A0 =C2=A0 + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABIL=
ITY,
>=C2=A0 =C2=A0 WHETHER IN
>=C2=A0 =C2=A0 + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENC=
E OR
>=C2=A0 =C2=A0 OTHERWISE)
>=C2=A0 =C2=A0 + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN=
 IF
>=C2=A0 =C2=A0 ADVISED OF THE
>=C2=A0 =C2=A0 + * POSSIBILITY OF SUCH DAMAGE.
>=C2=A0 =C2=A0 + */
>=C2=A0 =C2=A0 +#include <sys/cdefs.h>
>=C2=A0 =C2=A0 +__RCSID("$NetBSD: memcpy_chk.c,v 1.7 2015/05/13 19:57:16 jo=
erg Exp $");
>=C2=A0 =C2=A0 +
>=C2=A0 =C2=A0 +#include <string.h>
>=C2=A0 =C2=A0 +
>=C2=A0 =C2=A0 +#include <ssp/string.h>
>=C2=A0 =C2=A0 +#undef memcpy
>=C2=A0 =C2=A0 +
>=C2=A0 =C2=A0 +#include "ssp_internal.h"
>=C2=A0 =C2=A0 +
>=C2=A0 =C2=A0 +void *
>=C2=A0 =C2=A0 +__memcpy_chk(void * __restrict dst, const void * __restrict=
 src,
>=C2=A0 =C2=A0 size_t len,
>=C2=A0 =C2=A0 +=C2=A0 =C2=A0 size_t slen)
>=C2=A0 =C2=A0 +{
>=C2=A0 =C2=A0 +=C2=A0=C2=A0=C2=A0 if (len > slen)
>=C2=A0 =C2=A0 +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 __chk_fail();
>=C2=A0 =C2=A0 +
>=C2=A0 =C2=A0 +=C2=A0=C2=A0=C2=A0 if (__ssp_overlap((const char *)src, (co=
nst char *)dst, len))
>=C2=A0 =C2=A0 +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 __chk_fail();
>=C2=A0 =C2=A0 +
>=C2=A0 =C2=A0 +=C2=A0=C2=A0=C2=A0 return (memcpy(dst, src, len));
>=C2=A0 =C2=A0 +}
>=C2=A0 =C2=A0 diff --git a/lib/libc/secure/memmove_chk.c
>=C2=A0 =C2=A0 b/lib/libc/secure/memmove_chk.c
>=C2=A0 =C2=A0 new file mode 100644
>=C2=A0 =C2=A0 index 000000000000..07f965d608fc
>=C2=A0 =C2=A0 --- /dev/null
>=C2=A0 =C2=A0 +++ b/lib/libc/secure/memmove_chk.c
>=C2=A0 =C2=A0 @@ -0,0 +1,47 @@
>=C2=A0 =C2=A0 +/*-
>=C2=A0 =C2=A0 + *
>=C2=A0 =C2=A0 + * SPDX-License-Identifier: BSD-2-Clause
>=C2=A0 =C2=A0 + *
>=C2=A0 =C2=A0 + * Copyright (c) 2006 The NetBSD Foundation, Inc.
>=C2=A0 =C2=A0 + * All rights reserved.
>=C2=A0 =C2=A0 + *
>=C2=A0 =C2=A0 + * This code is derived from software contributed to The Ne=
tBSD
>=C2=A0 =C2=A0 Foundation
>=C2=A0 =C2=A0 + * by Christos Zoulas.
>=C2=A0 =C2=A0 + *
>=C2=A0 =C2=A0 + * Redistribution and use in source and binary forms, with =
or without
>=C2=A0 =C2=A0 + * modification, are permitted provided that the following =
conditions
>=C2=A0 =C2=A0 + * are met:
>=C2=A0 =C2=A0 + * 1. Redistributions of source code must retain the above =
copyright
>=C2=A0 =C2=A0 + *=C2=A0 =C2=A0 notice, this list of conditions and the fol=
lowing disclaimer.
>=C2=A0 =C2=A0 + * 2. Redistributions in binary form must reproduce the abo=
ve copyright
>=C2=A0 =C2=A0 + *=C2=A0 =C2=A0 notice, this list of conditions and the fol=
lowing disclaimer
>=C2=A0 =C2=A0 in the
>=C2=A0 =C2=A0 + *=C2=A0 =C2=A0 documentation and/or other materials provid=
ed with the
>=C2=A0 =C2=A0 distribution.
>=C2=A0 =C2=A0 + *
>=C2=A0 =C2=A0 + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC.=
 AND
>=C2=A0 =C2=A0 CONTRIBUTORS
>=C2=A0 =C2=A0 + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDI=
NG, BUT
>=C2=A0 =C2=A0 NOT LIMITED
>=C2=A0 =C2=A0 + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNES=
S FOR A
>=C2=A0 =C2=A0 PARTICULAR
>=C2=A0 =C2=A0 + * PURPOSE ARE DISCLAIMED.=C2=A0 IN NO EVENT SHALL THE FOUN=
DATION OR
>=C2=A0 =C2=A0 CONTRIBUTORS
>=C2=A0 =C2=A0 + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
>=C2=A0 =C2=A0 EXEMPLARY, OR
>=C2=A0 =C2=A0 + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PR=
OCUREMENT OF
>=C2=A0 =C2=A0 + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROF=
ITS; OR
>=C2=A0 =C2=A0 BUSINESS
>=C2=A0 =C2=A0 + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABIL=
ITY,
>=C2=A0 =C2=A0 WHETHER IN
>=C2=A0 =C2=A0 + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENC=
E OR
>=C2=A0 =C2=A0 OTHERWISE)
>=C2=A0 =C2=A0 + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN=
 IF
>=C2=A0 =C2=A0 ADVISED OF THE
>=C2=A0 =C2=A0 + * POSSIBILITY OF SUCH DAMAGE.
>=C2=A0 =C2=A0 + */
>=C2=A0 =C2=A0 +#include <sys/cdefs.h>
>=C2=A0 =C2=A0 +__RCSID("$NetBSD: memmove_chk.c,v 1.6 2020/09/05 13:37:59 m=
rg Exp $");
>=C2=A0 =C2=A0 +
>=C2=A0 =C2=A0 +#include <string.h>
>=C2=A0 =C2=A0 +
>=C2=A0 =C2=A0 +#include <ssp/string.h>
>=C2=A0 =C2=A0 +#undef memmove
>=C2=A0 =C2=A0 +
>=C2=A0 =C2=A0 +void *
>=C2=A0 =C2=A0 +__memmove_chk(void *dst, const void *src, size_t len,
>=C2=A0 =C2=A0 +=C2=A0 =C2=A0 size_t slen)
>=C2=A0 =C2=A0 +{
>=C2=A0 =C2=A0 +=C2=A0=C2=A0=C2=A0 if (len > slen)
>=C2=A0 =C2=A0 +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 __chk_fail();
>=C2=A0 =C2=A0 +=C2=A0=C2=A0=C2=A0 return (memmove(dst, src, len));
>=C2=A0 =C2=A0 +}
>=C2=A0 =C2=A0 diff --git a/lib/libc/secure/memset_chk.c b/lib/libc/secure/=
memset_chk.c
>=C2=A0 =C2=A0 new file mode 100644
>=C2=A0 =C2=A0 index 000000000000..f337be98b46d
>=C2=A0 =C2=A0 --- /dev/null
>=C2=A0 =C2=A0 +++ b/lib/libc/secure/memset_chk.c
>=C2=A0 =C2=A0 @@ -0,0 +1,46 @@
>=C2=A0 =C2=A0 +/*-
>=C2=A0 =C2=A0 + *
>=C2=A0 =C2=A0 + * SPDX-License-Identifier: BSD-2-Clause
>=C2=A0 =C2=A0 + *
>=C2=A0 =C2=A0 + * Copyright (c) 2006 The NetBSD Foundation, Inc.
>=C2=A0 =C2=A0 + * All rights reserved.
>=C2=A0 =C2=A0 + *
>=C2=A0 =C2=A0 + * This code is derived from software contributed to The Ne=
tBSD
>=C2=A0 =C2=A0 Foundation
>=C2=A0 =C2=A0 + * by Christos Zoulas.
>=C2=A0 =C2=A0 + *
>=C2=A0 =C2=A0 + * Redistribution and use in source and binary forms, with =
or without
>=C2=A0 =C2=A0 + * modification, are permitted provided that the following =
conditions
>=C2=A0 =C2=A0 + * are met:
>=C2=A0 =C2=A0 + * 1. Redistributions of source code must retain the above =
copyright
>=C2=A0 =C2=A0 + *=C2=A0 =C2=A0 notice, this list of conditions and the fol=
lowing disclaimer.
>=C2=A0 =C2=A0 + * 2. Redistributions in binary form must reproduce the abo=
ve copyright
>=C2=A0 =C2=A0 + *=C2=A0 =C2=A0 notice, this list of conditions and the fol=
lowing disclaimer
>=C2=A0 =C2=A0 in the
>=C2=A0 =C2=A0 + *=C2=A0 =C2=A0 documentation and/or other materials provid=
ed with the
>=C2=A0 =C2=A0 distribution.
>=C2=A0 =C2=A0 + *
>=C2=A0 =C2=A0 + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC.=
 AND
>=C2=A0 =C2=A0 CONTRIBUTORS
>=C2=A0 =C2=A0 + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDI=
NG, BUT
>=C2=A0 =C2=A0 NOT LIMITED
>=C2=A0 =C2=A0 + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNES=
S FOR A
>=C2=A0 =C2=A0 PARTICULAR
>=C2=A0 =C2=A0 + * PURPOSE ARE DISCLAIMED.=C2=A0 IN NO EVENT SHALL THE FOUN=
DATION OR
>=C2=A0 =C2=A0 CONTRIBUTORS
>=C2=A0 =C2=A0 + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
>=C2=A0 =C2=A0 EXEMPLARY, OR
>=C2=A0 =C2=A0 + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PR=
OCUREMENT OF
>=C2=A0 =C2=A0 + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROF=
ITS; OR
>=C2=A0 =C2=A0 BUSINESS
>=C2=A0 =C2=A0 + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABIL=
ITY,
>=C2=A0 =C2=A0 WHETHER IN
>=C2=A0 =C2=A0 + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENC=
E OR
>=C2=A0 =C2=A0 OTHERWISE)
>=C2=A0 =C2=A0 + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN=
 IF
>=C2=A0 =C2=A0 ADVISED OF THE
>=C2=A0 =C2=A0 + * POSSIBILITY OF SUCH DAMAGE.
>=C2=A0 =C2=A0 + */
>=C2=A0 =C2=A0 +#include <sys/cdefs.h>
>=C2=A0 =C2=A0 +__RCSID("$NetBSD: memset_chk.c,v 1.5 2014/09/17 00:39:28 jo=
erg Exp $");
>=C2=A0 =C2=A0 +
>=C2=A0 =C2=A0 +#include <string.h>
>=C2=A0 =C2=A0 +
>=C2=A0 =C2=A0 +#include <ssp/string.h>
>=C2=A0 =C2=A0 +#undef memset
>=C2=A0 =C2=A0 +
>=C2=A0 =C2=A0 +void *
>=C2=A0 =C2=A0 +__memset_chk(void * __restrict dst, int val, size_t len, si=
ze_t slen)
>=C2=A0 =C2=A0 +{
>=C2=A0 =C2=A0 +=C2=A0=C2=A0=C2=A0 if (len > slen)
>=C2=A0 =C2=A0 +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 __chk_fail();
>=C2=A0 =C2=A0 +=C2=A0=C2=A0=C2=A0 return (memset(dst, val, len));
>=C2=A0 =C2=A0 +}
>=C2=A0 =C2=A0 diff --git a/lib/libc/secure/snprintf_chk.c
>=C2=A0 =C2=A0 b/lib/libc/secure/snprintf_chk.c
>=C2=A0 =C2=A0 new file mode 100644
>=C2=A0 =C2=A0 index 000000000000..52ef874ede5b
>=C2=A0 =C2=A0 --- /dev/null
>=C2=A0 =C2=A0 +++ b/lib/libc/secure/snprintf_chk.c
>=C2=A0 =C2=A0 @@ -0,0 +1,56 @@
>=C2=A0 =C2=A0 +/*-
>=C2=A0 =C2=A0 + *
>=C2=A0 =C2=A0 + * SPDX-License-Identifier: BSD-2-Clause
>=C2=A0 =C2=A0 + *
>=C2=A0 =C2=A0 + * Copyright (c) 2006 The NetBSD Foundation, Inc.
>=C2=A0 =C2=A0 + * All rights reserved.
>=C2=A0 =C2=A0 + *
>=C2=A0 =C2=A0 + * This code is derived from software contributed to The Ne=
tBSD
>=C2=A0 =C2=A0 Foundation
>=C2=A0 =C2=A0 + * by Christos Zoulas.
>=C2=A0 =C2=A0 + *
>=C2=A0 =C2=A0 + * Redistribution and use in source and binary forms, with =
or without
>=C2=A0 =C2=A0 + * modification, are permitted provided that the following =
conditions
>=C2=A0 =C2=A0 + * are met:
>=C2=A0 =C2=A0 + * 1. Redistributions of source code must retain the above =
copyright
>=C2=A0 =C2=A0 + *=C2=A0 =C2=A0 notice, this list of conditions and the fol=
lowing disclaimer.
>=C2=A0 =C2=A0 + * 2. Redistributions in binary form must reproduce the abo=
ve copyright
>=C2=A0 =C2=A0 + *=C2=A0 =C2=A0 notice, this list of conditions and the fol=
lowing disclaimer
>=C2=A0 =C2=A0 in the
>=C2=A0 =C2=A0 + *=C2=A0 =C2=A0 documentation and/or other materials provid=
ed with the
>=C2=A0 =C2=A0 distribution.
>=C2=A0 =C2=A0 + *
>=C2=A0 =C2=A0 + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC.=
 AND
>=C2=A0 =C2=A0 CONTRIBUTORS
>=C2=A0 =C2=A0 + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDI=
NG, BUT
>=C2=A0 =C2=A0 NOT LIMITED
>=C2=A0 =C2=A0 + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNES=
S FOR A
>=C2=A0 =C2=A0 PARTICULAR
>=C2=A0 =C2=A0 + * PURPOSE ARE DISCLAIMED.=C2=A0 IN NO EVENT SHALL THE FOUN=
DATION OR
>=C2=A0 =C2=A0 CONTRIBUTORS
>=C2=A0 =C2=A0 + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
>=C2=A0 =C2=A0 EXEMPLARY, OR
>=C2=A0 =C2=A0 + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PR=
OCUREMENT OF
>=C2=A0 =C2=A0 + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROF=
ITS; OR
>=C2=A0 =C2=A0 BUSINESS
>=C2=A0 =C2=A0 + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABIL=
ITY,
>=C2=A0 =C2=A0 WHETHER IN
>=C2=A0 =C2=A0 + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENC=
E OR
>=C2=A0 =C2=A0 OTHERWISE)
>=C2=A0 =C2=A0 + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN=
 IF
>=C2=A0 =C2=A0 ADVISED OF THE
>=C2=A0 =C2=A0 + * POSSIBILITY OF SUCH DAMAGE.
>=C2=A0 =C2=A0 + */
>=C2=A0 =C2=A0 +#include <sys/cdefs.h>
>=C2=A0 =C2=A0 +__RCSID("$NetBSD: snprintf_chk.c,v 1.5 2008/04/28 20:23:00 =
martin
>=C2=A0 =C2=A0 Exp $");
>=C2=A0 =C2=A0 +
>=C2=A0 =C2=A0 +#include <stdarg.h>
>=C2=A0 =C2=A0 +#include <stdio.h>
>=C2=A0 =C2=A0 +
>=C2=A0 =C2=A0 +#include <ssp/stdio.h>
>=C2=A0 =C2=A0 +#undef vsnprintf
>=C2=A0 =C2=A0 +
>=C2=A0 =C2=A0 +int
>=C2=A0 =C2=A0 +__snprintf_chk(char * __restrict buf, size_t len, int flags=
, size_t
>=C2=A0 =C2=A0 slen,
>=C2=A0 =C2=A0 +=C2=A0 =C2=A0 const char * __restrict fmt, ...)
>=C2=A0 =C2=A0 +{
>=C2=A0 =C2=A0 +=C2=A0=C2=A0=C2=A0 va_list ap;
>=C2=A0 =C2=A0 +=C2=A0=C2=A0=C2=A0 int rv;
>=C2=A0 =C2=A0 +
>=C2=A0 =C2=A0 +=C2=A0=C2=A0=C2=A0 if (len > slen)
>=C2=A0 =C2=A0 +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 __chk_fail();
>=C2=A0 =C2=A0 +
>=C2=A0 =C2=A0 +=C2=A0=C2=A0=C2=A0 va_start(ap, fmt);
>=C2=A0 =C2=A0 +=C2=A0=C2=A0=C2=A0 rv =3D vsnprintf(buf, len, fmt, ap);
>=C2=A0 =C2=A0 +=C2=A0=C2=A0=C2=A0 va_end(ap);
>=C2=A0 =C2=A0 +
>=C2=A0 =C2=A0 +=C2=A0=C2=A0=C2=A0 return (rv);
>=C2=A0 =C2=A0 +}
>=C2=A0 =C2=A0 diff --git a/lib/libc/secure/sprintf_chk.c
>=C2=A0 =C2=A0 b/lib/libc/secure/sprintf_chk.c
>=C2=A0 =C2=A0 new file mode 100644
>=C2=A0 =C2=A0 index 000000000000..d4c42ccba3ce
>=C2=A0 =C2=A0 --- /dev/null
>=C2=A0 =C2=A0 +++ b/lib/libc/secure/sprintf_chk.c
>=C2=A0 =C2=A0 @@ -0,0 +1,61 @@
>=C2=A0 =C2=A0 +/*-
>=C2=A0 =C2=A0 + *
>=C2=A0 =C2=A0 + * SPDX-License-Identifier: BSD-2-Clause
>=C2=A0 =C2=A0 + *
>=C2=A0 =C2=A0 + * Copyright (c) 2006 The NetBSD Foundation, Inc.
>=C2=A0 =C2=A0 + * All rights reserved.
>=C2=A0 =C2=A0 + *
>=C2=A0 =C2=A0 + * This code is derived from software contributed to The Ne=
tBSD
>=C2=A0 =C2=A0 Foundation
>=C2=A0 =C2=A0 *** 1063 LINES SKIPPED ***
>=20
>=20
 =20
------=_Part_1357399_2058372477.1716093599883
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<html><head></head><body><div class=3D"ydp8924580yahoo-style-wrap" style=3D=
"font-family:Helvetica Neue, Helvetica, Arial, sans-serif;font-size:16px;">=
<div></div>
        <div dir=3D"ltr" data-setdir=3D"false">FWIW .. and let me be clear =
I haven't worked on this in ages and I am not planning to retake this eithe=
r...</div><div dir=3D"ltr" data-setdir=3D"false"><br></div><div dir=3D"ltr"=
 data-setdir=3D"false">clang just couldn't do the static&nbsp; fortify_sour=
ce <span><span style=3D"color: rgb(0, 0, 0); font-family: Helvetica Neue, H=
elvetica, Arial, sans-serif; font-size: 16px;">checks</span></span>&nbsp; d=
ue to the way llvm uses an intermediate representation; the size just could=
n't be handled in the preprocessor. Google did spend some time adding extra=
 attributes to clang to improve the debugging and you can see that implemen=
ted in bionic libc but that was it. musl didn't even try.</div><div dir=3D"=
ltr" data-setdir=3D"false"><br></div><div dir=3D"ltr" data-setdir=3D"false"=
>fortify_source does replace some key libc functions with memory checking a=
lternatives and that turns out to be annoying when debugging. In a way it b=
reaks that principle C programmers once had, where developers are expected =
to know what they are doing, and if the error is caught at runtime by the s=
tack protector anyways it ends up being redundant.</div><div dir=3D"ltr" da=
ta-setdir=3D"false"><br></div><div dir=3D"ltr" data-setdir=3D"false">One mo=
re thing about the static checks. Most of the linux distributions out there=
 indeed have built their software packages with GCC and fortify_source &gt;=
=3D2. As a consequence, when we ran an exp-run on the ports tree (with GCC)=
, fortify_source didn't find anything: it was basically a waste of time.</d=
iv><div dir=3D"ltr" data-setdir=3D"false"><br></div><div dir=3D"ltr" data-s=
etdir=3D"false">Another reason for not setting it by default is performance=
. And here I answer Shawn's comment on why not enable stack-protector-all a=
nd safestack and fortify_source at the same time: running unnecessary check=
s over and over again wastes energy and can have some performance hit. The =
later may seem negligible in modern processors, but why do them if they bri=
ng no benefit? (No need to answer ... just left as food for thought)</div><=
div dir=3D"ltr" data-setdir=3D"false"><br></div><div dir=3D"ltr" data-setdi=
r=3D"false">Pedro.</div><div><br></div>
       =20
        </div><div id=3D"ydp72f18629yahoo_quoted_6991073376" class=3D"ydp72=
f18629yahoo_quoted">
            <div style=3D"font-family:'Helvetica Neue', Helvetica, Arial, s=
ans-serif;font-size:13px;color:#26282a;">
               =20
                <div>
                        On Saturday, May 18, 2024 at 09:08:52 PM GMT-5, Kyl=
e Evans &lt;kevans@freebsd.org&gt; wrote:
                    </div>
                    <div><br></div>
                    <div><br></div>
               =20
               =20
                <div><div dir=3D"ltr"><br></div><div dir=3D"ltr"><br></div>=
<div dir=3D"ltr">On 5/18/24 20:09, Pedro Giffuni wrote:<br></div><div dir=
=3D"ltr">&gt; (sorry for top posting .. my mailer just sucks)<br></div><div=
 dir=3D"ltr">&gt; Hi;<br></div><div dir=3D"ltr">&gt; <br></div><div dir=3D"=
ltr">&gt; I used to like the limited static checking FORTIFY_SOURCE provide=
s and <br></div><div dir=3D"ltr">&gt; when I ran it over FreeBSD it did fin=
d a couple of minor issues. It only <br></div><div dir=3D"ltr">&gt; works f=
or GCC though.<br></div><div dir=3D"ltr">&gt; <br></div><div dir=3D"ltr"><b=
r></div><div dir=3D"ltr">I don't think this is particularly true anymore; I=
 haven't found a case <br></div><div dir=3D"ltr">yet where __builtin_object=
_size(3) doesn't give me the correct size <br></div><div dir=3D"ltr">while =
GCC did.&nbsp; I'd welcome counter-examples here, though -- we have <br></d=
iv><div dir=3D"ltr">funding to both finish the project (widen the _FORTIFY_=
SOURCE net to <br></div><div dir=3D"ltr">more of libc/libsys) and add tests=
 to demonstrate that it's both <br></div><div dir=3D"ltr">functional and co=
rrect.&nbsp; It would be useful to also document <br></div><div dir=3D"ltr"=
>deficiencies in the tests.<br></div><div dir=3D"ltr"><br></div><div dir=3D=
"ltr">&gt; I guess it doesn't really hurt to have FORTIFY_SOURCE around and=
 NetBSD <br></div><div dir=3D"ltr">&gt; had the least intrusive implementat=
ion the last time I checked but I <br></div><div dir=3D"ltr">&gt; would cer=
tainly request it should never be activated by default, <br></div><div dir=
=3D"ltr">&gt; specially with clang. The GCC version has seen more developme=
nt on glibc <br></div><div dir=3D"ltr">&gt; but I still think its a dead en=
d.<br></div><div dir=3D"ltr">&gt; <br></div><div dir=3D"ltr"><br></div><div=
 dir=3D"ltr">I don't see a compelling reason to avoid enabling it by defaul=
t; see <br></div><div dir=3D"ltr">above, the functionality that we need in =
clang appears to be just fine <br></div><div dir=3D"ltr">(and, iirc, was al=
so fine when I checked at the beginning of working on <br></div><div dir=3D=
"ltr">this in 2021) and it provides useful<br></div><div dir=3D"ltr"><br></=
div><div dir=3D"ltr">&gt; What I would like to see working on FreeBSD is Sa=
festack as a <br></div><div dir=3D"ltr">&gt; replacement for the stack prot=
ector, which we were so very slow to adopt <br></div><div dir=3D"ltr">&gt; =
even when it was originally developed in FreeBSD. I think other projects <b=
r></div><div dir=3D"ltr">&gt; based on FreeBSD (Chimera and hardenedBSD) ha=
ve been using it but I <br></div><div dir=3D"ltr">&gt; don't know the detai=
ls.<br></div><div dir=3D"ltr">&gt; <br></div><div dir=3D"ltr"><br></div><di=
v dir=3D"ltr">No comment there, though I think Shawn Webb / HardenedBSD had=
 been <br></div><div dir=3D"ltr">playing around with SafeStack (and might h=
ave enabled it? I haven't <br></div><div dir=3D"ltr">actually looked in a w=
hile now).<br></div><div dir=3D"ltr"><br></div><div dir=3D"ltr">&gt; This i=
s just all my $0.02<br></div><div dir=3D"ltr">&gt; <br></div><div dir=3D"lt=
r">&gt; Pedro.<br></div><div dir=3D"ltr"><br></div><div dir=3D"ltr">Thanks,=
<br></div><div dir=3D"ltr"><br></div><div dir=3D"ltr">Kyle Evans<br></div><=
div dir=3D"ltr"><br></div><div dir=3D"ltr">&gt; <br></div><div dir=3D"ltr">=
&gt; On Saturday, May 18, 2024 at 05:54:42 PM GMT-5, Kyle Evans <br></div><=
div dir=3D"ltr">&gt; &lt;<a href=3D"mailto:kaevans@fastmail.com" rel=3D"nof=
ollow" target=3D"_blank">kaevans@fastmail.com</a>&gt; wrote:<br></div><div =
dir=3D"ltr">&gt; <br></div><div dir=3D"ltr">&gt; <br></div><div dir=3D"ltr"=
>&gt; <br></div><div dir=3D"ltr">&gt; <br></div><div dir=3D"ltr">&gt; On Ma=
y 18, 2024 13:42, Pedro Giffuni &lt;<a href=3D"mailto:pfg@freebsd.org" rel=
=3D"nofollow" target=3D"_blank">pfg@freebsd.org</a>&gt; wrote:<br></div><di=
v dir=3D"ltr">&gt; <br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  Oh no .. p=
lease not...<br></div><div dir=3D"ltr">&gt; <br></div><div dir=3D"ltr">&gt;=
&nbsp; &nbsp;  We went into that in a GSoC:<br></div><div dir=3D"ltr">&gt; =
<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  <a href=3D"https://wiki.freeb=
sd.org/SummerOfCode2015/FreeBSDLibcSecurityExtensions" rel=3D"nofollow" tar=
get=3D"_blank">https://wiki.freebsd.org/SummerOfCode2015/FreeBSDLibcSecurit=
yExtensions</a> &lt;<a href=3D"https://wiki.freebsd.org/SummerOfCode2015/Fr=
eeBSDLibcSecurityExtensions" rel=3D"nofollow" target=3D"_blank">https://wik=
i.freebsd.org/SummerOfCode2015/FreeBSDLibcSecurityExtensions</a>&gt;<br></d=
iv><div dir=3D"ltr">&gt; <br></div><div dir=3D"ltr">&gt; <br></div><div dir=
=3D"ltr">&gt;&nbsp; &nbsp;  Ultimately it proved to be useless since stack-=
protector-strong.<br></div><div dir=3D"ltr">&gt; <br></div><div dir=3D"ltr"=
>&gt; <br></div><div dir=3D"ltr">&gt; Respectfully, I disagree with your co=
nclusion here:<br></div><div dir=3D"ltr">&gt; <br></div><div dir=3D"ltr">&g=
t; 1.) _FORTIFY_SOURCE provides more granular detection of overflow; I <br>=
</div><div dir=3D"ltr">&gt; don't have to overflow all the way into the can=
ary at the end of the <br></div><div dir=3D"ltr">&gt; frame to be detected,=
 so my minor bug now can be caught before something <br></div><div dir=3D"l=
tr">&gt; causes the stack frame to be rearranged and turn it into a securit=
y <br></div><div dir=3D"ltr">&gt; issue later<br></div><div dir=3D"ltr">&gt=
; <br></div><div dir=3D"ltr">&gt; 2.) __builtin_object_size doesn't work on=
 heap objects, but it actually <br></div><div dir=3D"ltr">&gt; can work on =
subobjects from a heap allocation (e.g., &amp;foo-&gt;name), so the <br></d=
iv><div dir=3D"ltr">&gt; coverage extends beyond the stack into starting to=
 detect other kinds of <br></div><div dir=3D"ltr">&gt; overflow<br></div><d=
iv dir=3D"ltr">&gt; <br></div><div dir=3D"ltr">&gt; While the security valu=
e over stack-protector-strong may be marginal (I <br></div><div dir=3D"ltr"=
>&gt; won't debate this specifically), the feature still has value in gener=
al.<br></div><div dir=3D"ltr">&gt; <br></div><div dir=3D"ltr">&gt; Thanks,<=
br></div><div dir=3D"ltr">&gt; <br></div><div dir=3D"ltr">&gt; Kyle Evans<b=
r></div><div dir=3D"ltr">&gt; <br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp; =
 The NetBSD code was not well adapted to clang either.<br></div><div dir=3D=
"ltr">&gt; <br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  Ask me more if you=
 really want to dig into it, but we don't want this.<br></div><div dir=3D"l=
tr">&gt; <br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  Pedro.<br></div><div=
 dir=3D"ltr">&gt; <br></div><div dir=3D"ltr">&gt; <br></div><div dir=3D"ltr=
">&gt;&nbsp; &nbsp;  On Monday, May 13, 2024 at 12:24:13 AM GMT-5, Kyle Eva=
ns<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  &lt;<a href=3D"mailto:kevan=
s@freebsd.org" rel=3D"nofollow" target=3D"_blank">kevans@freebsd.org</a>&gt=
; wrote:<br></div><div dir=3D"ltr">&gt; <br></div><div dir=3D"ltr">&gt; <br=
></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  The branch main has been updated=
 by kevans:<br></div><div dir=3D"ltr">&gt; <br></div><div dir=3D"ltr">&gt;&=
nbsp; &nbsp;  URL:<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  <a href=3D"=
https://cgit.FreeBSD.org/src/commit/?id=3Dbe04fec42638f30f50b5b55fd8e3634c0=
fb89928" rel=3D"nofollow" target=3D"_blank">https://cgit.FreeBSD.org/src/co=
mmit/?id=3Dbe04fec42638f30f50b5b55fd8e3634c0fb89928</a> &lt;<a href=3D"http=
s://cgit.FreeBSD.org/src/commit/?id=3Dbe04fec42638f30f50b5b55fd8e3634c0fb89=
928" rel=3D"nofollow" target=3D"_blank">https://cgit.FreeBSD.org/src/commit=
/?id=3Dbe04fec42638f30f50b5b55fd8e3634c0fb89928</a>&gt;<br></div><div dir=
=3D"ltr">&gt; <br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  commit be04fec4=
2638f30f50b5b55fd8e3634c0fb89928<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp=
;  Author:&nbsp; &nbsp; Kyle Evans &lt;<a href=3D"mailto:kevans@FreeBSD.org=
" rel=3D"nofollow" target=3D"_blank">kevans@FreeBSD.org</a> &lt;mailto:keva=
ns@FreeBSD.org&gt;&gt;<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  AuthorD=
ate: 2024-05-13 05:23:49 +0000<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp; =
 Commit:&nbsp; &nbsp; Kyle Evans &lt;<a href=3D"mailto:kevans@FreeBSD.org" =
rel=3D"nofollow" target=3D"_blank">kevans@FreeBSD.org</a> &lt;mailto:kevans=
@FreeBSD.org&gt;&gt;<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  CommitDat=
e: 2024-05-13 05:23:49 +0000<br></div><div dir=3D"ltr">&gt; <br></div><div =
dir=3D"ltr">&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Import _FORTIFY_SOURCE i=
mplementation from NetBSD<br></div><div dir=3D"ltr">&gt; <br></div><div dir=
=3D"ltr">&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; This is a mostly-unmodified=
 copy of the various *_chk<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  imp=
lementations<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbs=
p; and headers from NetBSD, without yet modifying system headers<br></div><=
div dir=3D"ltr">&gt;&nbsp; &nbsp;  to start<br></div><div dir=3D"ltr">&gt;&=
nbsp; &nbsp; &nbsp; &nbsp; &nbsp; actually including them.&nbsp; A future c=
ommit will also apply the<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  need=
ed<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bits to=
 fix ssp/unistd.h.<br></div><div dir=3D"ltr">&gt; <br></div><div dir=3D"ltr=
">&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Reviewed by:&nbsp; &nbsp; imp, pau=
amma_gundo.com (both previous<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  =
versions), kib<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp; &nbsp; &nbsp; &n=
bsp; Sponsored by:&nbsp; Stormshield<br></div><div dir=3D"ltr">&gt;&nbsp; &=
nbsp; &nbsp; &nbsp; &nbsp; Sponsored by:&nbsp; Klara, Inc.<br></div><div di=
r=3D"ltr">&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Differential Revision: <a =
href=3D"https://reviews.freebsd.org/D32306" rel=3D"nofollow" target=3D"_bla=
nk">https://reviews.freebsd.org/D32306</a><br></div><div dir=3D"ltr">&gt;&n=
bsp; &nbsp;  &lt;<a href=3D"https://reviews.freebsd.org/D32306" rel=3D"nofo=
llow" target=3D"_blank">https://reviews.freebsd.org/D32306</a>&gt;<br></div=
><div dir=3D"ltr">&gt;&nbsp; &nbsp;  ---<br></div><div dir=3D"ltr">&gt;&nbs=
p; &nbsp;  etc/mtree/BSD.include.dist&nbsp; &nbsp; &nbsp; &nbsp; |&nbsp; 2 =
+<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  include/Makefile&nbsp; &nbsp=
; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; |&nbsp; 2 +-<br></div><d=
iv dir=3D"ltr">&gt;&nbsp; &nbsp;  include/ssp/Makefile&nbsp; &nbsp; &nbsp; =
&nbsp; &nbsp; &nbsp; &nbsp; |&nbsp; 6 ++<br></div><div dir=3D"ltr">&gt;&nbs=
p; &nbsp;  include/ssp/ssp.h&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp=
; &nbsp; &nbsp; |&nbsp; 91 ++++++++++++++++++++++++++<br></div><div dir=3D"=
ltr">&gt;&nbsp; &nbsp;  include/ssp/stdio.h&nbsp; &nbsp; &nbsp; &nbsp; &nbs=
p; &nbsp; &nbsp; &nbsp; |&nbsp; 93 ++++++++++++++++++++++++++<br></div><div=
 dir=3D"ltr">&gt;&nbsp; &nbsp;  include/ssp/string.h&nbsp; &nbsp; &nbsp; &n=
bsp; &nbsp; &nbsp; &nbsp; | 129<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;=
  ++++++++++++++++++++++++++++++++++++<br></div><div dir=3D"ltr">&gt;&nbsp;=
 &nbsp;  include/ssp/strings.h&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nb=
sp; |&nbsp; 67 +++++++++++++++++++<br></div><div dir=3D"ltr">&gt;&nbsp; &nb=
sp;  include/ssp/unistd.h&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; |=
&nbsp; 54 +++++++++++++++<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  lib/=
libc/secure/Makefile.inc&nbsp; &nbsp; &nbsp; |&nbsp; 11 ++++<br></div><div =
dir=3D"ltr">&gt;&nbsp; &nbsp;  lib/libc/secure/Symbol.map&nbsp; &nbsp; &nbs=
p; &nbsp; |&nbsp; 18 +++++<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  lib=
/libc/secure/fgets_chk.c&nbsp; &nbsp; &nbsp; &nbsp; |&nbsp; 54 ++++++++++++=
+++<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  lib/libc/secure/gets_chk.c=
&nbsp; &nbsp; &nbsp; &nbsp; |&nbsp; 74 +++++++++++++++++++++<br></div><div =
dir=3D"ltr">&gt;&nbsp; &nbsp;  lib/libc/secure/memcpy_chk.c&nbsp; &nbsp; &n=
bsp; |&nbsp; 53 +++++++++++++++<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;=
  lib/libc/secure/memmove_chk.c&nbsp; &nbsp; &nbsp; |&nbsp; 47 ++++++++++++=
+<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  lib/libc/secure/memset_chk.c=
&nbsp; &nbsp; &nbsp; |&nbsp; 46 +++++++++++++<br></div><div dir=3D"ltr">&gt=
;&nbsp; &nbsp;  lib/libc/secure/snprintf_chk.c&nbsp; &nbsp; |&nbsp; 56 ++++=
++++++++++++<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  lib/libc/secure/s=
printf_chk.c&nbsp; &nbsp; &nbsp; |&nbsp; 61 +++++++++++++++++<br></div><div=
 dir=3D"ltr">&gt;&nbsp; &nbsp;  lib/libc/secure/ssp_internal.h&nbsp; &nbsp;=
 |&nbsp; 37 +++++++++++<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  lib/li=
bc/secure/stpcpy_chk.c&nbsp; &nbsp; &nbsp; |&nbsp; 55 ++++++++++++++++<br><=
/div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  lib/libc/secure/stpncpy_chk.c&nbsp=
; &nbsp; &nbsp; |&nbsp; 53 +++++++++++++++<br></div><div dir=3D"ltr">&gt;&n=
bsp; &nbsp;  lib/libc/secure/strcat_chk.c&nbsp; &nbsp; &nbsp; |&nbsp; 60 ++=
+++++++++++++++<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  lib/libc/secur=
e/strcpy_chk.c&nbsp; &nbsp; &nbsp; |&nbsp; 54 +++++++++++++++<br></div><div=
 dir=3D"ltr">&gt;&nbsp; &nbsp;  lib/libc/secure/strncat_chk.c&nbsp; &nbsp; =
&nbsp; |&nbsp; 70 ++++++++++++++++++++<br></div><div dir=3D"ltr">&gt;&nbsp;=
 &nbsp;  lib/libc/secure/strncpy_chk.c&nbsp; &nbsp; &nbsp; |&nbsp; 53 +++++=
++++++++++<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  lib/libc/secure/vsn=
printf_chk.c&nbsp; &nbsp; |&nbsp; 49 ++++++++++++++<br></div><div dir=3D"lt=
r">&gt;&nbsp; &nbsp;  lib/libc/secure/vsprintf_chk.c&nbsp; &nbsp; |&nbsp; 5=
8 ++++++++++++++++<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  lib/libssp/=
Makefile&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; |&nbsp; 20 =
+++++-<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  lib/libssp/Symbol.map&n=
bsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; |&nbsp; 12 ++--<br></div><di=
v dir=3D"ltr">&gt;&nbsp; &nbsp;  lib/libssp/Versions.def&nbsp; &nbsp; &nbsp=
; &nbsp; &nbsp; &nbsp; |&nbsp; 5 ++<br></div><div dir=3D"ltr">&gt;&nbsp; &n=
bsp;  lib/libssp/__builtin_object_size.3 | 110 ++++++++++++++++++++++++++++=
+++<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  lib/libssp/fortify_stubs.c=
&nbsp; &nbsp; &nbsp; &nbsp; | 131<br></div><div dir=3D"ltr">&gt;&nbsp; &nbs=
p;  -------------------------------------<br></div><div dir=3D"ltr">&gt;&nb=
sp; &nbsp;  lib/libssp/ssp.3&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp=
; &nbsp; &nbsp; | 130<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  ++++++++=
++++++++++++++++++++++++++++<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  3=
2 files changed, 1621 insertions(+), 140 deletions(-)<br></div><div dir=3D"=
ltr">&gt; <br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  diff --git a/etc/mt=
ree/BSD.include.dist b/etc/mtree/BSD.include.dist<br></div><div dir=3D"ltr"=
>&gt;&nbsp; &nbsp;  index a6bd5880bf61..f8c83d6dde7a 100644<br></div><div d=
ir=3D"ltr">&gt;&nbsp; &nbsp;  --- a/etc/mtree/BSD.include.dist<br></div><di=
v dir=3D"ltr">&gt;&nbsp; &nbsp;  +++ b/etc/mtree/BSD.include.dist<br></div>=
<div dir=3D"ltr">&gt;&nbsp; &nbsp;  @@ -372,6 +372,8 @@<br></div><div dir=
=3D"ltr">&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mac_veriexec<=
br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nb=
sp; ..<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ..<=
br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +&nbsp; &nbsp; ssp<br></div><d=
iv dir=3D"ltr">&gt;&nbsp; &nbsp;  +&nbsp; &nbsp; ..<br></div><div dir=3D"lt=
r">&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sys<br></div><div dir=3D"ltr">&gt=
;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; disk<br></div><div dir=3D=
"ltr">&gt;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ..<br></div><div=
 dir=3D"ltr">&gt;&nbsp; &nbsp;  diff --git a/include/Makefile b/include/Mak=
efile<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  index 19e6beb95203..3277=
4419f162 100644<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  --- a/include/=
Makefile<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +++ b/include/Makefil=
e<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  @@ -4,7 +4,7 @@<br></div><di=
v dir=3D"ltr">&gt; <br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  PACKAGE=3D=
clibs<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  CLEANFILES=3D osreldate.=
h version<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  -SUBDIR=3D arpa prot=
ocols rpcsvc rpc xlocale<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +SUBD=
IR=3D arpa protocols rpcsvc rpc ssp xlocale<br></div><div dir=3D"ltr">&gt;&=
nbsp; &nbsp;  .if ${MACHINE_CPUARCH} =3D=3D "amd64"<br></div><div dir=3D"lt=
r">&gt;&nbsp; &nbsp;  SUBDIR+=3D&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; i386<=
br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  INCLUDE_SUBDIRS+=3D&nbsp;&nbsp=
;&nbsp; i386<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  diff --git a/incl=
ude/ssp/Makefile b/include/ssp/Makefile<br></div><div dir=3D"ltr">&gt;&nbsp=
; &nbsp;  new file mode 100644<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp; =
 index 000000000000..dff19f43c920<br></div><div dir=3D"ltr">&gt;&nbsp; &nbs=
p;  --- /dev/null<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +++ b/includ=
e/ssp/Makefile<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  @@ -0,0 +1,6 @@=
<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +# $FreeBSD$<br></div><div di=
r=3D"ltr">&gt;&nbsp; &nbsp;  +<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp; =
 +INCS=3D&nbsp;&nbsp;&nbsp; ssp.h stdio.h string.h strings.h unistd.h<br></=
div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +INCSDIR=3D&nbsp;&nbsp;&nbsp; ${INC=
LUDEDIR}/ssp<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +<br></div><div d=
ir=3D"ltr">&gt;&nbsp; &nbsp;  +.include &lt;bsd.prog.mk&gt;<br></div><div d=
ir=3D"ltr">&gt;&nbsp; &nbsp;  diff --git a/include/ssp/ssp.h b/include/ssp/=
ssp.h<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  new file mode 100644<br>=
</div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  index 000000000000..35a9aeee02df<=
br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  --- /dev/null<br></div><div di=
r=3D"ltr">&gt;&nbsp; &nbsp;  +++ b/include/ssp/ssp.h<br></div><div dir=3D"l=
tr">&gt;&nbsp; &nbsp;  @@ -0,0 +1,91 @@<br></div><div dir=3D"ltr">&gt;&nbsp=
; &nbsp;  +/*&nbsp;&nbsp;&nbsp; $NetBSD: ssp.h,v 1.13 2015/09/03 20:43:47 p=
lunky Exp $&nbsp;&nbsp;&nbsp; */<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp=
;  +<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +/*-<br></div><div dir=3D=
"ltr">&gt;&nbsp; &nbsp;  + *<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +=
 * SPDX-License-Identifier: BSD-2-Clause<br></div><div dir=3D"ltr">&gt;&nbs=
p; &nbsp;  + *<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + * Copyright (=
c) 2006, 2011 The NetBSD Foundation, Inc.<br></div><div dir=3D"ltr">&gt;&nb=
sp; &nbsp;  + * All rights reserved.<br></div><div dir=3D"ltr">&gt;&nbsp; &=
nbsp;  + *<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + * This code is de=
rived from software contributed to The NetBSD<br></div><div dir=3D"ltr">&gt=
;&nbsp; &nbsp;  Foundation<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + *=
 by Christos Zoulas.<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + *<br></=
div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + * Redistribution and use in sourc=
e and binary forms, with or without<br></div><div dir=3D"ltr">&gt;&nbsp; &n=
bsp;  + * modification, are permitted provided that the following condition=
s<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + * are met:<br></div><div d=
ir=3D"ltr">&gt;&nbsp; &nbsp;  + * 1. Redistributions of source code must re=
tain the above copyright<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + *&n=
bsp; &nbsp; notice, this list of conditions and the following disclaimer.<b=
r></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + * 2. Redistributions in binar=
y form must reproduce the above copyright<br></div><div dir=3D"ltr">&gt;&nb=
sp; &nbsp;  + *&nbsp; &nbsp; notice, this list of conditions and the follow=
ing disclaimer<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  in the<br></div=
><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + *&nbsp; &nbsp; documentation and/or =
other materials provided with the<br></div><div dir=3D"ltr">&gt;&nbsp; &nbs=
p;  distribution.<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + *<br></div=
><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + * THIS SOFTWARE IS PROVIDED BY THE N=
ETBSD FOUNDATION, INC. AND<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  CON=
TRIBUTORS<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + * ``AS IS'' AND AN=
Y EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT<br></div><div dir=3D"ltr">&=
gt;&nbsp; &nbsp;  NOT LIMITED<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  =
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A<br></di=
v><div dir=3D"ltr">&gt;&nbsp; &nbsp;  PARTICULAR<br></div><div dir=3D"ltr">=
&gt;&nbsp; &nbsp;  + * PURPOSE ARE DISCLAIMED.&nbsp; IN NO EVENT SHALL THE =
FOUNDATION OR<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  CONTRIBUTORS<br>=
</div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + * BE LIABLE FOR ANY DIRECT, IND=
IRECT, INCIDENTAL, SPECIAL,<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  EX=
EMPLARY, OR<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + * CONSEQUENTIAL =
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF<br></div><div dir=3D=
"ltr">&gt;&nbsp; &nbsp;  + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DAT=
A, OR PROFITS; OR<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  BUSINESS<br>=
</div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + * INTERRUPTION) HOWEVER CAUSED =
AND ON ANY THEORY OF LIABILITY,<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;=
  WHETHER IN<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + * CONTRACT, STR=
ICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR<br></div><div dir=3D"ltr">&=
gt;&nbsp; &nbsp;  OTHERWISE)<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +=
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF<br></div><di=
v dir=3D"ltr">&gt;&nbsp; &nbsp;  ADVISED OF THE<br></div><div dir=3D"ltr">&=
gt;&nbsp; &nbsp;  + * POSSIBILITY OF SUCH DAMAGE.<br></div><div dir=3D"ltr"=
>&gt;&nbsp; &nbsp;  + */<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +#ifn=
def _SSP_SSP_H_<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +#define _SSP_=
SSP_H_<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +<br></div><div dir=3D"=
ltr">&gt;&nbsp; &nbsp;  +#include &lt;sys/cdefs.h&gt;<br></div><div dir=3D"=
ltr">&gt;&nbsp; &nbsp;  +<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +#if=
 !defined(__cplusplus)<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +# if d=
efined(_FORTIFY_SOURCE) &amp;&amp; _FORTIFY_SOURCE &gt; 0 &amp;&amp; \<br><=
/div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +&nbsp; &nbsp; (__OPTIMIZE__ &gt; =
0 || defined(__clang__))<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +#&nb=
sp; if _FORTIFY_SOURCE &gt; 1<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  =
+#&nbsp; define __SSP_FORTIFY_LEVEL 2<br></div><div dir=3D"ltr">&gt;&nbsp; =
&nbsp;  +#&nbsp; else<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +#&nbsp;=
 define __SSP_FORTIFY_LEVEL 1<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  =
+#&nbsp; endif<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +# else<br></di=
v><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +#&nbsp; define __SSP_FORTIFY_LEVEL 0=
<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +# endif<br></div><div dir=3D=
"ltr">&gt;&nbsp; &nbsp;  +#else<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;=
  +# define __SSP_FORTIFY_LEVEL 0<br></div><div dir=3D"ltr">&gt;&nbsp; &nbs=
p;  +#endif<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +<br></div><div di=
r=3D"ltr">&gt;&nbsp; &nbsp;  +#define&nbsp;&nbsp;&nbsp; __ssp_var(type)&nbs=
p;&nbsp;&nbsp; __CONCAT(__ssp_ ## type, __COUNTER__)<br></div><div dir=3D"l=
tr">&gt;&nbsp; &nbsp;  +<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +/* _=
_ssp_real is used by the implementation in libc */<br></div><div dir=3D"ltr=
">&gt;&nbsp; &nbsp;  +#if __SSP_FORTIFY_LEVEL =3D=3D 0<br></div><div dir=3D=
"ltr">&gt;&nbsp; &nbsp;  +#define __ssp_real_(fun)&nbsp;&nbsp;&nbsp; fun<br=
></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +#else<br></div><div dir=3D"ltr"=
>&gt;&nbsp; &nbsp;  +#define __ssp_real_(fun)&nbsp;&nbsp;&nbsp; __ssp_real_=
 ## fun<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +#endif<br></div><div =
dir=3D"ltr">&gt;&nbsp; &nbsp;  +#define __ssp_real(fun)&nbsp;&nbsp;&nbsp; &=
nbsp;&nbsp;&nbsp; __ssp_real_(fun)<br></div><div dir=3D"ltr">&gt;&nbsp; &nb=
sp;  +<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +#define __ssp_inline s=
tatic __inline __attribute__((__always_inline__))<br></div><div dir=3D"ltr"=
>&gt;&nbsp; &nbsp;  +<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +#define=
 __ssp_bos(ptr) __builtin_object_size(ptr,<br></div><div dir=3D"ltr">&gt;&n=
bsp; &nbsp;  __SSP_FORTIFY_LEVEL &gt; 1)<br></div><div dir=3D"ltr">&gt;&nbs=
p; &nbsp;  +#define __ssp_bos0(ptr) __builtin_object_size(ptr, 0)<br></div>=
<div dir=3D"ltr">&gt;&nbsp; &nbsp;  +<br></div><div dir=3D"ltr">&gt;&nbsp; =
&nbsp;  +#define __ssp_check(buf, len, bos) \<br></div><div dir=3D"ltr">&gt=
;&nbsp; &nbsp;  +&nbsp;&nbsp;&nbsp; if (bos(buf) !=3D (size_t)-1 &amp;&amp;=
 len &gt; bos(buf)) \<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +&nbsp;&=
nbsp;&nbsp; &nbsp;&nbsp;&nbsp; __chk_fail()<br></div><div dir=3D"ltr">&gt;&=
nbsp; &nbsp;  +#define __ssp_redirect_raw(rtype, fun, symbol, args, call, c=
ond, bos) \<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +rtype __ssp_real_=
(fun) args __RENAME(symbol); \<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp; =
 +__ssp_inline rtype fun args __RENAME(__ssp_protected_ ## fun); \<br></div=
><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +__ssp_inline rtype fun args { \<br></=
div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +&nbsp;&nbsp;&nbsp; if (cond) \<br>=
</div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&=
nbsp; __ssp_check(__buf, __len, bos); \<br></div><div dir=3D"ltr">&gt;&nbsp=
; &nbsp;  +&nbsp;&nbsp;&nbsp; return __ssp_real_(fun) call; \<br></div><div=
 dir=3D"ltr">&gt;&nbsp; &nbsp;  +}<br></div><div dir=3D"ltr">&gt;&nbsp; &nb=
sp;  +<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +#define __ssp_redirect=
(rtype, fun, args, call) \<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +&n=
bsp; &nbsp; __ssp_redirect_raw(rtype, fun, fun, args, call, 1, __ssp_bos)<b=
r></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +#define __ssp_redirect0(rtype,=
 fun, args, call) \<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +&nbsp; &n=
bsp; __ssp_redirect_raw(rtype, fun, fun, args, call, 1, __ssp_bos0)<br></di=
v><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +<br></div><div dir=3D"ltr">&gt;&nbsp=
; &nbsp;  +__BEGIN_DECLS<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +void=
 __stack_chk_fail(void) __dead2;<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp=
;  +void __chk_fail(void) __dead2;<br></div><div dir=3D"ltr">&gt;&nbsp; &nb=
sp;  +__END_DECLS<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +<br></div><=
div dir=3D"ltr">&gt;&nbsp; &nbsp;  +#endif /* _SSP_SSP_H_ */<br></div><div =
dir=3D"ltr">&gt;&nbsp; &nbsp;  diff --git a/include/ssp/stdio.h b/include/s=
sp/stdio.h<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  new file mode 10064=
4<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  index 000000000000..72e3236e=
ac80<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  --- /dev/null<br></div><d=
iv dir=3D"ltr">&gt;&nbsp; &nbsp;  +++ b/include/ssp/stdio.h<br></div><div d=
ir=3D"ltr">&gt;&nbsp; &nbsp;  @@ -0,0 +1,93 @@<br></div><div dir=3D"ltr">&g=
t;&nbsp; &nbsp;  +/*&nbsp;&nbsp;&nbsp; $NetBSD: stdio.h,v 1.5 2011/07/17 20=
:54:34 joerg Exp $&nbsp;&nbsp;&nbsp; */<br></div><div dir=3D"ltr">&gt;&nbsp=
; &nbsp;  +<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +/*-<br></div><div=
 dir=3D"ltr">&gt;&nbsp; &nbsp;  + *<br></div><div dir=3D"ltr">&gt;&nbsp; &n=
bsp;  + * SPDX-License-Identifier: BSD-2-Clause<br></div><div dir=3D"ltr">&=
gt;&nbsp; &nbsp;  + *<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + * Copy=
right (c) 2006 The NetBSD Foundation, Inc.<br></div><div dir=3D"ltr">&gt;&n=
bsp; &nbsp;  + * All rights reserved.<br></div><div dir=3D"ltr">&gt;&nbsp; =
&nbsp;  + *<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + * This code is d=
erived from software contributed to The NetBSD<br></div><div dir=3D"ltr">&g=
t;&nbsp; &nbsp;  Foundation<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + =
* by Christos Zoulas.<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + *<br><=
/div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + * Redistribution and use in sour=
ce and binary forms, with or without<br></div><div dir=3D"ltr">&gt;&nbsp; &=
nbsp;  + * modification, are permitted provided that the following conditio=
ns<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + * are met:<br></div><div =
dir=3D"ltr">&gt;&nbsp; &nbsp;  + * 1. Redistributions of source code must r=
etain the above copyright<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + *&=
nbsp; &nbsp; notice, this list of conditions and the following disclaimer.<=
br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + * 2. Redistributions in bina=
ry form must reproduce the above copyright<br></div><div dir=3D"ltr">&gt;&n=
bsp; &nbsp;  + *&nbsp; &nbsp; notice, this list of conditions and the follo=
wing disclaimer<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  in the<br></di=
v><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + *&nbsp; &nbsp; documentation and/or=
 other materials provided with the<br></div><div dir=3D"ltr">&gt;&nbsp; &nb=
sp;  distribution.<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + *<br></di=
v><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + * THIS SOFTWARE IS PROVIDED BY THE =
NETBSD FOUNDATION, INC. AND<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  CO=
NTRIBUTORS<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + * ``AS IS'' AND A=
NY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT<br></div><div dir=3D"ltr">=
&gt;&nbsp; &nbsp;  NOT LIMITED<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp; =
 + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A<br></d=
iv><div dir=3D"ltr">&gt;&nbsp; &nbsp;  PARTICULAR<br></div><div dir=3D"ltr"=
>&gt;&nbsp; &nbsp;  + * PURPOSE ARE DISCLAIMED.&nbsp; IN NO EVENT SHALL THE=
 FOUNDATION OR<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  CONTRIBUTORS<br=
></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + * BE LIABLE FOR ANY DIRECT, IN=
DIRECT, INCIDENTAL, SPECIAL,<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  E=
XEMPLARY, OR<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + * CONSEQUENTIAL=
 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF<br></div><div dir=
=3D"ltr">&gt;&nbsp; &nbsp;  + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, =
DATA, OR PROFITS; OR<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  BUSINESS<=
br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + * INTERRUPTION) HOWEVER CAUS=
ED AND ON ANY THEORY OF LIABILITY,<br></div><div dir=3D"ltr">&gt;&nbsp; &nb=
sp;  WHETHER IN<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + * CONTRACT, =
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR<br></div><div dir=3D"ltr=
">&gt;&nbsp; &nbsp;  OTHERWISE)<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;=
  + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF<br></div>=
<div dir=3D"ltr">&gt;&nbsp; &nbsp;  ADVISED OF THE<br></div><div dir=3D"ltr=
">&gt;&nbsp; &nbsp;  + * POSSIBILITY OF SUCH DAMAGE.<br></div><div dir=3D"l=
tr">&gt;&nbsp; &nbsp;  + */<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +#=
ifndef _SSP_STDIO_H_<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +#define =
_SSP_STDIO_H_<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +<br></div><div =
dir=3D"ltr">&gt;&nbsp; &nbsp;  +#include &lt;ssp/ssp.h&gt;<br></div><div di=
r=3D"ltr">&gt;&nbsp; &nbsp;  +<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp; =
 +__BEGIN_DECLS<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +int __sprintf=
_chk(char *__restrict, int, size_t, const char<br></div><div dir=3D"ltr">&g=
t;&nbsp; &nbsp;  *__restrict, ...)<br></div><div dir=3D"ltr">&gt;&nbsp; &nb=
sp;  +&nbsp; &nbsp; __printflike(4, 5);<br></div><div dir=3D"ltr">&gt;&nbsp=
; &nbsp;  +int __vsprintf_chk(char *__restrict, int, size_t, const char<br>=
</div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  *__restrict,<br></div><div dir=3D=
"ltr">&gt;&nbsp; &nbsp;  +&nbsp; &nbsp; __va_list)<br></div><div dir=3D"ltr=
">&gt;&nbsp; &nbsp;  +&nbsp; &nbsp; __printflike(4, 0);<br></div><div dir=
=3D"ltr">&gt;&nbsp; &nbsp;  +int __snprintf_chk(char *__restrict, size_t, i=
nt, size_t,<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +&nbsp; &nbsp; con=
st char *__restrict, ...)<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +&nb=
sp; &nbsp; __printflike(5, 6);<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp; =
 +int __vsnprintf_chk(char *__restrict, size_t, int, size_t,<br></div><div =
dir=3D"ltr">&gt;&nbsp; &nbsp;  +&nbsp; &nbsp; const char *__restrict, __va_=
list)<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +&nbsp; &nbsp; __printfl=
ike(5, 0);<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +char *__gets_chk(c=
har *, size_t);<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +char *__fgets=
_chk(char *, int, size_t, FILE *);<br></div><div dir=3D"ltr">&gt;&nbsp; &nb=
sp;  +__END_DECLS<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +<br></div><=
div dir=3D"ltr">&gt;&nbsp; &nbsp;  +#if __SSP_FORTIFY_LEVEL &gt; 0<br></div=
><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +<br></div><div dir=3D"ltr">&gt;&nbsp;=
 &nbsp;  +#define sprintf(str, ...) ({&nbsp;&nbsp;&nbsp; \<br></div><div di=
r=3D"ltr">&gt;&nbsp; &nbsp;  +&nbsp; &nbsp; char *_ssp_str =3D (str);&nbsp;=
&nbsp;&nbsp; \<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +&nbsp; &nbsp; =
__builtin___sprintf_chk(_ssp_str, 0, __ssp_bos(_ssp_str),&nbsp;&nbsp;&nbsp;=
 &nbsp;&nbsp;&nbsp; \<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +&nbsp; =
&nbsp; &nbsp; &nbsp; __VA_ARGS__); \<br></div><div dir=3D"ltr">&gt;&nbsp; &=
nbsp;  +})<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +<br></div><div dir=
=3D"ltr">&gt;&nbsp; &nbsp;  +#define vsprintf(str, fmt, ap) ({&nbsp;&nbsp;&=
nbsp; \<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +&nbsp; &nbsp; char *_=
ssp_str =3D (str);&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; \<br></div><div dir=
=3D"ltr">&gt;&nbsp; &nbsp;  +&nbsp; &nbsp; __builtin___vsprintf_chk(_ssp_st=
r, 0, __ssp_bos(_ssp_str),<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  fmt=
,&nbsp;&nbsp;&nbsp; \<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +&nbsp; =
&nbsp; &nbsp; &nbsp; ap);&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;=
&nbsp; &nbsp;&nbsp;&nbsp; \<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +}=
)<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +<br></div><div dir=3D"ltr">=
&gt;&nbsp; &nbsp;  +#define snprintf(str, len, ...) ({&nbsp;&nbsp;&nbsp; \<=
br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +&nbsp; &nbsp; char *_ssp_str =
=3D (str);&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; \<br></div><div dir=3D"ltr"=
>&gt;&nbsp; &nbsp;  +&nbsp; &nbsp; __builtin___snprintf_chk(_ssp_str, len, =
0,<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  __ssp_bos(_ssp_str),&nbsp;&=
nbsp;&nbsp; \<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +&nbsp; &nbsp; &=
nbsp; &nbsp; __VA_ARGS__);&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp=
;&nbsp; \<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +})<br></div><div di=
r=3D"ltr">&gt;&nbsp; &nbsp;  +<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp; =
 +#define vsnprintf(str, len, fmt, ap) ({&nbsp;&nbsp;&nbsp; \<br></div><div=
 dir=3D"ltr">&gt;&nbsp; &nbsp;  +&nbsp; &nbsp; char *_ssp_str =3D (str);&nb=
sp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; \<br></div><div dir=3D"ltr">&gt;&nbsp; &=
nbsp;  +&nbsp; &nbsp; __builtin___vsnprintf_chk(_ssp_str, len, 0,<br></div>=
<div dir=3D"ltr">&gt;&nbsp; &nbsp;  __ssp_bos(_ssp_str),&nbsp;&nbsp;&nbsp; =
\<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +&nbsp; &nbsp; &nbsp; &nbsp;=
 fmt, ap);&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; \<br></d=
iv><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +})<br></div><div dir=3D"ltr">&gt;&n=
bsp; &nbsp;  +<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +#define gets(s=
tr) ({&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; \<br></div><=
div dir=3D"ltr">&gt;&nbsp; &nbsp;  +&nbsp; char *_ssp_str =3D (str);&nbsp;&=
nbsp;&nbsp; &nbsp;&nbsp;&nbsp; \<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp=
;  +&nbsp; &nbsp; __gets_chk(_ssp_str, __ssp_bos(_ssp_str));&nbsp;&nbsp;&nb=
sp; \<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +})<br></div><div dir=3D=
"ltr">&gt;&nbsp; &nbsp;  +<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +#d=
efine fgets(str, len, fp) ({&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; \<br></di=
v><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +&nbsp; &nbsp; char *_ssp_str =3D (st=
r);&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; \<br></div><div dir=3D"ltr">&gt;&n=
bsp; &nbsp;  +&nbsp; &nbsp; __fgets_chk(_ssp_str, len, __ssp_bos(_ssp_str),=
 fp);&nbsp;&nbsp;&nbsp; \<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +})<=
br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +<br></div><div dir=3D"ltr">&g=
t;&nbsp; &nbsp;  +#endif /* __SSP_FORTIFY_LEVEL &gt; 0 */<br></div><div dir=
=3D"ltr">&gt;&nbsp; &nbsp;  +<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  =
+#endif /* _SSP_STDIO_H_ */<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  di=
ff --git a/include/ssp/string.h b/include/ssp/string.h<br></div><div dir=3D=
"ltr">&gt;&nbsp; &nbsp;  new file mode 100644<br></div><div dir=3D"ltr">&gt=
;&nbsp; &nbsp;  index 000000000000..996020fda778<br></div><div dir=3D"ltr">=
&gt;&nbsp; &nbsp;  --- /dev/null<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp=
;  +++ b/include/ssp/string.h<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  =
@@ -0,0 +1,129 @@<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +/*&nbsp;&nb=
sp;&nbsp; $NetBSD: string.h,v 1.14 2020/09/05 13:37:59 mrg Exp $&nbsp;&nbsp=
;&nbsp; */<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +<br></div><div dir=
=3D"ltr">&gt;&nbsp; &nbsp;  +/*-<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp=
;  + *<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + * SPDX-License-Identi=
fier: BSD-2-Clause<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + *<br></di=
v><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + * Copyright (c) 2006 The NetBSD Fou=
ndation, Inc.<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + * All rights r=
eserved.<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + *<br></div><div dir=
=3D"ltr">&gt;&nbsp; &nbsp;  + * This code is derived from software contribu=
ted to The NetBSD<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  Foundation<b=
r></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + * by Christos Zoulas.<br></di=
v><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + *<br></div><div dir=3D"ltr">&gt;&nb=
sp; &nbsp;  + * Redistribution and use in source and binary forms, with or =
without<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + * modification, are =
permitted provided that the following conditions<br></div><div dir=3D"ltr">=
&gt;&nbsp; &nbsp;  + * are met:<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;=
  + * 1. Redistributions of source code must retain the above copyright<br>=
</div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + *&nbsp; &nbsp; notice, this lis=
t of conditions and the following disclaimer.<br></div><div dir=3D"ltr">&gt=
;&nbsp; &nbsp;  + * 2. Redistributions in binary form must reproduce the ab=
ove copyright<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + *&nbsp; &nbsp;=
 notice, this list of conditions and the following disclaimer<br></div><div=
 dir=3D"ltr">&gt;&nbsp; &nbsp;  in the<br></div><div dir=3D"ltr">&gt;&nbsp;=
 &nbsp;  + *&nbsp; &nbsp; documentation and/or other materials provided wit=
h the<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  distribution.<br></div><=
div dir=3D"ltr">&gt;&nbsp; &nbsp;  + *<br></div><div dir=3D"ltr">&gt;&nbsp;=
 &nbsp;  + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND<b=
r></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  CONTRIBUTORS<br></div><div dir=
=3D"ltr">&gt;&nbsp; &nbsp;  + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRAN=
TIES, INCLUDING, BUT<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  NOT LIMIT=
ED<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + * TO, THE IMPLIED WARRANT=
IES OF MERCHANTABILITY AND FITNESS FOR A<br></div><div dir=3D"ltr">&gt;&nbs=
p; &nbsp;  PARTICULAR<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + * PURP=
OSE ARE DISCLAIMED.&nbsp; IN NO EVENT SHALL THE FOUNDATION OR<br></div><div=
 dir=3D"ltr">&gt;&nbsp; &nbsp;  CONTRIBUTORS<br></div><div dir=3D"ltr">&gt;=
&nbsp; &nbsp;  + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,=
<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  EXEMPLARY, OR<br></div><div d=
ir=3D"ltr">&gt;&nbsp; &nbsp;  + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT=
 LIMITED TO, PROCUREMENT OF<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + =
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR<br></div>=
<div dir=3D"ltr">&gt;&nbsp; &nbsp;  BUSINESS<br></div><div dir=3D"ltr">&gt;=
&nbsp; &nbsp;  + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABIL=
ITY,<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  WHETHER IN<br></div><div =
dir=3D"ltr">&gt;&nbsp; &nbsp;  + * CONTRACT, STRICT LIABILITY, OR TORT (INC=
LUDING NEGLIGENCE OR<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  OTHERWISE=
)<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + * ARISING IN ANY WAY OUT O=
F THE USE OF THIS SOFTWARE, EVEN IF<br></div><div dir=3D"ltr">&gt;&nbsp; &n=
bsp;  ADVISED OF THE<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + * POSSI=
BILITY OF SUCH DAMAGE.<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + */<br=
></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +#ifndef _SSP_STRING_H_<br></div=
><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +#define _SSP_STRING_H_<br></div><div =
dir=3D"ltr">&gt;&nbsp; &nbsp;  +<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp=
;  +#include &lt;ssp/ssp.h&gt;<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp; =
 +<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +__BEGIN_DECLS<br></div><di=
v dir=3D"ltr">&gt;&nbsp; &nbsp;  +void *__memcpy_chk(void *, const void *, =
size_t, size_t);<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +void *__memm=
ove_chk(void *, const void *, size_t, size_t);<br></div><div dir=3D"ltr">&g=
t;&nbsp; &nbsp;  +void *__memset_chk(void *, int, size_t, size_t);<br></div=
><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +char *__stpcpy_chk(char *, const char=
 *, size_t);<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +char *__stpncpy_=
chk(char *, const char *, size_t, size_t);<br></div><div dir=3D"ltr">&gt;&n=
bsp; &nbsp;  +char *__strcat_chk(char *, const char *, size_t);<br></div><d=
iv dir=3D"ltr">&gt;&nbsp; &nbsp;  +char *__strcpy_chk(char *, const char *,=
 size_t);<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +char *__strncat_chk=
(char *, const char *, size_t, size_t);<br></div><div dir=3D"ltr">&gt;&nbsp=
; &nbsp;  +char *__strncpy_chk(char *, const char *, size_t, size_t);<br></=
div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +__END_DECLS<br></div><div dir=3D"l=
tr">&gt;&nbsp; &nbsp;  +<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +#if =
__SSP_FORTIFY_LEVEL &gt; 0<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +<b=
r></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +#define __ssp_bos_check3_typed=
_var(fun, dsttype, dsrvar, dst,<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;=
  srctype, srcvar, \<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +&nbsp; &=
nbsp; src, lenvar, len) ({&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp=
;&nbsp; &nbsp;&nbsp;&nbsp; \<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +=
&nbsp; &nbsp; srctype srcvar =3D (src);&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp=
; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; \<br></div><div dir=3D"ltr">&gt;&nb=
sp; &nbsp;  +&nbsp; &nbsp; dsttype dstvar =3D (dst);&nbsp;&nbsp;&nbsp; &nbs=
p;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; \<br></div><div dir=3D=
"ltr">&gt;&nbsp; &nbsp;  +&nbsp; &nbsp; size_t lenvar =3D (len);&nbsp;&nbsp=
;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; \<br></div=
><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +&nbsp; &nbsp; ((__ssp_bos0(dstvar) !=
=3D (size_t)-1) ?&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; \<br></div><div dir=
=3D"ltr">&gt;&nbsp; &nbsp;  +&nbsp; &nbsp; __builtin___ ## fun ## _chk(dstv=
ar, srcvar, lenvar,&nbsp;&nbsp;&nbsp; \<br></div><div dir=3D"ltr">&gt;&nbsp=
; &nbsp;  +&nbsp; &nbsp; &nbsp; &nbsp; __ssp_bos0(dstvar)) :&nbsp;&nbsp;&nb=
sp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; \<br></div><di=
v dir=3D"ltr">&gt;&nbsp; &nbsp;  +&nbsp; &nbsp; __ ## fun ## _ichk(dstvar, =
srcvar, lenvar));&nbsp;&nbsp;&nbsp; \<br></div><div dir=3D"ltr">&gt;&nbsp; =
&nbsp;  +})<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +<br></div><div di=
r=3D"ltr">&gt;&nbsp; &nbsp;  +#define __ssp_bos_check3_typed(fun, dsttype, =
dst, srctype, src,<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  len)&nbsp;&=
nbsp;&nbsp; \<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +&nbsp; &nbsp; _=
_ssp_bos_check3_typed_var(fun, dsttype, __ssp_var(dstv), dst,&nbsp;&nbsp;&n=
bsp; \<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +&nbsp; &nbsp; &nbsp; &=
nbsp; srctype, __ssp_var(srcv), src, __ssp_var(lenv), len)<br></div><div di=
r=3D"ltr">&gt;&nbsp; &nbsp;  +<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp; =
 +#define __ssp_bos_check3(fun, dst, src, len)&nbsp;&nbsp;&nbsp; &nbsp;&nbs=
p;&nbsp; \<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +&nbsp; &nbsp; __ss=
p_bos_check3_typed_var(fun, void *, __ssp_var(dstv), dst,&nbsp;&nbsp;&nbsp;=
 \<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +&nbsp; &nbsp; &nbsp; &nbsp=
; const void *, __ssp_var(srcv), src, __ssp_var(lenv), len)<br></div><div d=
ir=3D"ltr">&gt;&nbsp; &nbsp;  +<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;=
  +#define __ssp_bos_check2_var(fun, dstvar, dst, srcvar, src) ({&nbsp;&nbs=
p;&nbsp; &nbsp;&nbsp;&nbsp; \<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  =
+&nbsp; &nbsp; const void *srcvar =3D (src);&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;=
&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; \<br></div><div dir=3D"ltr">&g=
t;&nbsp; &nbsp;  +&nbsp; &nbsp; void *dstvar =3D (dst);&nbsp;&nbsp;&nbsp; &=
nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; \<br></div><div dir=
=3D"ltr">&gt;&nbsp; &nbsp;  +&nbsp; &nbsp; ((__ssp_bos0(dstvar) !=3D (size_=
t)-1) ?&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; \<br></div><div dir=3D"ltr">&g=
t;&nbsp; &nbsp;  +&nbsp; &nbsp; __builtin___ ## fun ## _chk(dstvar, srcvar,=
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; \<br></div><div dir=3D"ltr">&gt;&nbsp=
; &nbsp;  +&nbsp; &nbsp; &nbsp; &nbsp; __ssp_bos0(dstvar)) :&nbsp;&nbsp;&nb=
sp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; \<br></div><di=
v dir=3D"ltr">&gt;&nbsp; &nbsp;  +&nbsp; &nbsp; __ ## fun ## _ichk(dstvar, =
srcvar));&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; \<br></div><div dir=3D"ltr">=
&gt;&nbsp; &nbsp;  +})<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +<br></=
div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +#define __ssp_bos_check2(fun, dst,=
 src)&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; \<br></div><d=
iv dir=3D"ltr">&gt;&nbsp; &nbsp;  +&nbsp; &nbsp; __ssp_bos_check2_var(fun, =
__ssp_var(dstv), dst,<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  __ssp_va=
r(srcv), src)<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +<br></div><div =
dir=3D"ltr">&gt;&nbsp; &nbsp;  +#define __ssp_bos_icheck3_restrict(fun, typ=
e1, type2) \<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +static __inline =
type1 __ ## fun ## _ichk(type1 __restrict, type2<br></div><div dir=3D"ltr">=
&gt;&nbsp; &nbsp;  __restrict, size_t); \<br></div><div dir=3D"ltr">&gt;&nb=
sp; &nbsp;  +static __inline __attribute__((__always_inline__)) type1 \<br>=
</div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +__ ## fun ## _ichk(type1 __restr=
ict dst, type2 __restrict src,<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp; =
 size_t len) { \<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +&nbsp;&nbsp;=
&nbsp; return __builtin___ ## fun ## _chk(dst, src, len,<br></div><div dir=
=3D"ltr">&gt;&nbsp; &nbsp;  __ssp_bos0(dst)); \<br></div><div dir=3D"ltr">&=
gt;&nbsp; &nbsp;  +}<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +<br></di=
v><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +#define __ssp_bos_icheck3(fun, type1=
, type2) \<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +static __inline ty=
pe1 __ ## fun ## _ichk(type1, type2, size_t); \<br></div><div dir=3D"ltr">&=
gt;&nbsp; &nbsp;  +static __inline __attribute__((__always_inline__)) type1=
 \<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +__ ## fun ## _ichk(type1 d=
st, type2 src, size_t len) { \<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp; =
 +&nbsp;&nbsp;&nbsp; return __builtin___ ## fun ## _chk(dst, src, len,<br><=
/div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  __ssp_bos0(dst)); \<br></div><div =
dir=3D"ltr">&gt;&nbsp; &nbsp;  +}<br></div><div dir=3D"ltr">&gt;&nbsp; &nbs=
p;  +<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +#define __ssp_bos_ichec=
k2_restrict(fun, type1, type2) \<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp=
;  +static __inline type1 __ ## fun ## _ichk(type1, type2); \<br></div><div=
 dir=3D"ltr">&gt;&nbsp; &nbsp;  +static __inline __attribute__((__always_in=
line__)) type1 \<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +__ ## fun ##=
 _ichk(type1 __restrict dst, type2 __restrict src) { \<br></div><div dir=3D=
"ltr">&gt;&nbsp; &nbsp;  +&nbsp;&nbsp;&nbsp; return __builtin___ ## fun ## =
_chk(dst, src, __ssp_bos0(dst)); \<br></div><div dir=3D"ltr">&gt;&nbsp; &nb=
sp;  +}<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +<br></div><div dir=3D=
"ltr">&gt;&nbsp; &nbsp;  +__BEGIN_DECLS<br></div><div dir=3D"ltr">&gt;&nbsp=
; &nbsp;  +__ssp_bos_icheck3_restrict(memcpy, void *, const void *)<br></di=
v><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +__ssp_bos_icheck3(memmove, void *, c=
onst void *)<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +__ssp_bos_icheck=
3(memset, void *, int)<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +__ssp_=
bos_icheck2_restrict(stpcpy, char *, const char *)<br></div><div dir=3D"ltr=
">&gt;&nbsp; &nbsp;  +__ssp_bos_icheck3_restrict(stpncpy, char *, const cha=
r *)<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +__ssp_bos_icheck2_restri=
ct(strcpy, char *, const char *)<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp=
;  +__ssp_bos_icheck2_restrict(strcat, char *, const char *)<br></div><div =
dir=3D"ltr">&gt;&nbsp; &nbsp;  +__ssp_bos_icheck3_restrict(strncpy, char *,=
 const char *)<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +__ssp_bos_iche=
ck3_restrict(strncat, char *, const char *)<br></div><div dir=3D"ltr">&gt;&=
nbsp; &nbsp;  +__END_DECLS<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +<b=
r></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +#define memcpy(dst, src, len) =
__ssp_bos_check3(memcpy, dst, src, len)<br></div><div dir=3D"ltr">&gt;&nbsp=
; &nbsp;  +#define memmove(dst, src, len) __ssp_bos_check3(memmove, dst, sr=
c, len)<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +#define memset(dst, v=
al, len) \<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +&nbsp; &nbsp; __ss=
p_bos_check3_typed(memset, void *, dst, int, val, len)<br></div><div dir=3D=
"ltr">&gt;&nbsp; &nbsp;  +#define stpcpy(dst, src) __ssp_bos_check2(stpcpy,=
 dst, src)<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +#define stpncpy(ds=
t, src, len) __ssp_bos_check3(stpncpy, dst, src, len)<br></div><div dir=3D"=
ltr">&gt;&nbsp; &nbsp;  +#define strcpy(dst, src) __ssp_bos_check2(strcpy, =
dst, src)<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +#define strcat(dst,=
 src) __ssp_bos_check2(strcat, dst, src)<br></div><div dir=3D"ltr">&gt;&nbs=
p; &nbsp;  +#define strncpy(dst, src, len) __ssp_bos_check3(strncpy, dst, s=
rc, len)<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +#define strncat(dst,=
 src, len) __ssp_bos_check3(strncat, dst, src, len)<br></div><div dir=3D"lt=
r">&gt;&nbsp; &nbsp;  +<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +#endi=
f /* __SSP_FORTIFY_LEVEL &gt; 0 */<br></div><div dir=3D"ltr">&gt;&nbsp; &nb=
sp;  +#endif /* _SSP_STRING_H_ */<br></div><div dir=3D"ltr">&gt;&nbsp; &nbs=
p;  diff --git a/include/ssp/strings.h b/include/ssp/strings.h<br></div><di=
v dir=3D"ltr">&gt;&nbsp; &nbsp;  new file mode 100644<br></div><div dir=3D"=
ltr">&gt;&nbsp; &nbsp;  index 000000000000..06c9c7cc0a09<br></div><div dir=
=3D"ltr">&gt;&nbsp; &nbsp;  --- /dev/null<br></div><div dir=3D"ltr">&gt;&nb=
sp; &nbsp;  +++ b/include/ssp/strings.h<br></div><div dir=3D"ltr">&gt;&nbsp=
; &nbsp;  @@ -0,0 +1,67 @@<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +/*=
&nbsp;&nbsp;&nbsp; $NetBSD: strings.h,v 1.3 2008/04/28 20:22:54 martin Exp =
$&nbsp;&nbsp;&nbsp; */<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +<br></=
div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +/*-<br></div><div dir=3D"ltr">&gt;=
&nbsp; &nbsp;  + *<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + * SPDX-Li=
cense-Identifier: BSD-2-Clause<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp; =
 + *<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + * Copyright (c) 2007 Th=
e NetBSD Foundation, Inc.<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + * =
All rights reserved.<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + *<br></=
div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + * This code is derived from softw=
are contributed to The NetBSD<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  =
Foundation<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + * by Christos Zou=
las.<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + *<br></div><div dir=3D"=
ltr">&gt;&nbsp; &nbsp;  + * Redistribution and use in source and binary for=
ms, with or without<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + * modifi=
cation, are permitted provided that the following conditions<br></div><div =
dir=3D"ltr">&gt;&nbsp; &nbsp;  + * are met:<br></div><div dir=3D"ltr">&gt;&=
nbsp; &nbsp;  + * 1. Redistributions of source code must retain the above c=
opyright<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + *&nbsp; &nbsp; noti=
ce, this list of conditions and the following disclaimer.<br></div><div dir=
=3D"ltr">&gt;&nbsp; &nbsp;  + * 2. Redistributions in binary form must repr=
oduce the above copyright<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + *&=
nbsp; &nbsp; notice, this list of conditions and the following disclaimer<b=
r></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  in the<br></div><div dir=3D"ltr=
">&gt;&nbsp; &nbsp;  + *&nbsp; &nbsp; documentation and/or other materials =
provided with the<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  distribution=
.<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + *<br></div><div dir=3D"ltr=
">&gt;&nbsp; &nbsp;  + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION=
, INC. AND<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  CONTRIBUTORS<br></d=
iv><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + * ``AS IS'' AND ANY EXPRESS OR IMP=
LIED WARRANTIES, INCLUDING, BUT<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;=
  NOT LIMITED<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + * TO, THE IMPL=
IED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A<br></div><div dir=3D"lt=
r">&gt;&nbsp; &nbsp;  PARTICULAR<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp=
;  + * PURPOSE ARE DISCLAIMED.&nbsp; IN NO EVENT SHALL THE FOUNDATION OR<br=
></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  CONTRIBUTORS<br></div><div dir=
=3D"ltr">&gt;&nbsp; &nbsp;  + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDEN=
TAL, SPECIAL,<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  EXEMPLARY, OR<br=
></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + * CONSEQUENTIAL DAMAGES (INCLU=
DING, BUT NOT LIMITED TO, PROCUREMENT OF<br></div><div dir=3D"ltr">&gt;&nbs=
p; &nbsp;  + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;=
 OR<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  BUSINESS<br></div><div dir=
=3D"ltr">&gt;&nbsp; &nbsp;  + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THE=
ORY OF LIABILITY,<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  WHETHER IN<b=
r></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + * CONTRACT, STRICT LIABILITY,=
 OR TORT (INCLUDING NEGLIGENCE OR<br></div><div dir=3D"ltr">&gt;&nbsp; &nbs=
p;  OTHERWISE)<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + * ARISING IN =
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF<br></div><div dir=3D"ltr">=
&gt;&nbsp; &nbsp;  ADVISED OF THE<br></div><div dir=3D"ltr">&gt;&nbsp; &nbs=
p;  + * POSSIBILITY OF SUCH DAMAGE.<br></div><div dir=3D"ltr">&gt;&nbsp; &n=
bsp;  + */<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +#ifndef _SSP_STRIN=
GS_H_<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +#define _SSP_STRINGS_H_=
<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +<br></div><div dir=3D"ltr">&=
gt;&nbsp; &nbsp;  +#include &lt;ssp/ssp.h&gt;<br></div><div dir=3D"ltr">&gt=
;&nbsp; &nbsp;  +#include &lt;string.h&gt;<br></div><div dir=3D"ltr">&gt;&n=
bsp; &nbsp;  +<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +#if __SSP_FORT=
IFY_LEVEL &gt; 0<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +<br></div><d=
iv dir=3D"ltr">&gt;&nbsp; &nbsp;  +#define _ssp_bcopy(srcvar, src, dstvar, =
dst, lenvar,&nbsp; len) ({&nbsp;&nbsp;&nbsp; \<br></div><div dir=3D"ltr">&g=
t;&nbsp; &nbsp;  +&nbsp; &nbsp; const void *srcvar =3D (src);&nbsp;&nbsp;&n=
bsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; \<br></div><div dir=3D"ltr">&gt;=
&nbsp; &nbsp;  +&nbsp; &nbsp; void *dstvar =3D (dst);&nbsp;&nbsp;&nbsp; &nb=
sp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; \<br></div><div dir=3D"ltr">&gt;&nbsp; &=
nbsp;  +&nbsp; &nbsp; size_t lenvar =3D (len);&nbsp;&nbsp;&nbsp; &nbsp;&nbs=
p;&nbsp; &nbsp;&nbsp;&nbsp; \<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  =
+&nbsp; &nbsp; ((__ssp_bos0(dstvar) !=3D (size_t)-1) ?&nbsp;&nbsp;&nbsp; \<=
br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +&nbsp; &nbsp; __builtin___mem=
move_chk(dstvar, srcvar, lenvar,&nbsp;&nbsp;&nbsp; \<br></div><div dir=3D"l=
tr">&gt;&nbsp; &nbsp;  +&nbsp; &nbsp; &nbsp; &nbsp; __ssp_bos0(dstvar)) :&n=
bsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; \<br></div><div dir=
=3D"ltr">&gt;&nbsp; &nbsp;  +&nbsp; &nbsp; __memmove_ichk(dstvar, srcvar, l=
envar));&nbsp;&nbsp;&nbsp; \<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +=
})<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +<br></div><div dir=3D"ltr"=
>&gt;&nbsp; &nbsp;  +#define&nbsp;&nbsp;&nbsp; bcopy(src, dst, len)&nbsp;&n=
bsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; \<br></div><div dir=3D"ltr=
">&gt;&nbsp; &nbsp;  +&nbsp; &nbsp; _ssp_bcopy(__ssp_var(srcv), src, __ssp_=
var(dstv), dst,<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  __ssp_var(lenv=
), len)<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +<br></div><div dir=3D=
"ltr">&gt;&nbsp; &nbsp;  +#define _ssp_bzero(dstvar, dst, lenvar, len) ({&n=
bsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; \<br></div><div dir=3D"ltr">&gt;&nbsp; =
&nbsp;  +&nbsp; &nbsp; void *dstvar =3D (dst);&nbsp;&nbsp;&nbsp; &nbsp;&nbs=
p;&nbsp; &nbsp;&nbsp;&nbsp; \<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  =
+&nbsp; &nbsp; size_t lenvar =3D (len);&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp=
; &nbsp;&nbsp;&nbsp; \<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +&nbsp;=
 &nbsp; ((__ssp_bos0(dstvar) !=3D (size_t)-1) ?&nbsp;&nbsp;&nbsp; \<br></di=
v><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +&nbsp; &nbsp; __builtin___memset_chk=
(dstvar, 0, lenvar,&nbsp;&nbsp;&nbsp; \<br></div><div dir=3D"ltr">&gt;&nbsp=
; &nbsp;  +&nbsp; &nbsp; &nbsp; &nbsp; __ssp_bos0(dstvar)) : \<br></div><di=
v dir=3D"ltr">&gt;&nbsp; &nbsp;  +&nbsp; &nbsp; __memset_ichk(dstvar, 0, le=
nvar));&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; \<br></div><div dir=3D"ltr">&g=
t;&nbsp; &nbsp;  +})<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +<br></di=
v><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +#define&nbsp;&nbsp;&nbsp; bzero(dst,=
 len)&nbsp;&nbsp;&nbsp; _ssp_bzero(__ssp_var(dstv), dst,<br></div><div dir=
=3D"ltr">&gt;&nbsp; &nbsp;  __ssp_var(lenv), len)<br></div><div dir=3D"ltr"=
>&gt;&nbsp; &nbsp;  +<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +#endif =
/* __SSP_FORTIFY_LEVEL &gt; 0 */<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp=
;  +#endif /* _SSP_STRINGS_H_ */<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp=
;  diff --git a/include/ssp/unistd.h b/include/ssp/unistd.h<br></div><div d=
ir=3D"ltr">&gt;&nbsp; &nbsp;  new file mode 100644<br></div><div dir=3D"ltr=
">&gt;&nbsp; &nbsp;  index 000000000000..2414e2baa96b<br></div><div dir=3D"=
ltr">&gt;&nbsp; &nbsp;  --- /dev/null<br></div><div dir=3D"ltr">&gt;&nbsp; =
&nbsp;  +++ b/include/ssp/unistd.h<br></div><div dir=3D"ltr">&gt;&nbsp; &nb=
sp;  @@ -0,0 +1,54 @@<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +/*&nbsp=
;&nbsp;&nbsp; $NetBSD: unistd.h,v 1.7 2015/06/25 18:41:03 joerg Exp $&nbsp;=
&nbsp;&nbsp; */<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +<br></div><di=
v dir=3D"ltr">&gt;&nbsp; &nbsp;  +/*-<br></div><div dir=3D"ltr">&gt;&nbsp; =
&nbsp;  + *<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + * SPDX-License-I=
dentifier: BSD-2-Clause<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + *<br=
></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + * Copyright (c) 2006 The NetBS=
D Foundation, Inc.<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + * All rig=
hts reserved.<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + *<br></div><di=
v dir=3D"ltr">&gt;&nbsp; &nbsp;  + * This code is derived from software con=
tributed to The NetBSD<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  Foundat=
ion<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + * by Christos Zoulas.<br=
></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + *<br></div><div dir=3D"ltr">&g=
t;&nbsp; &nbsp;  + * Redistribution and use in source and binary forms, wit=
h or without<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + * modification,=
 are permitted provided that the following conditions<br></div><div dir=3D"=
ltr">&gt;&nbsp; &nbsp;  + * are met:<br></div><div dir=3D"ltr">&gt;&nbsp; &=
nbsp;  + * 1. Redistributions of source code must retain the above copyrigh=
t<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + *&nbsp; &nbsp; notice, thi=
s list of conditions and the following disclaimer.<br></div><div dir=3D"ltr=
">&gt;&nbsp; &nbsp;  + * 2. Redistributions in binary form must reproduce t=
he above copyright<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + *&nbsp; &=
nbsp; notice, this list of conditions and the following disclaimer<br></div=
><div dir=3D"ltr">&gt;&nbsp; &nbsp;  in the<br></div><div dir=3D"ltr">&gt;&=
nbsp; &nbsp;  + *&nbsp; &nbsp; documentation and/or other materials provide=
d with the<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  distribution.<br></=
div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + *<br></div><div dir=3D"ltr">&gt;&=
nbsp; &nbsp;  + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. =
AND<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  CONTRIBUTORS<br></div><div=
 dir=3D"ltr">&gt;&nbsp; &nbsp;  + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WA=
RRANTIES, INCLUDING, BUT<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  NOT L=
IMITED<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + * TO, THE IMPLIED WAR=
RANTIES OF MERCHANTABILITY AND FITNESS FOR A<br></div><div dir=3D"ltr">&gt;=
&nbsp; &nbsp;  PARTICULAR<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + * =
PURPOSE ARE DISCLAIMED.&nbsp; IN NO EVENT SHALL THE FOUNDATION OR<br></div>=
<div dir=3D"ltr">&gt;&nbsp; &nbsp;  CONTRIBUTORS<br></div><div dir=3D"ltr">=
&gt;&nbsp; &nbsp;  + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPEC=
IAL,<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  EXEMPLARY, OR<br></div><d=
iv dir=3D"ltr">&gt;&nbsp; &nbsp;  + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT=
 NOT LIMITED TO, PROCUREMENT OF<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;=
  + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR<br></=
div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  BUSINESS<br></div><div dir=3D"ltr">=
&gt;&nbsp; &nbsp;  + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LI=
ABILITY,<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  WHETHER IN<br></div><=
div dir=3D"ltr">&gt;&nbsp; &nbsp;  + * CONTRACT, STRICT LIABILITY, OR TORT =
(INCLUDING NEGLIGENCE OR<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  OTHER=
WISE)<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + * ARISING IN ANY WAY O=
UT OF THE USE OF THIS SOFTWARE, EVEN IF<br></div><div dir=3D"ltr">&gt;&nbsp=
; &nbsp;  ADVISED OF THE<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + * P=
OSSIBILITY OF SUCH DAMAGE.<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + *=
/<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +#ifndef _SSP_UNISTD_H_<br><=
/div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +#define _SSP_UNISTD_H_<br></div><=
div dir=3D"ltr">&gt;&nbsp; &nbsp;  +<br></div><div dir=3D"ltr">&gt;&nbsp; &=
nbsp;  +#include &lt;ssp/ssp.h&gt;<br></div><div dir=3D"ltr">&gt;&nbsp; &nb=
sp;  +<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +#if __SSP_FORTIFY_LEVE=
L &gt; 0<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +__BEGIN_DECLS<br></d=
iv><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +<br></div><div dir=3D"ltr">&gt;&nbs=
p; &nbsp;  +__ssp_redirect0(ssize_t, read, (int __fd, void *__buf, size_t _=
_len), \<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +&nbsp; &nbsp; (__fd,=
 __buf, __len));<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +<br></div><d=
iv dir=3D"ltr">&gt;&nbsp; &nbsp;  +__ssp_redirect(ssize_t, readlink, (const=
 char *__restrict __path, \<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +&=
nbsp; &nbsp; char *__restrict __buf, size_t __len), (__path, __buf, __len))=
;<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +<br></div><div dir=3D"ltr">=
&gt;&nbsp; &nbsp;  +__ssp_redirect_raw(char *, getcwd, getcwd, (char *__buf=
, size_t __len),<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +&nbsp; &nbsp=
; (__buf, __len), __buf !=3D 0, __ssp_bos);<br></div><div dir=3D"ltr">&gt;&=
nbsp; &nbsp;  +<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +__END_DECLS<b=
r></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +<br></div><div dir=3D"ltr">&gt=
;&nbsp; &nbsp;  +#endif /* __SSP_FORTIFY_LEVEL &gt; 0 */<br></div><div dir=
=3D"ltr">&gt;&nbsp; &nbsp;  +#endif /* _SSP_UNISTD_H_ */<br></div><div dir=
=3D"ltr">&gt;&nbsp; &nbsp;  diff --git a/lib/libc/secure/Makefile.inc b/lib=
/libc/secure/Makefile.inc<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  inde=
x 8574c5a05dc5..3b1ad879c715 100644<br></div><div dir=3D"ltr">&gt;&nbsp; &n=
bsp;  --- a/lib/libc/secure/Makefile.inc<br></div><div dir=3D"ltr">&gt;&nbs=
p; &nbsp;  +++ b/lib/libc/secure/Makefile.inc<br></div><div dir=3D"ltr">&gt=
;&nbsp; &nbsp;  @@ -3,6 +3,17 @@<br></div><div dir=3D"ltr">&gt; <br></div><=
div dir=3D"ltr">&gt;&nbsp; &nbsp;  .PATH: ${LIBC_SRCTOP}/secure<br></div><d=
iv dir=3D"ltr">&gt; <br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +# _FORTI=
FY_SOURCE<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +SRCS+=3D&nbsp;&nbsp=
;&nbsp; gets_chk.c fgets_chk.c memcpy_chk.c memmove_chk.c<br></div><div dir=
=3D"ltr">&gt;&nbsp; &nbsp;  memset_chk.c \<br></div><div dir=3D"ltr">&gt;&n=
bsp; &nbsp;  +&nbsp;&nbsp;&nbsp; snprintf_chk.c sprintf_chk.c stpcpy_chk.c =
stpncpy_chk.c \<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +&nbsp;&nbsp;&=
nbsp; strcat_chk.c strcpy_chk.c strncat_chk.c strncpy_chk.c \<br></div><div=
 dir=3D"ltr">&gt;&nbsp; &nbsp;  +&nbsp;&nbsp;&nbsp; vsnprintf_chk.c vsprint=
f_chk.c<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +<br></div><div dir=3D=
"ltr">&gt;&nbsp; &nbsp;  +CFLAGS.snprintf_chk.c+=3D&nbsp;&nbsp;&nbsp; -Wno-=
unused-parameter<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +CFLAGS.sprin=
tf_chk.c+=3D&nbsp;&nbsp;&nbsp; -Wno-unused-parameter<br></div><div dir=3D"l=
tr">&gt;&nbsp; &nbsp;  +CFLAGS.vsnprintf_chk.c+=3D&nbsp;&nbsp;&nbsp; -Wno-u=
nused-parameter<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +CFLAGS.vsprin=
tf_chk.c+=3D&nbsp;&nbsp;&nbsp; -Wno-unused-parameter<br></div><div dir=3D"l=
tr">&gt;&nbsp; &nbsp;  +<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  # Sou=
rces common to both syscall interfaces:<br></div><div dir=3D"ltr">&gt;&nbsp=
; &nbsp;  SRCS+=3D&nbsp;&nbsp;&nbsp; stack_protector.c \<br></div><div dir=
=3D"ltr">&gt;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp; stack_protector_compat=
.c<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  diff --git a/lib/libc/secur=
e/Symbol.map b/lib/libc/secure/Symbol.map<br></div><div dir=3D"ltr">&gt;&nb=
sp; &nbsp;  index 641f451b5421..7859fcee3821 100644<br></div><div dir=3D"lt=
r">&gt;&nbsp; &nbsp;  --- a/lib/libc/secure/Symbol.map<br></div><div dir=3D=
"ltr">&gt;&nbsp; &nbsp;  +++ b/lib/libc/secure/Symbol.map<br></div><div dir=
=3D"ltr">&gt;&nbsp; &nbsp;  @@ -3,3 +3,21 @@ FBSD_1.0 {<br></div><div dir=
=3D"ltr">&gt;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp; __stack_chk_fail;<br><=
/div><div dir=3D"ltr">&gt;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp; __stack_c=
hk_guard;<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  };<br></div><div dir=
=3D"ltr">&gt;&nbsp; &nbsp;  +<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  =
+FBSD_1.8 {<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +&nbsp;&nbsp;&nbsp=
; __gets_chk;<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +&nbsp;&nbsp;&nb=
sp; __fgets_chk;<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +&nbsp;&nbsp;=
&nbsp; __memcpy_chk;<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +&nbsp;&n=
bsp;&nbsp; __memmove_chk;<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +&nb=
sp;&nbsp;&nbsp; __memset_chk;<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  =
+&nbsp;&nbsp;&nbsp; __snprintf_chk;<br></div><div dir=3D"ltr">&gt;&nbsp; &n=
bsp;  +&nbsp;&nbsp;&nbsp; __sprintf_chk;<br></div><div dir=3D"ltr">&gt;&nbs=
p; &nbsp;  +&nbsp;&nbsp;&nbsp; __stpcpy_chk;<br></div><div dir=3D"ltr">&gt;=
&nbsp; &nbsp;  +&nbsp;&nbsp;&nbsp; __stpncpy_chk;<br></div><div dir=3D"ltr"=
>&gt;&nbsp; &nbsp;  +&nbsp;&nbsp;&nbsp; __strcat_chk;<br></div><div dir=3D"=
ltr">&gt;&nbsp; &nbsp;  +&nbsp;&nbsp;&nbsp; __strcpy_chk;<br></div><div dir=
=3D"ltr">&gt;&nbsp; &nbsp;  +&nbsp;&nbsp;&nbsp; __strncat_chk;<br></div><di=
v dir=3D"ltr">&gt;&nbsp; &nbsp;  +&nbsp;&nbsp;&nbsp; __strncpy_chk;<br></di=
v><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +&nbsp;&nbsp;&nbsp; __vsnprintf_chk;<=
br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +&nbsp;&nbsp;&nbsp; __vsprintf=
_chk;<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +};<br></div><div dir=3D=
"ltr">&gt;&nbsp; &nbsp;  diff --git a/lib/libc/secure/fgets_chk.c b/lib/lib=
c/secure/fgets_chk.c<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  new file =
mode 100644<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  index 000000000000=
..72aa1d816ce1<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  --- /dev/null<b=
r></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +++ b/lib/libc/secure/fgets_chk=
.c<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  @@ -0,0 +1,54 @@<br></div><=
div dir=3D"ltr">&gt;&nbsp; &nbsp;  +/*-<br></div><div dir=3D"ltr">&gt;&nbsp=
; &nbsp;  + *<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + * SPDX-License=
-Identifier: BSD-2-Clause<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + *<=
br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + * Copyright (c) 2006 The Net=
BSD Foundation, Inc.<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + * All r=
ights reserved.<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + *<br></div><=
div dir=3D"ltr">&gt;&nbsp; &nbsp;  + * This code is derived from software c=
ontributed to The NetBSD<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  Found=
ation<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + * by Christos Zoulas.<=
br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + *<br></div><div dir=3D"ltr">=
&gt;&nbsp; &nbsp;  + * Redistribution and use in source and binary forms, w=
ith or without<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + * modificatio=
n, are permitted provided that the following conditions<br></div><div dir=
=3D"ltr">&gt;&nbsp; &nbsp;  + * are met:<br></div><div dir=3D"ltr">&gt;&nbs=
p; &nbsp;  + * 1. Redistributions of source code must retain the above copy=
right<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + *&nbsp; &nbsp; notice,=
 this list of conditions and the following disclaimer.<br></div><div dir=3D=
"ltr">&gt;&nbsp; &nbsp;  + * 2. Redistributions in binary form must reprodu=
ce the above copyright<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + *&nbs=
p; &nbsp; notice, this list of conditions and the following disclaimer<br><=
/div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  in the<br></div><div dir=3D"ltr">&=
gt;&nbsp; &nbsp;  + *&nbsp; &nbsp; documentation and/or other materials pro=
vided with the<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  distribution.<b=
r></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + *<br></div><div dir=3D"ltr">&=
gt;&nbsp; &nbsp;  + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, I=
NC. AND<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  CONTRIBUTORS<br></div>=
<div dir=3D"ltr">&gt;&nbsp; &nbsp;  + * ``AS IS'' AND ANY EXPRESS OR IMPLIE=
D WARRANTIES, INCLUDING, BUT<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  N=
OT LIMITED<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + * TO, THE IMPLIED=
 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A<br></div><div dir=3D"ltr">=
&gt;&nbsp; &nbsp;  PARTICULAR<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  =
+ * PURPOSE ARE DISCLAIMED.&nbsp; IN NO EVENT SHALL THE FOUNDATION OR<br></=
div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  CONTRIBUTORS<br></div><div dir=3D"l=
tr">&gt;&nbsp; &nbsp;  + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, =
SPECIAL,<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  EXEMPLARY, OR<br></di=
v><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + * CONSEQUENTIAL DAMAGES (INCLUDING,=
 BUT NOT LIMITED TO, PROCUREMENT OF<br></div><div dir=3D"ltr">&gt;&nbsp; &n=
bsp;  + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR<b=
r></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  BUSINESS<br></div><div dir=3D"l=
tr">&gt;&nbsp; &nbsp;  + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY O=
F LIABILITY,<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  WHETHER IN<br></d=
iv><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + * CONTRACT, STRICT LIABILITY, OR T=
ORT (INCLUDING NEGLIGENCE OR<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  O=
THERWISE)<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + * ARISING IN ANY W=
AY OUT OF THE USE OF THIS SOFTWARE, EVEN IF<br></div><div dir=3D"ltr">&gt;&=
nbsp; &nbsp;  ADVISED OF THE<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +=
 * POSSIBILITY OF SUCH DAMAGE.<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp; =
 + */<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +#include &lt;sys/cdefs.=
h&gt;<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +__RCSID("$NetBSD: fgets=
_chk.c,v 1.6 2009/02/05 05:41:51 lukem Exp $");<br></div><div dir=3D"ltr">&=
gt;&nbsp; &nbsp;  +<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +#include =
&lt;limits.h&gt;<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +#include &lt=
;stdio.h&gt;<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +#include &lt;std=
lib.h&gt;<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +#include &lt;string=
.h&gt;<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +<br></div><div dir=3D"=
ltr">&gt;&nbsp; &nbsp;  +#include &lt;ssp/stdio.h&gt;<br></div><div dir=3D"=
ltr">&gt;&nbsp; &nbsp;  +#include &lt;ssp/string.h&gt;<br></div><div dir=3D=
"ltr">&gt;&nbsp; &nbsp;  +#undef fgets<br></div><div dir=3D"ltr">&gt;&nbsp;=
 &nbsp;  +<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +char *<br></div><d=
iv dir=3D"ltr">&gt;&nbsp; &nbsp;  +__fgets_chk(char * __restrict buf, int l=
en, size_t slen, FILE *fp)<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +{<=
br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +&nbsp;&nbsp;&nbsp; if (slen &=
gt;=3D (size_t)INT_MAX)<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +&nbsp=
;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return (fgets(buf, len, fp));<br></div><di=
v dir=3D"ltr">&gt;&nbsp; &nbsp;  +<br></div><div dir=3D"ltr">&gt;&nbsp; &nb=
sp;  +&nbsp;&nbsp;&nbsp; if (len &gt;=3D 0 &amp;&amp; (size_t)len &gt; slen=
)<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +&nbsp;&nbsp;&nbsp; &nbsp;&n=
bsp;&nbsp; __chk_fail();<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +<br>=
</div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +&nbsp;&nbsp;&nbsp; return (fgets=
(buf, len, fp));<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +}<br></div><=
div dir=3D"ltr">&gt;&nbsp; &nbsp;  diff --git a/lib/libc/secure/gets_chk.c =
b/lib/libc/secure/gets_chk.c<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  n=
ew file mode 100644<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  index 0000=
00000000..18c1e2d18f43<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  --- /de=
v/null<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +++ b/lib/libc/secure/g=
ets_chk.c<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  @@ -0,0 +1,74 @@<br>=
</div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +/*-<br></div><div dir=3D"ltr">&g=
t;&nbsp; &nbsp;  + *<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + * SPDX-=
License-Identifier: BSD-2-Clause<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp=
;  + *<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + * Copyright (c) 2006 =
The NetBSD Foundation, Inc.<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + =
* All rights reserved.<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + *<br>=
</div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + * This code is derived from sof=
tware contributed to The NetBSD<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;=
  Foundation<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + * by Christos Z=
oulas.<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + *<br></div><div dir=
=3D"ltr">&gt;&nbsp; &nbsp;  + * Redistribution and use in source and binary=
 forms, with or without<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + * mo=
dification, are permitted provided that the following conditions<br></div><=
div dir=3D"ltr">&gt;&nbsp; &nbsp;  + * are met:<br></div><div dir=3D"ltr">&=
gt;&nbsp; &nbsp;  + * 1. Redistributions of source code must retain the abo=
ve copyright<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + *&nbsp; &nbsp; =
notice, this list of conditions and the following disclaimer.<br></div><div=
 dir=3D"ltr">&gt;&nbsp; &nbsp;  + * 2. Redistributions in binary form must =
reproduce the above copyright<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  =
+ *&nbsp; &nbsp; notice, this list of conditions and the following disclaim=
er<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  in the<br></div><div dir=3D=
"ltr">&gt;&nbsp; &nbsp;  + *&nbsp; &nbsp; documentation and/or other materi=
als provided with the<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  distribu=
tion.<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + *<br></div><div dir=3D=
"ltr">&gt;&nbsp; &nbsp;  + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDA=
TION, INC. AND<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  CONTRIBUTORS<br=
></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + * ``AS IS'' AND ANY EXPRESS OR=
 IMPLIED WARRANTIES, INCLUDING, BUT<br></div><div dir=3D"ltr">&gt;&nbsp; &n=
bsp;  NOT LIMITED<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + * TO, THE =
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A<br></div><div dir=
=3D"ltr">&gt;&nbsp; &nbsp;  PARTICULAR<br></div><div dir=3D"ltr">&gt;&nbsp;=
 &nbsp;  + * PURPOSE ARE DISCLAIMED.&nbsp; IN NO EVENT SHALL THE FOUNDATION=
 OR<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  CONTRIBUTORS<br></div><div=
 dir=3D"ltr">&gt;&nbsp; &nbsp;  + * BE LIABLE FOR ANY DIRECT, INDIRECT, INC=
IDENTAL, SPECIAL,<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  EXEMPLARY, O=
R<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + * CONSEQUENTIAL DAMAGES (I=
NCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF<br></div><div dir=3D"ltr">&gt;=
&nbsp; &nbsp;  + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROF=
ITS; OR<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  BUSINESS<br></div><div=
 dir=3D"ltr">&gt;&nbsp; &nbsp;  + * INTERRUPTION) HOWEVER CAUSED AND ON ANY=
 THEORY OF LIABILITY,<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  WHETHER =
IN<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + * CONTRACT, STRICT LIABIL=
ITY, OR TORT (INCLUDING NEGLIGENCE OR<br></div><div dir=3D"ltr">&gt;&nbsp; =
&nbsp;  OTHERWISE)<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + * ARISING=
 IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF<br></div><div dir=3D"l=
tr">&gt;&nbsp; &nbsp;  ADVISED OF THE<br></div><div dir=3D"ltr">&gt;&nbsp; =
&nbsp;  + * POSSIBILITY OF SUCH DAMAGE.<br></div><div dir=3D"ltr">&gt;&nbsp=
; &nbsp;  + */<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +#include &lt;s=
ys/cdefs.h&gt;<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +__RCSID("$NetB=
SD: gets_chk.c,v 1.7 2013/10/04 20:49:16 christos Exp<br></div><div dir=3D"=
ltr">&gt;&nbsp; &nbsp;  $");<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +=
<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +#include &lt;limits.h&gt;<br=
></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +#include &lt;stdio.h&gt;<br></d=
iv><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +#include &lt;stdlib.h&gt;<br></div>=
<div dir=3D"ltr">&gt;&nbsp; &nbsp;  +#include &lt;string.h&gt;<br></div><di=
v dir=3D"ltr">&gt;&nbsp; &nbsp;  +<br></div><div dir=3D"ltr">&gt;&nbsp; &nb=
sp;  +#include &lt;ssp/stdio.h&gt;<br></div><div dir=3D"ltr">&gt;&nbsp; &nb=
sp;  +#include &lt;ssp/string.h&gt;<br></div><div dir=3D"ltr">&gt;&nbsp; &n=
bsp;  +<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +char *__gets_unsafe(c=
har *);<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +<br></div><div dir=3D=
"ltr">&gt;&nbsp; &nbsp;  +char *<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp=
;  +__gets_chk(char * __restrict buf, size_t slen)<br></div><div dir=3D"ltr=
">&gt;&nbsp; &nbsp;  +{<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +&nbsp=
;&nbsp;&nbsp; char *abuf;<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +&nb=
sp;&nbsp;&nbsp; size_t len;<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +<=
br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +&nbsp;&nbsp;&nbsp; if (slen &=
gt;=3D (size_t)INT_MAX)<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +&nbsp=
;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return (__gets_unsafe(buf));<br></div><div=
 dir=3D"ltr">&gt;&nbsp; &nbsp;  +<br></div><div dir=3D"ltr">&gt;&nbsp; &nbs=
p;  +&nbsp;&nbsp;&nbsp; if ((abuf =3D malloc(slen + 1)) =3D=3D NULL)<br></d=
iv><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbs=
p; return (__gets_unsafe(buf));<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;=
  +<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +&nbsp;&nbsp;&nbsp; if (fg=
ets(abuf, (int)(slen + 1), stdin) =3D=3D NULL) {<br></div><div dir=3D"ltr">=
&gt;&nbsp; &nbsp;  +&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; free(abuf);<br></=
div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nb=
sp; return (NULL);<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +&nbsp;&nbs=
p;&nbsp; }<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +<br></div><div dir=
=3D"ltr">&gt;&nbsp; &nbsp;  +&nbsp;&nbsp;&nbsp; len =3D strlen(abuf);<br></=
div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +&nbsp;&nbsp;&nbsp; if (len &gt; 0 =
&amp;&amp; abuf[len - 1] =3D=3D '\n')<br></div><div dir=3D"ltr">&gt;&nbsp; =
&nbsp;  +&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; --len;<br></div><div dir=3D"=
ltr">&gt;&nbsp; &nbsp;  +<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +&nb=
sp;&nbsp;&nbsp; if (len &gt;=3D slen)<br></div><div dir=3D"ltr">&gt;&nbsp; =
&nbsp;  +&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; __chk_fail();<br></div><div =
dir=3D"ltr">&gt;&nbsp; &nbsp;  +<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp=
;  +&nbsp;&nbsp;&nbsp; (void)memcpy(buf, abuf, len);<br></div><div dir=3D"l=
tr">&gt;&nbsp; &nbsp;  +<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +&nbs=
p;&nbsp;&nbsp; buf[len] =3D '\0';<br></div><div dir=3D"ltr">&gt;&nbsp; &nbs=
p;  +&nbsp;&nbsp;&nbsp; free(abuf);<br></div><div dir=3D"ltr">&gt;&nbsp; &n=
bsp;  +&nbsp;&nbsp;&nbsp; return (buf);<br></div><div dir=3D"ltr">&gt;&nbsp=
; &nbsp;  +}<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  diff --git a/lib/=
libc/secure/memcpy_chk.c b/lib/libc/secure/memcpy_chk.c<br></div><div dir=
=3D"ltr">&gt;&nbsp; &nbsp;  new file mode 100644<br></div><div dir=3D"ltr">=
&gt;&nbsp; &nbsp;  index 000000000000..99cf2d5f13ff<br></div><div dir=3D"lt=
r">&gt;&nbsp; &nbsp;  --- /dev/null<br></div><div dir=3D"ltr">&gt;&nbsp; &n=
bsp;  +++ b/lib/libc/secure/memcpy_chk.c<br></div><div dir=3D"ltr">&gt;&nbs=
p; &nbsp;  @@ -0,0 +1,53 @@<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +/=
*-<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + *<br></div><div dir=3D"lt=
r">&gt;&nbsp; &nbsp;  + * SPDX-License-Identifier: BSD-2-Clause<br></div><d=
iv dir=3D"ltr">&gt;&nbsp; &nbsp;  + *<br></div><div dir=3D"ltr">&gt;&nbsp; =
&nbsp;  + * Copyright (c) 2006 The NetBSD Foundation, Inc.<br></div><div di=
r=3D"ltr">&gt;&nbsp; &nbsp;  + * All rights reserved.<br></div><div dir=3D"=
ltr">&gt;&nbsp; &nbsp;  + *<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + =
* This code is derived from software contributed to The NetBSD<br></div><di=
v dir=3D"ltr">&gt;&nbsp; &nbsp;  Foundation<br></div><div dir=3D"ltr">&gt;&=
nbsp; &nbsp;  + * by Christos Zoulas.<br></div><div dir=3D"ltr">&gt;&nbsp; =
&nbsp;  + *<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + * Redistribution=
 and use in source and binary forms, with or without<br></div><div dir=3D"l=
tr">&gt;&nbsp; &nbsp;  + * modification, are permitted provided that the fo=
llowing conditions<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + * are met=
:<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + * 1. Redistributions of so=
urce code must retain the above copyright<br></div><div dir=3D"ltr">&gt;&nb=
sp; &nbsp;  + *&nbsp; &nbsp; notice, this list of conditions and the follow=
ing disclaimer.<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + * 2. Redistr=
ibutions in binary form must reproduce the above copyright<br></div><div di=
r=3D"ltr">&gt;&nbsp; &nbsp;  + *&nbsp; &nbsp; notice, this list of conditio=
ns and the following disclaimer<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;=
  in the<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + *&nbsp; &nbsp; docu=
mentation and/or other materials provided with the<br></div><div dir=3D"ltr=
">&gt;&nbsp; &nbsp;  distribution.<br></div><div dir=3D"ltr">&gt;&nbsp; &nb=
sp;  + *<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + * THIS SOFTWARE IS =
PROVIDED BY THE NETBSD FOUNDATION, INC. AND<br></div><div dir=3D"ltr">&gt;&=
nbsp; &nbsp;  CONTRIBUTORS<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + *=
 ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT<br></div><=
div dir=3D"ltr">&gt;&nbsp; &nbsp;  NOT LIMITED<br></div><div dir=3D"ltr">&g=
t;&nbsp; &nbsp;  + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITN=
ESS FOR A<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  PARTICULAR<br></div>=
<div dir=3D"ltr">&gt;&nbsp; &nbsp;  + * PURPOSE ARE DISCLAIMED.&nbsp; IN NO=
 EVENT SHALL THE FOUNDATION OR<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp; =
 CONTRIBUTORS<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + * BE LIABLE FO=
R ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,<br></div><div dir=3D"ltr">&gt;=
&nbsp; &nbsp;  EXEMPLARY, OR<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +=
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF<br>=
</div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + * SUBSTITUTE GOODS OR SERVICES;=
 LOSS OF USE, DATA, OR PROFITS; OR<br></div><div dir=3D"ltr">&gt;&nbsp; &nb=
sp;  BUSINESS<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + * INTERRUPTION=
) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,<br></div><div dir=3D"ltr">=
&gt;&nbsp; &nbsp;  WHETHER IN<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  =
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR<br></div><=
div dir=3D"ltr">&gt;&nbsp; &nbsp;  OTHERWISE)<br></div><div dir=3D"ltr">&gt=
;&nbsp; &nbsp;  + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVE=
N IF<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  ADVISED OF THE<br></div><=
div dir=3D"ltr">&gt;&nbsp; &nbsp;  + * POSSIBILITY OF SUCH DAMAGE.<br></div=
><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + */<br></div><div dir=3D"ltr">&gt;&nb=
sp; &nbsp;  +#include &lt;sys/cdefs.h&gt;<br></div><div dir=3D"ltr">&gt;&nb=
sp; &nbsp;  +__RCSID("$NetBSD: memcpy_chk.c,v 1.7 2015/05/13 19:57:16 joerg=
 Exp $");<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +<br></div><div dir=
=3D"ltr">&gt;&nbsp; &nbsp;  +#include &lt;string.h&gt;<br></div><div dir=3D=
"ltr">&gt;&nbsp; &nbsp;  +<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +#i=
nclude &lt;ssp/string.h&gt;<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +#=
undef memcpy<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +<br></div><div d=
ir=3D"ltr">&gt;&nbsp; &nbsp;  +#include "ssp_internal.h"<br></div><div dir=
=3D"ltr">&gt;&nbsp; &nbsp;  +<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  =
+void *<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +__memcpy_chk(void * _=
_restrict dst, const void * __restrict src,<br></div><div dir=3D"ltr">&gt;&=
nbsp; &nbsp;  size_t len,<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +&nb=
sp; &nbsp; size_t slen)<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +{<br>=
</div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +&nbsp;&nbsp;&nbsp; if (len &gt; =
slen)<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +&nbsp;&nbsp;&nbsp; &nbs=
p;&nbsp;&nbsp; __chk_fail();<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +=
<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +&nbsp;&nbsp;&nbsp; if (__ssp=
_overlap((const char *)src, (const char *)dst, len))<br></div><div dir=3D"l=
tr">&gt;&nbsp; &nbsp;  +&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; __chk_fail();=
<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +<br></div><div dir=3D"ltr">&=
gt;&nbsp; &nbsp;  +&nbsp;&nbsp;&nbsp; return (memcpy(dst, src, len));<br></=
div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +}<br></div><div dir=3D"ltr">&gt;&n=
bsp; &nbsp;  diff --git a/lib/libc/secure/memmove_chk.c<br></div><div dir=
=3D"ltr">&gt;&nbsp; &nbsp;  b/lib/libc/secure/memmove_chk.c<br></div><div d=
ir=3D"ltr">&gt;&nbsp; &nbsp;  new file mode 100644<br></div><div dir=3D"ltr=
">&gt;&nbsp; &nbsp;  index 000000000000..07f965d608fc<br></div><div dir=3D"=
ltr">&gt;&nbsp; &nbsp;  --- /dev/null<br></div><div dir=3D"ltr">&gt;&nbsp; =
&nbsp;  +++ b/lib/libc/secure/memmove_chk.c<br></div><div dir=3D"ltr">&gt;&=
nbsp; &nbsp;  @@ -0,0 +1,47 @@<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp; =
 +/*-<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + *<br></div><div dir=3D=
"ltr">&gt;&nbsp; &nbsp;  + * SPDX-License-Identifier: BSD-2-Clause<br></div=
><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + *<br></div><div dir=3D"ltr">&gt;&nbs=
p; &nbsp;  + * Copyright (c) 2006 The NetBSD Foundation, Inc.<br></div><div=
 dir=3D"ltr">&gt;&nbsp; &nbsp;  + * All rights reserved.<br></div><div dir=
=3D"ltr">&gt;&nbsp; &nbsp;  + *<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;=
  + * This code is derived from software contributed to The NetBSD<br></div=
><div dir=3D"ltr">&gt;&nbsp; &nbsp;  Foundation<br></div><div dir=3D"ltr">&=
gt;&nbsp; &nbsp;  + * by Christos Zoulas.<br></div><div dir=3D"ltr">&gt;&nb=
sp; &nbsp;  + *<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + * Redistribu=
tion and use in source and binary forms, with or without<br></div><div dir=
=3D"ltr">&gt;&nbsp; &nbsp;  + * modification, are permitted provided that t=
he following conditions<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + * ar=
e met:<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + * 1. Redistributions =
of source code must retain the above copyright<br></div><div dir=3D"ltr">&g=
t;&nbsp; &nbsp;  + *&nbsp; &nbsp; notice, this list of conditions and the f=
ollowing disclaimer.<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + * 2. Re=
distributions in binary form must reproduce the above copyright<br></div><d=
iv dir=3D"ltr">&gt;&nbsp; &nbsp;  + *&nbsp; &nbsp; notice, this list of con=
ditions and the following disclaimer<br></div><div dir=3D"ltr">&gt;&nbsp; &=
nbsp;  in the<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + *&nbsp; &nbsp;=
 documentation and/or other materials provided with the<br></div><div dir=
=3D"ltr">&gt;&nbsp; &nbsp;  distribution.<br></div><div dir=3D"ltr">&gt;&nb=
sp; &nbsp;  + *<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + * THIS SOFTW=
ARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND<br></div><div dir=3D"ltr=
">&gt;&nbsp; &nbsp;  CONTRIBUTORS<br></div><div dir=3D"ltr">&gt;&nbsp; &nbs=
p;  + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT<br>=
</div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  NOT LIMITED<br></div><div dir=3D"=
ltr">&gt;&nbsp; &nbsp;  + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY A=
ND FITNESS FOR A<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  PARTICULAR<br=
></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + * PURPOSE ARE DISCLAIMED.&nbsp=
; IN NO EVENT SHALL THE FOUNDATION OR<br></div><div dir=3D"ltr">&gt;&nbsp; =
&nbsp;  CONTRIBUTORS<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + * BE LI=
ABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,<br></div><div dir=3D"lt=
r">&gt;&nbsp; &nbsp;  EXEMPLARY, OR<br></div><div dir=3D"ltr">&gt;&nbsp; &n=
bsp;  + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT=
 OF<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + * SUBSTITUTE GOODS OR SE=
RVICES; LOSS OF USE, DATA, OR PROFITS; OR<br></div><div dir=3D"ltr">&gt;&nb=
sp; &nbsp;  BUSINESS<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + * INTER=
RUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,<br></div><div dir=
=3D"ltr">&gt;&nbsp; &nbsp;  WHETHER IN<br></div><div dir=3D"ltr">&gt;&nbsp;=
 &nbsp;  + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR<b=
r></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  OTHERWISE)<br></div><div dir=3D=
"ltr">&gt;&nbsp; &nbsp;  + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFT=
WARE, EVEN IF<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  ADVISED OF THE<b=
r></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + * POSSIBILITY OF SUCH DAMAGE.=
<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + */<br></div><div dir=3D"ltr=
">&gt;&nbsp; &nbsp;  +#include &lt;sys/cdefs.h&gt;<br></div><div dir=3D"ltr=
">&gt;&nbsp; &nbsp;  +__RCSID("$NetBSD: memmove_chk.c,v 1.6 2020/09/05 13:3=
7:59 mrg Exp $");<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +<br></div><=
div dir=3D"ltr">&gt;&nbsp; &nbsp;  +#include &lt;string.h&gt;<br></div><div=
 dir=3D"ltr">&gt;&nbsp; &nbsp;  +<br></div><div dir=3D"ltr">&gt;&nbsp; &nbs=
p;  +#include &lt;ssp/string.h&gt;<br></div><div dir=3D"ltr">&gt;&nbsp; &nb=
sp;  +#undef memmove<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +<br></di=
v><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +void *<br></div><div dir=3D"ltr">&gt=
;&nbsp; &nbsp;  +__memmove_chk(void *dst, const void *src, size_t len,<br><=
/div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +&nbsp; &nbsp; size_t slen)<br></d=
iv><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +{<br></div><div dir=3D"ltr">&gt;&nb=
sp; &nbsp;  +&nbsp;&nbsp;&nbsp; if (len &gt; slen)<br></div><div dir=3D"ltr=
">&gt;&nbsp; &nbsp;  +&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; __chk_fail();<b=
r></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +&nbsp;&nbsp;&nbsp; return (mem=
move(dst, src, len));<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +}<br></=
div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  diff --git a/lib/libc/secure/memset=
_chk.c b/lib/libc/secure/memset_chk.c<br></div><div dir=3D"ltr">&gt;&nbsp; =
&nbsp;  new file mode 100644<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  i=
ndex 000000000000..f337be98b46d<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;=
  --- /dev/null<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +++ b/lib/libc=
/secure/memset_chk.c<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  @@ -0,0 +=
1,46 @@<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +/*-<br></div><div dir=
=3D"ltr">&gt;&nbsp; &nbsp;  + *<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;=
  + * SPDX-License-Identifier: BSD-2-Clause<br></div><div dir=3D"ltr">&gt;&=
nbsp; &nbsp;  + *<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + * Copyrigh=
t (c) 2006 The NetBSD Foundation, Inc.<br></div><div dir=3D"ltr">&gt;&nbsp;=
 &nbsp;  + * All rights reserved.<br></div><div dir=3D"ltr">&gt;&nbsp; &nbs=
p;  + *<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + * This code is deriv=
ed from software contributed to The NetBSD<br></div><div dir=3D"ltr">&gt;&n=
bsp; &nbsp;  Foundation<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + * by=
 Christos Zoulas.<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + *<br></div=
><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + * Redistribution and use in source a=
nd binary forms, with or without<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp=
;  + * modification, are permitted provided that the following conditions<b=
r></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + * are met:<br></div><div dir=
=3D"ltr">&gt;&nbsp; &nbsp;  + * 1. Redistributions of source code must reta=
in the above copyright<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + *&nbs=
p; &nbsp; notice, this list of conditions and the following disclaimer.<br>=
</div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + * 2. Redistributions in binary =
form must reproduce the above copyright<br></div><div dir=3D"ltr">&gt;&nbsp=
; &nbsp;  + *&nbsp; &nbsp; notice, this list of conditions and the followin=
g disclaimer<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  in the<br></div><=
div dir=3D"ltr">&gt;&nbsp; &nbsp;  + *&nbsp; &nbsp; documentation and/or ot=
her materials provided with the<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;=
  distribution.<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + *<br></div><=
div dir=3D"ltr">&gt;&nbsp; &nbsp;  + * THIS SOFTWARE IS PROVIDED BY THE NET=
BSD FOUNDATION, INC. AND<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  CONTR=
IBUTORS<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + * ``AS IS'' AND ANY =
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT<br></div><div dir=3D"ltr">&gt=
;&nbsp; &nbsp;  NOT LIMITED<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + =
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A<br></div>=
<div dir=3D"ltr">&gt;&nbsp; &nbsp;  PARTICULAR<br></div><div dir=3D"ltr">&g=
t;&nbsp; &nbsp;  + * PURPOSE ARE DISCLAIMED.&nbsp; IN NO EVENT SHALL THE FO=
UNDATION OR<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  CONTRIBUTORS<br></=
div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + * BE LIABLE FOR ANY DIRECT, INDIR=
ECT, INCIDENTAL, SPECIAL,<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  EXEM=
PLARY, OR<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + * CONSEQUENTIAL DA=
MAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF<br></div><div dir=3D"l=
tr">&gt;&nbsp; &nbsp;  + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,=
 OR PROFITS; OR<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  BUSINESS<br></=
div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + * INTERRUPTION) HOWEVER CAUSED AN=
D ON ANY THEORY OF LIABILITY,<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  =
WHETHER IN<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + * CONTRACT, STRIC=
T LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR<br></div><div dir=3D"ltr">&gt=
;&nbsp; &nbsp;  OTHERWISE)<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + *=
 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF<br></div><div =
dir=3D"ltr">&gt;&nbsp; &nbsp;  ADVISED OF THE<br></div><div dir=3D"ltr">&gt=
;&nbsp; &nbsp;  + * POSSIBILITY OF SUCH DAMAGE.<br></div><div dir=3D"ltr">&=
gt;&nbsp; &nbsp;  + */<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +#inclu=
de &lt;sys/cdefs.h&gt;<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +__RCSI=
D("$NetBSD: memset_chk.c,v 1.5 2014/09/17 00:39:28 joerg Exp $");<br></div>=
<div dir=3D"ltr">&gt;&nbsp; &nbsp;  +<br></div><div dir=3D"ltr">&gt;&nbsp; =
&nbsp;  +#include &lt;string.h&gt;<br></div><div dir=3D"ltr">&gt;&nbsp; &nb=
sp;  +<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +#include &lt;ssp/strin=
g.h&gt;<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +#undef memset<br></di=
v><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +<br></div><div dir=3D"ltr">&gt;&nbsp=
; &nbsp;  +void *<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +__memset_ch=
k(void * __restrict dst, int val, size_t len, size_t slen)<br></div><div di=
r=3D"ltr">&gt;&nbsp; &nbsp;  +{<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;=
  +&nbsp;&nbsp;&nbsp; if (len &gt; slen)<br></div><div dir=3D"ltr">&gt;&nbs=
p; &nbsp;  +&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; __chk_fail();<br></div><d=
iv dir=3D"ltr">&gt;&nbsp; &nbsp;  +&nbsp;&nbsp;&nbsp; return (memset(dst, v=
al, len));<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +}<br></div><div di=
r=3D"ltr">&gt;&nbsp; &nbsp;  diff --git a/lib/libc/secure/snprintf_chk.c<br=
></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  b/lib/libc/secure/snprintf_chk.c=
<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  new file mode 100644<br></div=
><div dir=3D"ltr">&gt;&nbsp; &nbsp;  index 000000000000..52ef874ede5b<br></=
div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  --- /dev/null<br></div><div dir=3D"=
ltr">&gt;&nbsp; &nbsp;  +++ b/lib/libc/secure/snprintf_chk.c<br></div><div =
dir=3D"ltr">&gt;&nbsp; &nbsp;  @@ -0,0 +1,56 @@<br></div><div dir=3D"ltr">&=
gt;&nbsp; &nbsp;  +/*-<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + *<br>=
</div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + * SPDX-License-Identifier: BSD-=
2-Clause<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + *<br></div><div dir=
=3D"ltr">&gt;&nbsp; &nbsp;  + * Copyright (c) 2006 The NetBSD Foundation, I=
nc.<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + * All rights reserved.<b=
r></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + *<br></div><div dir=3D"ltr">&=
gt;&nbsp; &nbsp;  + * This code is derived from software contributed to The=
 NetBSD<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  Foundation<br></div><d=
iv dir=3D"ltr">&gt;&nbsp; &nbsp;  + * by Christos Zoulas.<br></div><div dir=
=3D"ltr">&gt;&nbsp; &nbsp;  + *<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;=
  + * Redistribution and use in source and binary forms, with or without<br=
></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + * modification, are permitted =
provided that the following conditions<br></div><div dir=3D"ltr">&gt;&nbsp;=
 &nbsp;  + * are met:<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + * 1. R=
edistributions of source code must retain the above copyright<br></div><div=
 dir=3D"ltr">&gt;&nbsp; &nbsp;  + *&nbsp; &nbsp; notice, this list of condi=
tions and the following disclaimer.<br></div><div dir=3D"ltr">&gt;&nbsp; &n=
bsp;  + * 2. Redistributions in binary form must reproduce the above copyri=
ght<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + *&nbsp; &nbsp; notice, t=
his list of conditions and the following disclaimer<br></div><div dir=3D"lt=
r">&gt;&nbsp; &nbsp;  in the<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +=
 *&nbsp; &nbsp; documentation and/or other materials provided with the<br><=
/div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  distribution.<br></div><div dir=3D=
"ltr">&gt;&nbsp; &nbsp;  + *<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +=
 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND<br></div><d=
iv dir=3D"ltr">&gt;&nbsp; &nbsp;  CONTRIBUTORS<br></div><div dir=3D"ltr">&g=
t;&nbsp; &nbsp;  + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLU=
DING, BUT<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  NOT LIMITED<br></div=
><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + * TO, THE IMPLIED WARRANTIES OF MERC=
HANTABILITY AND FITNESS FOR A<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  =
PARTICULAR<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + * PURPOSE ARE DIS=
CLAIMED.&nbsp; IN NO EVENT SHALL THE FOUNDATION OR<br></div><div dir=3D"ltr=
">&gt;&nbsp; &nbsp;  CONTRIBUTORS<br></div><div dir=3D"ltr">&gt;&nbsp; &nbs=
p;  + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,<br></div><=
div dir=3D"ltr">&gt;&nbsp; &nbsp;  EXEMPLARY, OR<br></div><div dir=3D"ltr">=
&gt;&nbsp; &nbsp;  + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO=
, PROCUREMENT OF<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + * SUBSTITUT=
E GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR<br></div><div dir=3D=
"ltr">&gt;&nbsp; &nbsp;  BUSINESS<br></div><div dir=3D"ltr">&gt;&nbsp; &nbs=
p;  + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,<br></d=
iv><div dir=3D"ltr">&gt;&nbsp; &nbsp;  WHETHER IN<br></div><div dir=3D"ltr"=
>&gt;&nbsp; &nbsp;  + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGL=
IGENCE OR<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  OTHERWISE)<br></div>=
<div dir=3D"ltr">&gt;&nbsp; &nbsp;  + * ARISING IN ANY WAY OUT OF THE USE O=
F THIS SOFTWARE, EVEN IF<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  ADVIS=
ED OF THE<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + * POSSIBILITY OF S=
UCH DAMAGE.<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + */<br></div><div=
 dir=3D"ltr">&gt;&nbsp; &nbsp;  +#include &lt;sys/cdefs.h&gt;<br></div><div=
 dir=3D"ltr">&gt;&nbsp; &nbsp;  +__RCSID("$NetBSD: snprintf_chk.c,v 1.5 200=
8/04/28 20:23:00 martin<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  Exp $"=
);<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +<br></div><div dir=3D"ltr"=
>&gt;&nbsp; &nbsp;  +#include &lt;stdarg.h&gt;<br></div><div dir=3D"ltr">&g=
t;&nbsp; &nbsp;  +#include &lt;stdio.h&gt;<br></div><div dir=3D"ltr">&gt;&n=
bsp; &nbsp;  +<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +#include &lt;s=
sp/stdio.h&gt;<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +#undef vsnprin=
tf<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +<br></div><div dir=3D"ltr"=
>&gt;&nbsp; &nbsp;  +int<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +__sn=
printf_chk(char * __restrict buf, size_t len, int flags, size_t<br></div><d=
iv dir=3D"ltr">&gt;&nbsp; &nbsp;  slen,<br></div><div dir=3D"ltr">&gt;&nbsp=
; &nbsp;  +&nbsp; &nbsp; const char * __restrict fmt, ...)<br></div><div di=
r=3D"ltr">&gt;&nbsp; &nbsp;  +{<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;=
  +&nbsp;&nbsp;&nbsp; va_list ap;<br></div><div dir=3D"ltr">&gt;&nbsp; &nbs=
p;  +&nbsp;&nbsp;&nbsp; int rv;<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;=
  +<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +&nbsp;&nbsp;&nbsp; if (le=
n &gt; slen)<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +&nbsp;&nbsp;&nbs=
p; &nbsp;&nbsp;&nbsp; __chk_fail();<br></div><div dir=3D"ltr">&gt;&nbsp; &n=
bsp;  +<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +&nbsp;&nbsp;&nbsp; va=
_start(ap, fmt);<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +&nbsp;&nbsp;=
&nbsp; rv =3D vsnprintf(buf, len, fmt, ap);<br></div><div dir=3D"ltr">&gt;&=
nbsp; &nbsp;  +&nbsp;&nbsp;&nbsp; va_end(ap);<br></div><div dir=3D"ltr">&gt=
;&nbsp; &nbsp;  +<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +&nbsp;&nbsp=
;&nbsp; return (rv);<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  +}<br></d=
iv><div dir=3D"ltr">&gt;&nbsp; &nbsp;  diff --git a/lib/libc/secure/sprintf=
_chk.c<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  b/lib/libc/secure/sprin=
tf_chk.c<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  new file mode 100644<=
br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  index 000000000000..d4c42ccba3=
ce<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  --- /dev/null<br></div><div=
 dir=3D"ltr">&gt;&nbsp; &nbsp;  +++ b/lib/libc/secure/sprintf_chk.c<br></di=
v><div dir=3D"ltr">&gt;&nbsp; &nbsp;  @@ -0,0 +1,61 @@<br></div><div dir=3D=
"ltr">&gt;&nbsp; &nbsp;  +/*-<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  =
+ *<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + * SPDX-License-Identifie=
r: BSD-2-Clause<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + *<br></div><=
div dir=3D"ltr">&gt;&nbsp; &nbsp;  + * Copyright (c) 2006 The NetBSD Founda=
tion, Inc.<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + * All rights rese=
rved.<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  + *<br></div><div dir=3D=
"ltr">&gt;&nbsp; &nbsp;  + * This code is derived from software contributed=
 to The NetBSD<br></div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  Foundation<br><=
/div><div dir=3D"ltr">&gt;&nbsp; &nbsp;  *** 1063 LINES SKIPPED ***<br></di=
v><div dir=3D"ltr">&gt; <br></div><div dir=3D"ltr">&gt; <br></div></div>
            </div>
        </div></body></html>
------=_Part_1357399_2058372477.1716093599883--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1413980952.1357400.1716093599901>