From patchwork Wed Aug 10 22:35:57 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: 9274317 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 59619600CB for ; Wed, 10 Aug 2016 22:36:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 47E4B283E6 for ; Wed, 10 Aug 2016 22:36:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3C10728409; Wed, 10 Aug 2016 22:36:37 +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]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 99EF4283E6 for ; Wed, 10 Aug 2016 22:36:36 +0000 (UTC) X-IronPort-AV: E=Sophos;i="5.28,502,1464652800"; d="scan'208";a="18384802" IronPort-PHdr: =?us-ascii?q?9a23=3APLcJtRf3brT5B6Gd7Fu8j9celGMj4u6mDksu8pMi?= =?us-ascii?q?zoh2WeGdxc+5Yx7h7PlgxGXEQZ/co6odzbGH6ua4BydZvt7B6ClEK80UEUddyI?= =?us-ascii?q?0/pE8JOIa9E0r1LfrnPWQRPf9pcxtbxUy9KlVfA83kZlff8TWY5D8WHQjjZ0Iu?= =?us-ascii?q?frymUrDbg8n/7e2u4ZqbO1wO32vkJ+ssZ0zp5UWJ749N0NMkcv5wgjLy4VJwM9?= =?us-ascii?q?xMwm1pIV/B1z3d3eyXuKBZziJLpvg6/NRBW6ipN44xTLhfESh0ezttvJ6jiAPH?= =?us-ascii?q?BTeryjNcFzxO00kAPw+Q9xz+X5HsogPmp+F932+cJsSwQrcqHXyg8KxiUgOyoD?= =?us-ascii?q?sWPD4+tmfMg4p/i7wf6Amsrhpz2YnVbMSRNeFiVr/MdtMdA2xaV4BeUDIFSpiw?= =?us-ascii?q?dKMTHuEBOqBetIC7qFwQ/jWkAgz5G+Lrzj5Bgzn9m7c92ek7DRru3Qo8EtZIu3?= =?us-ascii?q?PR/4a9D7sbTe3glPqA9j7Edf4DnG6l5Q=3D=3D?= X-IPAS-Result: =?us-ascii?q?A2EWBACFq6tX/wHyM5BdGgEBAQGDJ4FSpwmUEyOHZUwBAQE?= =?us-ascii?q?BAQECAlongjIEAxGCFQIEAQIkExQgDgMJAQEXCCEICAMBLRURBwcLBRgEiBDCM?= =?us-ascii?q?gEKAQEBI4gqhl8RAYV3BY8Oii6PEgKJaoVXkCxUhBpOAYYagTYBAQE?= Received: from unknown (HELO tarius.tycho.ncsc.mil) ([144.51.242.1]) by emsm-gh1-uea11.nsa.gov with ESMTP; 10 Aug 2016 22:36:33 +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 u7AMaELX032185; Wed, 10 Aug 2016 18:36: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 u7AMaCm3107150 for ; Wed, 10 Aug 2016 18:36:12 -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 u7AMaAS0032130; Wed, 10 Aug 2016 18:36:11 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A1DPAwABq6tX/yNjr8ZdGgEBAQGDJ4FStxqEDIYdAoFfTAEBAQEBAV6FBgIEJ1IQIDFXBxKIMcIuAQEBAQEBBAEBAQEjiCqMaAWPDooujxICj0GQLFSEGhwyAYdQAQEB X-IPAS-Result: A1DPAwABq6tX/yNjr8ZdGgEBAQGDJ4FStxqEDIYdAoFfTAEBAQEBAV6FBgIEJ1IQIDFXBxKIMcIuAQEBAQEBBAEBAQEjiCqMaAWPDooujxICj0GQLFSEGhwyAYdQAQEB X-IronPort-AV: E=Sophos;i="5.28,502,1464667200"; d="scan'208";a="5637772" 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 18:36:08 -0400 IronPort-PHdr: =?us-ascii?q?9a23=3AVevd9RdKm9MilXt34rn/a3WclGMj4u6mDksu8pMi?= =?us-ascii?q?zoh2WeGdxc++YB7h7PlgxGXEQZ/co6odzbGH6ua4BydZvt7B6ClEK80UEUddyI?= =?us-ascii?q?0/pE8JOIa9E0r1LfrnPWQRPf9pcxtbxUy9KlVfA83kZlff8TWY5D8WHQjjZ0Iu?= =?us-ascii?q?frymUrDbg8n/7e2u4ZqbO1wO32vkJ+ssZ0zp5UWJ749N0NMkcv5wgjLy4VJwM9?= =?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?A0HIBACFq6tX/yNjr8ZdGwEBAYMngVKnC?= =?us-ascii?q?ZARhAyGHQKBX0wBAQEBAQECAlongjIEARMBghQCBCdSECAxVwcSiDHCMgEBAQE?= =?us-ascii?q?BAQQBAQEBASKIKoxoBY8Oii6PEgKPQZAsVIQaHDIBh1ABAQE?= X-IPAS-Result: =?us-ascii?q?A0HIBACFq6tX/yNjr8ZdGwEBAYMngVKnCZARhAyGHQKBX0w?= =?us-ascii?q?BAQEBAQECAlongjIEARMBghQCBCdSECAxVwcSiDHCMgEBAQEBAQQBAQEBASKIK?= =?us-ascii?q?oxoBY8Oii6PEgKPQZAsVIQaHDIBh1ABAQE?= X-IronPort-AV: E=Sophos;i="5.28,502,1464652800"; d="scan'208";a="18384792" Received: from fmsmga002-icc.fm.intel.com ([198.175.99.35]) by emsm-gh1-uea11.nsa.gov with ESMTP; 10 Aug 2016 22:36:06 +0000 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos; i="5.28,502,1464678000"; d="scan'208"; a="1038936094" Received: from kamiles-mobl.amr.corp.intel.com (HELO wcrobert-MOBL1.amr.corp.intel.com) ([10.252.141.225]) by fmsmga002.fm.intel.com with ESMTP; 10 Aug 2016 15:36:06 -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 v2 2/5] libsepol: ensure key is valid before doing search Date: Wed, 10 Aug 2016 15:35:57 -0700 Message-Id: <1470868560-31328-2-git-send-email-william.c.roberts@intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1470868560-31328-1-git-send-email-william.c.roberts@intel.com> References: <1470868560-31328-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;