Skip to content

Commit 8f68fa3

Browse files
committed
Release v30122018 3.4.0
See ChangeLog
1 parent 7f1bfd5 commit 8f68fa3

File tree

8 files changed

+40
-10
lines changed

8 files changed

+40
-10
lines changed

ChangeLog

+13-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11

2-
ChangeLog file for safeclib
2+
ChangeLog file for safeclib
3+
4+
Changes in v30122018 3.4.0
5+
- Updated towctrans case-mappings to Unicode 11.0 (GH #62)
6+
- Improved memset_s, memzero_s security by adding a CPU memory barrier,
7+
not just a compiler barrier. (GH #63)
8+
Check various memory_barrier insns (mfence, sfence, lwsync, membar,
9+
lock..., memory_barrier) and use it for the memset primitives
10+
to reliably sync memory stores with possibly re-ordered loads.
11+
Note that glibc/BSD explicit_bzero or Microsoft SecureZeroMemory only do
12+
a simple compiler barrier, which is not Spectre, Meltdown secure.
13+
- add pic_flag to RETPOLINE cflags and ldflags (GH #55)
14+
- Add --disable-doc option (GH #54)
315

416
Changes in v03032018 3.3.0
517
- Added compile-time and run-time object_size checks (BOS), resulting

build-tools/smoke.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -193,9 +193,9 @@ if [ -e /usr/bin/arm-linux-gnueabihf-gcc ]; then
193193
./configure --enable-unsafe --enable-debug --host=arm-linux-gnueabihf && \
194194
make -s -j4 || exit;
195195
# $make -s -j4 check-log
196-
if [ ! -e /usr/arm-linux-gnueabihf/lib/libsafec-3.3.so.3 ]; then
196+
if [ ! -e /usr/arm-linux-gnueabihf/lib/libsafec-3.4.so.3 ]; then
197197
cd /usr/arm-linux-gnueabihf/lib/;
198-
sudo ln -s $OLDPWD/src/.libs/libsafec-3.3.so.3;
198+
sudo ln -s $OLDPWD/src/.libs/libsafec-3.4.so.3;
199199
cd -
200200
fi
201201
make -s -j4 -C tests tests;

configure.ac

+2-2
Original file line numberDiff line numberDiff line change
@@ -936,8 +936,8 @@ AC_SUBST([TARBALL_VERSION_FILE])
936936
# version information, refer to the libtool manual, section "Updating
937937
# library version information":
938938
# http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
939-
AC_SUBST([SAFEC_SO_VERSION], [3:3:0])
940-
AC_SUBST([SAFEC_API_VERSION], [3.3])
939+
AC_SUBST([SAFEC_SO_VERSION], [3:4:0])
940+
AC_SUBST([SAFEC_API_VERSION], [3.4])
941941

942942
# Automake variables, these variables get automagically included at the top
943943
# of all automake generated make files. This is why you don't see them

doc/libc-overview.md

+6
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,12 @@ with julia).
5252

5353
See also http://crashcourse.housegordon.org/coreutils-multibyte-support.html
5454

55+
None of the other libc's (and neither most crypto libraries) provide a secure
56+
memory barrier for memset/memzero/memset_s/explicit_bzero/SecureZeroMemory/...,
57+
they only provide a compiler barrier against false compiler optimizations. They
58+
don't reliably sync memory stores with possibly re-ordered loads by modern
59+
out-of-order CPU's. Only the linux kernel and safeclib do so.
60+
5561
# C11 Annex K/safec caveats
5662

5763
* `tmpnam_s`:

src/extmem/memzero_s.c

+4
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@
5454
* @pre dest shall not be a null pointer.
5555
* @pre len shall not be 0 nor greater than RSIZE_MAX_MEM and size of dest
5656
*
57+
* @note memzero_s provides a memory barrier for modern out-of-order CPU's
58+
* to ensure a cache flush or at least a compiler barrier fallback to
59+
* ensure that is not optimized away by optimizing compilers.
60+
*
5761
* @return If there is a runtime constraint, the operation is not performed.
5862
* @retval EOK when operation is successful
5963
* @retval ESNULLP when dest is NULL POINTER

src/mem/mem_primitives_lib.c

+4
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,17 @@
4242
*/
4343

4444
/**
45+
* @def mem_prim_set(dest,len,value)
4546
* @brief
4647
* Sets len bytes starting at dest to the specified value
4748
*
4849
* @param[out] dest pointer to memory that will be set to value
4950
* @param[in] len number of bytes to be set
5051
* @param[in] value byte value
5152
*
53+
* @note mem_prim_set provides a memory barrier for modern out-of-order CPU's
54+
* to ensure a cache flush or at least a compiler barrier fallback to
55+
* ensure that is not optimized away by optimizing compilers.
5256
*/
5357

5458
#if __WORDSIZE != 64

src/mem/mem_primitives_lib.h

+6-5
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,8 @@
111111
#define ASM_VOLATILE ASM_INLINE volatile
112112
#define COMPILER_BARRIER ASM_VOLATILE ("" ::: "memory") /* the insecure fallback */
113113
#else
114-
#define ASM_VOLATILE //
114+
/* warning no inline asm */
115+
#define ASM_VOLATILE
115116
#define COMPILER_BARRIER
116117
#endif
117118

@@ -122,13 +123,13 @@
122123
#elif defined(HAVE_MBARRIER_H) && (defined(sun) || defined(__sun))
123124
/* Solaris 12 (membar) */
124125
# define MEMORY_BARRIER __machine_rw_barrier()
125-
#elif defined(__GNUC__) && defined(HAVE_PPC_ALTIVEC) || defined(HAVE_PPC_SPE)
126+
#elif defined(__GNUC__) && defined(ASM_INLINE) && (defined(HAVE_PPC_ALTIVEC) || defined(HAVE_PPC_SPE))
126127
# define MEMORY_BARRIER ASM_VOLATILE ("lwsync" ::: "memory")
127-
#elif defined(__GNUC__) && (defined(__x86_64__) || defined(__SSE2__))
128+
#elif defined(__GNUC__) && defined(ASM_INLINE) && (defined(__x86_64__) || defined(__SSE2__))
128129
# define MEMORY_BARRIER ASM_VOLATILE ("mfence" ::: "memory")
129-
#elif defined(__GNUC__) && defined(__i386__)
130+
#elif defined(__GNUC__) && defined(ASM_INLINE) && defined(__i386__)
130131
# define MEMORY_BARRIER ASM_VOLATILE ("lock; addl $0,0(%%esp)" ::: "memory")
131-
#elif defined(HAVE_ARM_NEON) || defined(HAVE_ARM_NEON)
132+
#elif defined(ASM_INLINE) && (defined(HAVE_ARM_NEON) || defined(HAVE_ARM_NEON))
132133
# define MEMORY_BARRIER ASM_VOLATILE ("dmb; dsb; isb" ::: "memory")
133134
#elif defined(__GNUC__) && __GNUC__ >= 5
134135
/* new gcc-5 memory_barrier insn for most archs:

src/mem/memset_s.c

+3
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@
7272
* erroneous value of dmax does not expose the impending buffer
7373
* overflow.
7474
* @note C11 uses RSIZE_MAX, not RSIZE_MAX_MEM.
75+
* @note memset_s provides a memory barrier for modern out-of-order CPU's
76+
* to ensure a cache flush or at least a compiler barrier fallback to
77+
* ensure that is not optimized away by optimizing compilers.
7578
*
7679
* @return If there is a runtime-constraints violation, and if dest is not a null
7780
* pointer, and if dmax is not too large, then, before

0 commit comments

Comments
 (0)