From: Vitaly Chikunov <vt@altlinux.org>
To: Mimi Zohar <zohar@linux.vnet.ibm.com>,
Dmitry Kasatkin <dmitry.kasatkin@gmail.com>,
linux-integrity@vger.kernel.org
Subject: [PATCH v1 5/5] ima-evm-utils: Fix clang warning about possible unaligned pointer for hdr->keyid
Date: Mon, 8 Jul 2019 02:48:37 +0300 [thread overview]
Message-ID: <20190707234837.4866-6-vt@altlinux.org> (raw)
In-Reply-To: <20190707234837.4866-1-vt@altlinux.org>
Struct signature_v2_hdr is packed so clang complains that taking address
of packed member may result in an unaligned pointer value:
libimaevm.c:481:21: warning: taking address of packed member 'keyid' of class or structure 'signature_v2_hdr' may result in an unaligned pointer value
[-Waddress-of-packed-member]
__be32_to_cpup(&hdr->keyid));
^~~~~~~~~~
libimaevm.c:905:17: warning: taking address of packed member 'keyid' of class or structure 'signature_v2_hdr' may result in an unaligned pointer value
[-Waddress-of-packed-member]
calc_keyid_v2(&hdr->keyid, name, pkey);
^~~~~~~~~~
Signed-off-by: Vitaly Chikunov <vt@altlinux.org>
---
src/libimaevm.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/src/libimaevm.c b/src/libimaevm.c
index b556276..f8ab812 100644
--- a/src/libimaevm.c
+++ b/src/libimaevm.c
@@ -475,10 +475,12 @@ int verify_hash_v2(const char *file, const unsigned char *hash, int size,
}
if (public_keys) {
- pkey = find_keyid(hdr->keyid);
+ uint32_t keyid = hdr->keyid;
+
+ pkey = find_keyid(keyid);
if (!pkey) {
log_err("%s: unknown keyid: %x\n", file,
- __be32_to_cpup(&hdr->keyid));
+ __be32_to_cpup(&keyid));
return -1;
}
} else {
@@ -869,6 +871,7 @@ int sign_hash_v2(const char *algo, const unsigned char *hash, int size, const ch
const EVP_MD *md;
size_t sigsize;
const char *st;
+ uint32_t keyid;
if (!hash) {
log_err("sign_hash_v2: hash is null\n");
@@ -902,7 +905,8 @@ int sign_hash_v2(const char *algo, const unsigned char *hash, int size, const ch
hdr->hash_algo = get_hash_algo(algo);
- calc_keyid_v2(&hdr->keyid, name, pkey);
+ calc_keyid_v2(&keyid, name, pkey);
+ hdr->keyid = keyid;
st = "EVP_PKEY_CTX_new";
if (!(ctx = EVP_PKEY_CTX_new(pkey, NULL)))
--
2.11.0
next prev parent reply other threads:[~2019-07-07 23:49 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-07-07 23:48 [PATCH v1 0/5] ima-evm-utils: Assorted fixes and improvements Vitaly Chikunov
2019-07-07 23:48 ` [PATCH v1 1/5] ima-evm-utils: Fix EVP_MD_CTX leak in ima_calc_hash Vitaly Chikunov
2019-07-07 23:48 ` [PATCH v1 2/5] ima-evm-utils: Fix memory leak in init_public_keys Vitaly Chikunov
2019-07-07 23:48 ` [PATCH v1 3/5] ima-evm-utils: Preload public keys for ima_verify Vitaly Chikunov
2019-07-07 23:48 ` [PATCH v1 4/5] ima-evm-utils: Allow multiple files in ima_verify Vitaly Chikunov
2019-07-27 2:49 ` Vitaly Chikunov
2019-07-07 23:48 ` Vitaly Chikunov [this message]
2019-07-08 15:30 ` [PATCH v1 0/5] ima-evm-utils: Assorted fixes and improvements Mimi Zohar
2019-07-09 15:43 ` Vitaly Chikunov
2019-07-11 19:25 ` Mimi Zohar
2019-07-17 16:38 ` Petr Vorel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190707234837.4866-6-vt@altlinux.org \
--to=vt@altlinux.org \
--cc=dmitry.kasatkin@gmail.com \
--cc=linux-integrity@vger.kernel.org \
--cc=zohar@linux.vnet.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).