From patchwork Mon Oct 17 20:24:06 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Roberts, William C" X-Patchwork-Id: 9380515 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id BBCE3600CA for ; Mon, 17 Oct 2016 20:29:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B038128F34 for ; Mon, 17 Oct 2016 20:29:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A4FDE28F41; Mon, 17 Oct 2016 20:29:33 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from emsm-gh1-uea11.nsa.gov (emsm-gh1-uea11.nsa.gov [8.44.101.9]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AA8D228F3F for ; Mon, 17 Oct 2016 20:29:32 +0000 (UTC) X-IronPort-AV: E=Sophos;i="5.31,358,1473120000"; d="scan'208";a="20138032" IronPort-PHdr: =?us-ascii?q?9a23=3APQKNqBfI/lHC/W5axupSmfvelGMj4u6mDksu8pMi?= =?us-ascii?q?zoh2WeGdxc6zZh7h7PlgxGXEQZ/co6odzbGH6ea9AydZusfJmUtBWaQEbwUCh8?= =?us-ascii?q?QSkl5oK+++Imq/EsTXaTcnFt9JTl5v8iLzG0FUHMHjew+a+SXqvnYsExnyfTB4?= =?us-ascii?q?Ov7yUtaLyZ/mjabvodaKOFQArQH+SIs6FA+xowTVu5teqqpZAYF19CH0pGBVcf?= =?us-ascii?q?9d32JiKAHbtR/94sCt4MwrqHwI6Loc7coIbYHWN+R9FOQZX3waNDUu6cnqswTT?= =?us-ascii?q?ZRee7XsbFGMNm1xHBBaBpAr3V5H9qCz7uq952TKGFdHnRrAzHzK55uFkTwGswD?= =?us-ascii?q?wLLBYl4WrXjYp2l6sdrxW/9DJlxIuBf4CRMPt3e+XWO8kdT2dbQt15VipdD4f6?= =?us-ascii?q?ZIwKXLlJBvpRs4So/whGlhC5HwT5Qbq3xw=3D=3D?= X-IPAS-Result: =?us-ascii?q?A2H0BwAtNAVY/wHyM5BbGwEBAQMBAQEJAQEBFwEBBAEBCgE?= =?us-ascii?q?BgxEBAQEBAR1XfKQ6gVsfAZQ8JgOBeFSFJUwBAQEBAQEBAQIBAlsngjIEAxMFe?= =?us-ascii?q?Vs9AgQBAjcUIA4DCQEBFwghCAgDAS0VEQcHCwUYBIgXAxfCVgEliEKFF4FSEQG?= =?us-ascii?q?FewWaBoYoiVwCgjqHRIV1kHtUg1AcgW9WAYZgeIEoAQEB?= Received: from unknown (HELO tarius.tycho.ncsc.mil) ([144.51.242.1]) by emsm-gh1-uea11.nsa.gov with ESMTP; 17 Oct 2016 20:29:10 +0000 Received: from prometheus.infosec.tycho.ncsc.mil (prometheus [192.168.25.40]) by tarius.tycho.ncsc.mil (8.14.4/8.14.4) with ESMTP id u9HKT9Bx001194; Mon, 17 Oct 2016 16:29:09 -0400 Received: from tarius.tycho.ncsc.mil (tarius.infosec.tycho.ncsc.mil [144.51.242.1]) by prometheus.infosec.tycho.ncsc.mil (8.15.2/8.15.2) with ESMTP id u9HKOvQ1165470 for ; Mon, 17 Oct 2016 16:24:57 -0400 Received: from goalie.tycho.ncsc.mil (goalie [144.51.242.250]) by tarius.tycho.ncsc.mil (8.14.4/8.14.4) with ESMTP id u9HKOuRa032743; Mon, 17 Oct 2016 16:24:57 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A1AkBAC1MgVY/yNjr8ZbGgEBAQECAQEBAQgBAQEBgzwBAQEBAR1XfKQ6kimEFyCCTIM2AoFtTAECAQEBAQECXoUJAgR5ECAxVwcSiDgDF8JIAQEIAiaIQoUXh18FmgaGKIlcAoI6jTmQe1SDUByBbyI0AYkAAQEB X-IPAS-Result: A1AkBAC1MgVY/yNjr8ZbGgEBAQECAQEBAQgBAQEBgzwBAQEBAR1XfKQ6kimEFyCCTIM2AoFtTAECAQEBAQECXoUJAgR5ECAxVwcSiDgDF8JIAQEIAiaIQoUXh18FmgaGKIlcAoI6jTmQe1SDUByBbyI0AYkAAQEB X-IronPort-AV: E=Sophos;i="5.31,358,1473134400"; d="scan'208";a="5767606" Received: from emsm-gh1-uea11.corp.nsa.gov (HELO emsm-gh1-uea11.nsa.gov) ([10.208.41.37]) by goalie.tycho.ncsc.mil with ESMTP; 17 Oct 2016 16:24:55 -0400 IronPort-PHdr: =?us-ascii?q?9a23=3A/BHoSR1V7mB9uuZ0smDT+DRfVm0co7zxezQtwd8Z?= =?us-ascii?q?sekXLfad9pjvdHbS+e9qxAeQG96KsbQZ0aGP6PGocFdDyK7JiGoFfp1IWk1Nou?= =?us-ascii?q?QttCtkPvS4D1bmJuXhdS0wEZcKflZk+3amLRodQ56mNBXsq3G/pQQfBg/4fVIs?= =?us-ascii?q?YL+kQMiP1Y/ujLH60qaQSj0AvCC6b7J2IUf+hiTqne5Sv7FfLL0swADCuHpCdr?= =?us-ascii?q?ce72ppIVWOg0S0vZ/or9ZLuh5dsPM59sNGTb6yP+FhFeQZXwIdNHop6cHRuBLC?= =?us-ascii?q?VVHHpidEEzZerh0dGAXB7RfnTr/toyD6sax7wyDcMsroCfgvVD2k471sSROtjC?= =?us-ascii?q?YcKxYl4WrXjYp2l6sdrxW/41Rkz5X8fJCeNP04eLjUO9wdWzlvRMFUAjNABoe9?= =?us-ascii?q?Zo5JBKwbOuxVtZXmj1oIsRa6QwKrAbC8ggRUj2P7iPVpm98qFhvLiUl+R98=3D?= X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A0HLBgAxMwVY/yNjr8ZbGgEBAQECAQEBA?= =?us-ascii?q?QgBAQEBFgEBAQMBAQEJAQEBgxEBAQEBAR1XfKQ6gVsfAZAuhBcggXhUgzYCgW1?= =?us-ascii?q?MAQEBAQEBAQECAQJbJ4IyBAEVBXlbPQIEeRAgMVcHEog4AxfCSAEBCAIBJYhCh?= =?us-ascii?q?ReHXwWaBoYoiVwCgjqNOZB7VINQHIFvIjQBhz+BQQEBAQ?= X-IPAS-Result: =?us-ascii?q?A0HLBgAxMwVY/yNjr8ZbGgEBAQECAQEBAQgBAQEBFgEBAQM?= =?us-ascii?q?BAQEJAQEBgxEBAQEBAR1XfKQ6gVsfAZAuhBcggXhUgzYCgW1MAQEBAQEBAQECA?= =?us-ascii?q?QJbJ4IyBAEVBXlbPQIEeRAgMVcHEog4AxfCSAEBCAIBJYhChReHXwWaBoYoiVw?= =?us-ascii?q?CgjqNOZB7VINQHIFvIjQBhz+BQQEBAQ?= X-IronPort-AV: E=Sophos;i="5.31,358,1473120000"; d="scan'208";a="20137874" Received: from fmsmga002-icc.fm.intel.com ([198.175.99.35]) by emsm-gh1-uea11.nsa.gov with ESMTP; 17 Oct 2016 20:24:49 +0000 Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga002-icc.fm.intel.com with ESMTP; 17 Oct 2016 13:24:48 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos; i="5.31,358,1473145200"; d="scan'208"; a="1046007556" Received: from mcohen2-mobl.amr.corp.intel.com (HELO wcrobert-MOBL1.amr.corp.intel.com) ([10.254.186.130]) by orsmga001.jf.intel.com with ESMTP; 17 Oct 2016 13:24:47 -0700 From: william.c.roberts@intel.com To: selinux@tycho.nsa.gov, seandroid-list@tycho.nsa.gov, sds@tycho.nsa.gov Subject: [PATCH 4/8] libselinux: fix required alignment for sha1.c on mac Date: Mon, 17 Oct 2016 16:24:06 -0400 Message-Id: <1476735850-7844-4-git-send-email-william.c.roberts@intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1476735850-7844-1-git-send-email-william.c.roberts@intel.com> References: <1476735850-7844-1-git-send-email-william.c.roberts@intel.com> X-BeenThere: selinux@tycho.nsa.gov X-Mailman-Version: 2.1.20 Precedence: list List-Id: "Security-Enhanced Linux \(SELinux\) mailing list" List-Post: List-Help: MIME-Version: 1.0 Errors-To: selinux-bounces@tycho.nsa.gov Sender: "Selinux" X-Virus-Scanned: ClamAV using ClamSMTP From: William Roberts When building on mac with ANDROID_HOST=y, clang complains: sha1.c:73:33: error: cast from 'uint8_t *' (aka 'unsigned char *') to 'CHAR64LONG16 *' increases required alignment from 1 to 4 [-Werror,-Wcast-align] CHAR64LONG16* block = (CHAR64LONG16*) workspace; Rather then casting the bytearray to the CHAR64LONG16 union, just create a stack workspace of type CHAR64LONG16. This will prevent alignment issues with the data accesses. Signed-off-by: William Roberts --- libselinux/src/sha1.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/libselinux/src/sha1.c b/libselinux/src/sha1.c index 5f02af8..9bcbb6e 100644 --- a/libselinux/src/sha1.c +++ b/libselinux/src/sha1.c @@ -8,8 +8,14 @@ // Modified by WaterJuice retaining Public Domain license. // // This is free and unencumbered software released into the public domain - June 2013 waterjuice.org -// Modified to stop symbols being exported for libselinux shared library - October 2015 +// Modified to: +// - stop symbols being exported for libselinux shared library - October 2015 // Richard Haines +// - Not cast the workspace from a byte array to a CHAR64LONG16 due to allignment isses. +// Fixes: +// sha1.c:73:33: error: cast from 'uint8_t *' (aka 'unsigned char *') to 'CHAR64LONG16 *' increases required alignment from 1 to 4 [-Werror,-Wcast-align] +// CHAR64LONG16* block = (CHAR64LONG16*) workspace; +// William Roberts /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -69,8 +75,8 @@ void uint32_t c; uint32_t d; uint32_t e; - uint8_t workspace[64]; - CHAR64LONG16* block = (CHAR64LONG16*) workspace; + CHAR64LONG16 workspace; + CHAR64LONG16* block = &workspace; memcpy( block, buffer, 64 );