From: Michael Paquier <michael@paquier.xyz>
To: Postgres hackers <pgsql-hackers@lists.postgresql.org>
Cc: Julien Rouhaud <rjuju123@gmail.com>
Cc: Robert Haas <robertmhaas@gmail.com>
Subject: Avoiding useless SHA256 initialization with backup manifests, breaking base backups with FIPS
Date: Tue, 10 Nov 2020 11:00:14 +0900
Message-ID: <20201110020014.GE1887@paquier.xyz> (raw)
Hi all,
Trying to use OpenSSL with FIPS breaks if one attempts to call the
low-level SHA2 routines we currently use in sha2_openssl.c (upstream
calls that OpenSSLDie()), forcing a crash of PG. The actual way to
fix that is to use EVP as I solved here:
https://commitfest.postgresql.org/30/2762/
Unfortunately, this enforces an ABI breakage so this is not
backpatchable material. Now, if one attempts to use OpenSSL with
FIPS, the initialization of backup manifests in
InitializeBackupManifest() enforces a call to pg_sha256_init() for the
manifest file itself even if pg_basebackup, or anything requesting a
base backup with the replication protocol, does *not* want a backup
manifest. One can for example enforce to not use a backup manifest
with --no-manifest in pg_basebackup, but even if you specify that base
backups cause the backend to crash on HEAD if using FIPS in OpenSSL.
Looking at the code, the checksum of the manifest file is updated or
finalized only if IsManifestEnabled() is satisfied, meaning that if
the caller does not want a manifest we do its initialization, but
we have no use for it.
Attached is a patch that I would like to back-patch down to v13 to
avoid this useless initialization, giving users the possibility to
take base backups with FIPS when not using a backup manifest. Without
the solution in the first paragraph, you cannot make use of backup
manifests at all with OpenSSL+FIPS (one can still enforce the use of
the in-core SHA2 implementation even if building with OpenSSL), but at
least it gives an escape route with 13.
Thoughts?
--
Michael
Attachments:backup-manifest-init-v1.patch (text/x-diff, 940B) downloaddiff --git a/src/backend/replication/backup_manifest.c b/src/backend/replication/backup_manifest.cindex 556e6b5040..bab5e2f53b 100644--- a/src/backend/replication/backup_manifest.c+++ b/src/backend/replication/backup_manifest.c@@ -57,12 +57,17 @@ InitializeBackupManifest(backup_manifest_info *manifest,
backup_manifest_option want_manifest,
pg_checksum_type manifest_checksum_type)
{
+ memset(manifest, 0, sizeof(backup_manifest_info));+ manifest->checksum_type = manifest_checksum_type;+
if (want_manifest == MANIFEST_OPTION_NO)
manifest->buffile = NULL;
else
+ {
manifest->buffile = BufFileCreateTemp(false);
- manifest->checksum_type = manifest_checksum_type;- pg_sha256_init(&manifest->manifest_ctx);+ pg_sha256_init(&manifest->manifest_ctx);+ }+
manifest->manifest_size = UINT64CONST(0);
manifest->force_encode = (want_manifest == MANIFEST_OPTION_FORCE_ENCODE);
manifest->first_file = true;
signature.asc (application/pgp-signature, 832B) download
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-hackers@postgresql.org
Cc: michael@paquier.xyz, rjuju123@gmail.com, robertmhaas@gmail.com
Subject: Re: Avoiding useless SHA256 initialization with backup manifests, breaking base backups with FIPS
In-Reply-To: <20201110020014.GE1887@paquier.xyz>
References: <20201110020014.GE1887@paquier.xyz>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox