From owner-svn-src-head@freebsd.org Tue Mar 27 14:55:02 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0536CF5CDA0; Tue, 27 Mar 2018 14:55:02 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id AC6EF6A3C8; Tue, 27 Mar 2018 14:55:01 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id A73F31D951; Tue, 27 Mar 2018 14:55:01 +0000 (UTC) (envelope-from cem@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w2REt1mn079480; Tue, 27 Mar 2018 14:55:01 GMT (envelope-from cem@FreeBSD.org) Received: (from cem@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w2REt1Cs079478; Tue, 27 Mar 2018 14:55:01 GMT (envelope-from cem@FreeBSD.org) Message-Id: <201803271455.w2REt1Cs079478@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cem set sender to cem@FreeBSD.org using -f From: Conrad Meyer Date: Tue, 27 Mar 2018 14:55:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r331620 - in head/sys: contrib/libb2 crypto/blake2 X-SVN-Group: head X-SVN-Commit-Author: cem X-SVN-Commit-Paths: in head/sys: contrib/libb2 crypto/blake2 X-SVN-Commit-Revision: 331620 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 27 Mar 2018 14:55:02 -0000 Author: cem Date: Tue Mar 27 14:55:01 2018 New Revision: 331620 URL: https://svnweb.freebsd.org/changeset/base/331620 Log: MFV: libb2: use native calls for secure memory clearance Drop our local patch and restore full vanilla upstream code in contrib/libb2. No functional change intended. explicit_bzero() should continue to be used. Obtained from: libb2 b4b241a34824b51956a7866606329a065d397525 Sponsored by: Dell EMC Isilon Modified: head/sys/contrib/libb2/blake2-impl.h head/sys/crypto/blake2/config.h Modified: head/sys/contrib/libb2/blake2-impl.h ============================================================================== --- head/sys/contrib/libb2/blake2-impl.h Tue Mar 27 14:54:02 2018 (r331619) +++ head/sys/contrib/libb2/blake2-impl.h Tue Mar 27 14:55:01 2018 (r331620) @@ -131,11 +131,20 @@ static inline uint64_t rotr64( const uint64_t w, const /* prevents compiler optimizing out memset() */ static inline void secure_zero_memory(void *v, size_t n) { -#ifdef __FreeBSD__ +#if defined(_WIN32) || defined(WIN32) + SecureZeroMemory(v, n); +#else +// prioritize first the general C11 call +#if defined(HAVE_MEMSET_S) + memset_s(v, n, 0, n); +#elif defined(HAVE_EXPLICIT_BZERO) explicit_bzero(v, n); +#elif defined(HAVE_EXPLICIT_MEMSET) + explicit_memset(v, 0, n); #else - static void *(*const volatile memset_v)(void *, int, size_t) = &memset; - memset_v(v, 0, n); + memset(v, 0, n); + __asm__ __volatile__("" :: "r"(v) : "memory"); +#endif #endif } Modified: head/sys/crypto/blake2/config.h ============================================================================== --- head/sys/crypto/blake2/config.h Tue Mar 27 14:54:02 2018 (r331619) +++ head/sys/crypto/blake2/config.h Tue Mar 27 14:55:01 2018 (r331620) @@ -17,3 +17,5 @@ #else #define HAVE_ALIGNED_ACCESS_REQUIRED 1 #endif + +#define HAVE_EXPLICIT_BZERO 1