Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hnrL3-0002C7-2G for pgsql-hackers@arkaria.postgresql.org; Wed, 17 Jul 2019 21:19:49 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hnrL0-000463-7a for pgsql-hackers@arkaria.postgresql.org; Wed, 17 Jul 2019 21:19:46 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hnrKz-00045w-QG for pgsql-hackers@lists.postgresql.org; Wed, 17 Jul 2019 21:19:46 +0000 Received: from mail-qt1-x843.google.com ([2607:f8b0:4864:20::843]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hnrKr-00068g-Kn for pgsql-hackers@postgresql.org; Wed, 17 Jul 2019 21:19:44 +0000 Received: by mail-qt1-x843.google.com with SMTP id a15so24922013qtn.7 for ; Wed, 17 Jul 2019 14:19:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=ywkh3aJpxd6MP+iNJcq0wM/JMoXLAw0Cx3KE+c+1okM=; b=RcAdroV/B19sLRTCWcjxOCAzvXRh4Tbz6oIIWvkwPxrzlEdowwYpiwpozQqKmQtwPJ /azXbVjJocndZJZATNpT5IHMTzDnyfjuSNSiwG38/yyGBor0QrSvanpDVbZ6AQeYop8o uxC0xnl+TqtYcf5eYflH2knF0mw89QGPUOF8/HWGrt18XOCI+USPp80PCV0l2wGH/Zls sKSon1zOYFd1vDGCpscm4BwfpCHPy1Aj1OTsITOydLm2E5LX6Sv198zsMqTW6X2L8iM7 iRuryceeQQpjps81yj5usP0CRH5SNldiWO7gdpXcXYeHkkHWblcI6lkOGhUZY/1cYcLW IdvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=ywkh3aJpxd6MP+iNJcq0wM/JMoXLAw0Cx3KE+c+1okM=; b=A3A5TxaiuZAo79R4kKSWsDon018dp3uFQby4tFSw4Pm4F+PApoexkCoq1/duPqlPw6 YUdLqJYwe5M/giGd0dz0xBr0OC135Y08ktt8TVPaif0AgSFnVs7wI2Hrd/H81OJyBMcK xcCjpbMGLoeSG0+k/nMmLgE6Bv+kKK7kjbTy+DhcwlHuuddGBPkYJ0NhB9TfSyTQF/UM ULzYM71hKzA3cP+JX2KhtMpErJkZhSIXz/94y19UyqwOZNNCIQlEiVz2YsxxFhMFdIRD Tw2q9Ofp6Qelq5QaVDddD4U/KhgKOEle0CpihaDDaQ2tYJVvSDwvD25ugjeuoqaKXHeo orzA== X-Gm-Message-State: APjAAAUER3URCAVJ2HpmU5Rb8OZ0oFNs6PRLwQ8Ed2ejpASP5gWA1sXT 9SLIvcBcvklL1+qEnN1JyixOwg== X-Google-Smtp-Source: APXvYqwV3IDMqatfpM4r7vTTVJsPuuVF6Fe25UrFFrnTKbxUJzJ39IT70cM18NflSlfGaeeLjZq1vA== X-Received: by 2002:a0c:becb:: with SMTP id f11mr19180152qvj.33.1563398375010; Wed, 17 Jul 2019 14:19:35 -0700 (PDT) Received: from nimloth.alvh.no-ip.org ([177.154.139.198]) by smtp.gmail.com with ESMTPSA id o17sm10135629qkm.6.2019.07.17.14.19.34 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 17 Jul 2019 14:19:34 -0700 (PDT) Received: by nimloth.alvh.no-ip.org (Postfix, from userid 1000) id 82861121CA7; Wed, 17 Jul 2019 17:19:31 -0400 (-04) Date: Wed, 17 Jul 2019 17:19:31 -0400 From: Alvaro Herrera To: Thomas Munro Cc: Peter Eisentraut , Tom Lane , pgsql-hackers Subject: Re: using explicit_bzero Message-ID: <20190717211931.GA906@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 2019-Jul-11, Thomas Munro wrote: > Following a trail of crumbs beginning at OpenSSH's fallback > implementation of this[1], I learned that C11 has standardised > memset_s[2] for this purpose. Macs have memset_s but no > explicit_bzero. FreeBSD has both. I wonder if it'd be better to make > memset_s the function we use in our code, considering its standard > blessing and therefore likelihood of being available on every system > eventually. Sounds like a future-proof way would be to implement memset_s in src/port if absent from the OS (using explicit_bzero and other tricks), and use that. Here's a portable implementation (includes _WIN32 and NetBSD's explicit_memset) under ISC license: https://github.com/jedisct1/libsodium/blob/master/src/libsodium/sodium/utils.c#L112 (from https://www.cryptologie.net/article/419/zeroing-memory-compiler-optimizations-and-memset_s/ ) -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services