From patchwork Wed Aug 10 21:51:19 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: 9274257 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 E2F6F600CB for ; Wed, 10 Aug 2016 21:55:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D1A4128338 for ; Wed, 10 Aug 2016 21:55:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C675D2840F; Wed, 10 Aug 2016 21:55:21 +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 (smtp.nsa.gov [8.44.101.9]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2962D28338 for ; Wed, 10 Aug 2016 21:55:21 +0000 (UTC) X-IronPort-AV: E=Sophos;i="5.28,502,1464652800"; d="scan'208";a="18384260" IronPort-PHdr: =?us-ascii?q?9a23=3Ak6SnNhDJTQA1e0kb1aRWUyQJP3N1i/DPJgcQr6Af?= =?us-ascii?q?oPdwSP/4oMbcNUDSrc9gkEXOFd2CrakV0qyO7eu4CSRAuc/H6yFaNsQUFlcsso?= =?us-ascii?q?Y/p0QYGsmLCEn2frbBThcRO4B8bmJj5GyxKkNPGczzNBX4q3y26iMOSF2kbVIm?= =?us-ascii?q?btr8FoOatcmrzef6o8SVOFQRwmLjKusiZFXu9EOK55FQ2dMjYo8KiTLx6kNSfO?= =?us-ascii?q?pXwW46bXmypD3bovmKwZh47i5LsOgg/cMTGY/zfqA/UKAKRG9+azN92dfv/SXn?= =?us-ascii?q?YUPPoyJEEzZerh0dGAXB7RfnTr/toyD6sax7wyDcMsroCfg2Rj+r9bsxYAP5gy?= =?us-ascii?q?cAcTgi+SfYjdI0xLlWqRStvRt+z8vQYZqJHOZvdaPaO9UBTCxOWdgVHzdNGaug?= =?us-ascii?q?foAPCKwHJu8eoI7j9HUUqh7rGgioAOLmz3lDwGXx16Agz/8JEAfa0QhmFNUL4y?= =?us-ascii?q?ecl8n8KKpHCbP996LP1ziWKqoO1A=3D=3D?= X-IPAS-Result: =?us-ascii?q?A2EWBAAZoqtX/wHyM5BdGgEBAQGDJ4FSpwmUEyOHZUwBAQE?= =?us-ascii?q?BAQECAlongjIEAxGCFQIEAQIkExQgDgMJAQEXCCEICAMBLRURBwcLBRgEiBDCF?= =?us-ascii?q?QEKAQEBI4gqhl8RAYV3BY8Oii6PEgKJaoVXkCxUhBpOAYYagTYBAQE?= Received: from unknown (HELO tarius.tycho.ncsc.mil) ([144.51.242.1]) by emsm-gh1-uea11.nsa.gov with ESMTP; 10 Aug 2016 21:55:19 +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 u7ALtIsT027600; Wed, 10 Aug 2016 17:55:18 -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 u7ALpcXq106433 for ; Wed, 10 Aug 2016 17:51:38 -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 u7ALpTtp027154; Wed, 10 Aug 2016 17:51:29 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A1DPAwCKoKtX/yNjr8ZdGgEBAQGDJ4FStxqEDIYdAoFfTAEBAQEBAV6FBgIEJ1IQIDFXBxKIMcISAQEBAQEBBAEBAQEjiCqMaAWPDooujxICj0GQLFSEGhwyAYdQAQEB X-IPAS-Result: A1DPAwCKoKtX/yNjr8ZdGgEBAQGDJ4FStxqEDIYdAoFfTAEBAQEBAV6FBgIEJ1IQIDFXBxKIMcISAQEBAQEBBAEBAQEjiCqMaAWPDooujxICj0GQLFSEGhwyAYdQAQEB X-IronPort-AV: E=Sophos;i="5.28,502,1464667200"; d="scan'208";a="5637698" 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; 10 Aug 2016 17:51:30 -0400 IronPort-PHdr: =?us-ascii?q?9a23=3Aris5LBfot+tC/IeXMOHWTWmMlGMj4u6mDksu8pMi?= =?us-ascii?q?zoh2WeGdxc++YB7h7PlgxGXEQZ/co6odzbGH6ua4BydYsd7B6ClEK80UEUddyI?= =?us-ascii?q?0/pE8JOIa9E0r1LfrnPWQRPf9pcxtbxUy9KlVfA83kZlff8TWY5D8WHQjjZ0Iu?= =?us-ascii?q?frymUrDbg8n/7e2u4ZqbO1wO32vkJ+ssZ03m5UWJ749N0NMkcv5wgjLy4VJwM9?= =?us-ascii?q?xMwm1pIV/B1z3d3eyXuKBZziJLpvg6/NRBW6ipN44xTLhfESh0ezttvJ6jnVD5?= =?us-ascii?q?QACO/noRVHkN2loNWlCdrUKyYpCkqSb+t+xgyAGGLMb2SvYyQj3k4KB1DFfqly?= =?us-ascii?q?wOLSJj2H3Ggcx3yqRAqVSuoAI7i5XZaYeZLv1/cubZfMgGbXZQVcZWESpaC8Wz?= =?us-ascii?q?aJVLR/ENJs5EvoL9oB0IthL4Cg6yV831zTodmX7y2awz1qIqVxvB1gE6A8kmsX?= =?us-ascii?q?LIodGzP6AXArP997XB0TiWN6Ae4jz68oWdN0l5+fw=3D?= X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A0HIBAAjoatX/yNjr8ZdGwEBAYMngVKnC?= =?us-ascii?q?ZARhAyGHQKBX0wBAQEBAQECAlongjIEARMBghQCBCdSECAxVwcSiDHCFAEBAQE?= =?us-ascii?q?BAQQBAQEBASKIKoxoBY8Oii6PEgKPQZAsVIQaHDIBh1ABAQE?= X-IPAS-Result: =?us-ascii?q?A0HIBAAjoatX/yNjr8ZdGwEBAYMngVKnCZARhAyGHQKBX0w?= =?us-ascii?q?BAQEBAQECAlongjIEARMBghQCBCdSECAxVwcSiDHCFAEBAQEBAQQBAQEBASKIK?= =?us-ascii?q?oxoBY8Oii6PEgKPQZAsVIQaHDIBh1ABAQE?= X-IronPort-AV: E=Sophos;i="5.28,502,1464652800"; d="scan'208";a="18384157" Received: from fmsmga002-icc.fm.intel.com ([198.175.99.35]) by emsm-gh1-uea11.nsa.gov with ESMTP; 10 Aug 2016 21:51:28 +0000 Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga002-icc.fm.intel.com with ESMTP; 10 Aug 2016 14:51:27 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos; i="5.28,502,1464678000"; d="scan'208"; a="1012165572" Received: from kamiles-mobl.amr.corp.intel.com (HELO wcrobert-MOBL1.amr.corp.intel.com) ([10.252.141.225]) by orsmga001.jf.intel.com with ESMTP; 10 Aug 2016 14:51:26 -0700 From: william.c.roberts@intel.com To: selinux@tycho.nsa.gov, jwcart2@tycho.nsa.gov, seandroid-list@tycho.nsa.gov, sds@tycho.nsa.gov Subject: [PATCH 2/5] libsepol: ensure key is valid before doing search Date: Wed, 10 Aug 2016 14:51:19 -0700 Message-Id: <1470865882-22435-2-git-send-email-william.c.roberts@intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1470865882-22435-1-git-send-email-william.c.roberts@intel.com> References: <1470865882-22435-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 Signed-off-by: William Roberts --- libsepol/src/mls.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/libsepol/src/mls.c b/libsepol/src/mls.c index 1e84bb7..2dc5f2b 100644 --- a/libsepol/src/mls.c +++ b/libsepol/src/mls.c @@ -262,6 +262,7 @@ int mls_context_isvalid(const policydb_t * p, const context_struct_t * c) user_datum_t *usrdatum; unsigned int i, l; ebitmap_node_t *cnode; + hashtab_key_t key; if (!p->mls) return 1; @@ -279,11 +280,12 @@ int mls_context_isvalid(const policydb_t * p, const context_struct_t * c) if (!c->range.level[l].sens || c->range.level[l].sens > p->p_levels.nprim) return 0; - levdatum = (level_datum_t *) hashtab_search(p->p_levels.table, - p-> - p_sens_val_to_name - [c->range.level[l]. - sens - 1]); + + key = p->p_sens_val_to_name[c->range.level[l].sens - 1]; + if (!key) + return 0; + + levdatum = (level_datum_t *) hashtab_search(p->p_levels.table, key); if (!levdatum) return 0;