From c2a8a9de42192361c0f080b9daa224d64acc1c06 Mon Sep 17 00:00:00 2001 From: Radoslaw Zarzynski Date: Sat, 16 Nov 2019 00:41:13 +0100 Subject: [PATCH] rgw: audit memset & bzero users for FIPS. Signed-off-by: Radoslaw Zarzynski (cherry picked from commit cdfc5cded9db88c59fc8e9b5dcee0a0fb1f9272a) --- src/rgw/rgw_civetweb_frontend.cc | 1 + src/rgw/rgw_common.cc | 6 ++++++ src/rgw/rgw_file.h | 2 ++ src/rgw/rgw_http_client.cc | 1 + src/rgw/rgw_ldap.cc | 2 ++ src/rgw/rgw_swift_auth.cc | 2 ++ src/rgw/rgw_torrent.cc | 4 ++++ 7 files changed, 18 insertions(+) diff --git a/src/rgw/rgw_civetweb_frontend.cc b/src/rgw/rgw_civetweb_frontend.cc index 18aedede0f2d..4e9d1ce74fe7 100644 --- a/src/rgw/rgw_civetweb_frontend.cc +++ b/src/rgw/rgw_civetweb_frontend.cc @@ -142,6 +142,7 @@ int RGWCivetWebFrontend::run() options.push_back(nullptr); /* Initialize the CivetWeb right now. */ struct mg_callbacks cb; + // FIPS zeroization audit 20191115: this memset is not security related. memset((void *)&cb, 0, sizeof(cb)); cb.begin_request = civetweb_callback; cb.log_message = rgw_civetweb_log_callback; diff --git a/src/rgw/rgw_common.cc b/src/rgw/rgw_common.cc index e8a6438daece..fffc1b289cb5 100644 --- a/src/rgw/rgw_common.cc +++ b/src/rgw/rgw_common.cc @@ -475,24 +475,28 @@ static bool check_gmt_end(const char *s) static bool parse_rfc850(const char *s, struct tm *t) { + // FIPS zeroization audit 20191115: this memset is not security related. memset(t, 0, sizeof(*t)); return check_gmt_end(strptime(s, "%A, %d-%b-%y %H:%M:%S ", t)); } static bool parse_asctime(const char *s, struct tm *t) { + // FIPS zeroization audit 20191115: this memset is not security related. memset(t, 0, sizeof(*t)); return check_str_end(strptime(s, "%a %b %d %H:%M:%S %Y", t)); } static bool parse_rfc1123(const char *s, struct tm *t) { + // FIPS zeroization audit 20191115: this memset is not security related. memset(t, 0, sizeof(*t)); return check_gmt_end(strptime(s, "%a, %d %b %Y %H:%M:%S ", t)); } static bool parse_rfc1123_alt(const char *s, struct tm *t) { + // FIPS zeroization audit 20191115: this memset is not security related. memset(t, 0, sizeof(*t)); return check_str_end(strptime(s, "%a, %d %b %Y %H:%M:%S %z", t)); } @@ -504,6 +508,7 @@ bool parse_rfc2616(const char *s, struct tm *t) bool parse_iso8601(const char *s, struct tm *t, uint32_t *pns, bool extended_format) { + // FIPS zeroization audit 20191115: this memset is not security related. memset(t, 0, sizeof(*t)); const char *p; @@ -1445,6 +1450,7 @@ class HexTable public: HexTable() { + // FIPS zeroization audit 20191115: this memset is not security related. memset(table, -1, sizeof(table)); int i; for (i = '0'; i<='9'; i++) diff --git a/src/rgw/rgw_file.h b/src/rgw/rgw_file.h index f9cebc02e33b..84b17069e20f 100644 --- a/src/rgw/rgw_file.h +++ b/src/rgw/rgw_file.h @@ -438,6 +438,8 @@ namespace rgw { int stat(struct stat* st, uint32_t flags = FLAG_NONE) { /* partial Unix attrs */ + /* FIPS zeroization audit 20191115: this memset is not security + * related. */ memset(st, 0, sizeof(struct stat)); st->st_dev = state.dev; st->st_ino = fh.fh_hk.object; // XXX diff --git a/src/rgw/rgw_http_client.cc b/src/rgw/rgw_http_client.cc index bb68c1450ce1..bb14e03fd333 100644 --- a/src/rgw/rgw_http_client.cc +++ b/src/rgw/rgw_http_client.cc @@ -52,6 +52,7 @@ struct rgw_http_req_data : public RefCountedObject { std::unique_ptr completion; rgw_http_req_data() : id(-1), lock("rgw_http_req_data::lock") { + // FIPS zeroization audit 20191115: this memset is not security related. memset(error_buf, 0, sizeof(error_buf)); } diff --git a/src/rgw/rgw_ldap.cc b/src/rgw/rgw_ldap.cc index 91106a1156e7..9e7156fc52bd 100644 --- a/src/rgw/rgw_ldap.cc +++ b/src/rgw/rgw_ldap.cc @@ -23,6 +23,8 @@ std::string parse_rgw_ldap_bindpw(CephContext* ctx) << __func__ << " LDAP auth no rgw_ldap_secret file found in conf" << dendl; } else { + // FIPS zeroization audit 20191116: this memset is not intended to + // wipe out a secret after use. char bindpw[1024]; memset(bindpw, 0, 1024); int pwlen = safe_read_file("" /* base */, ldap_secret.c_str(), diff --git a/src/rgw/rgw_swift_auth.cc b/src/rgw/rgw_swift_auth.cc index dcd6758f3e90..207c8eaad45c 100644 --- a/src/rgw/rgw_swift_auth.cc +++ b/src/rgw/rgw_swift_auth.cc @@ -475,6 +475,8 @@ static int build_token(const string& swift_user, dout(20) << "build_token token=" << buf << dendl; char k[CEPH_CRYPTO_HMACSHA1_DIGESTSIZE]; + // FIPS zeroization audit 20191116: this memset is not intended to + // wipe out a secret after use. memset(k, 0, sizeof(k)); const char *s = key.c_str(); for (int i = 0; i < (int)key.length(); i++, s++) { diff --git a/src/rgw/rgw_torrent.cc b/src/rgw/rgw_torrent.cc index c8786ee9a7ed..57c3f944c3fb 100644 --- a/src/rgw/rgw_torrent.cc +++ b/src/rgw/rgw_torrent.cc @@ -154,6 +154,8 @@ void seed::sha1(SHA1 *h, bufferlist &bl, off_t bl_len) /* get sha1 */ for (off_t i = 0; i < num; i++) { + // FIPS zeroization audit 20191116: this memset is not intended to + // wipe out a secret after use. memset(sha, 0x00, sizeof(sha)); h->Update((unsigned char *)pstr, info.piece_length); h->Final((unsigned char *)sha); @@ -164,6 +166,8 @@ void seed::sha1(SHA1 *h, bufferlist &bl, off_t bl_len) /* process remain */ if (0 != remain) { + // FIPS zeroization audit 20191116: this memset is not intended to + // wipe out a secret after use. memset(sha, 0x00, sizeof(sha)); h->Update((unsigned char *)pstr, remain); h->Final((unsigned char *)sha); -- 2.47.3