From patchwork Tue Aug 16 17:28:32 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: 9284351 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 939EA60839 for ; Tue, 16 Aug 2016 17:51:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8865628626 for ; Tue, 16 Aug 2016 17:51:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7BF1A28640; Tue, 16 Aug 2016 17:51:35 +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 2149428626 for ; Tue, 16 Aug 2016 17:51:31 +0000 (UTC) X-IronPort-AV: E=Sophos;i="5.28,529,1464652800"; d="scan'208";a="18516837" IronPort-PHdr: =?us-ascii?q?9a23=3AT/OEhhwUZnM0bSnXCy+O+j09IxM/srCxBDY+r6Qd?= =?us-ascii?q?0OkfIJqq85mqBkHD//Il1AaPBtSCrasbwLOO4uigATVGusfZ9ihaMdRlbFwssY?= =?us-ascii?q?0uhQsuAcqIWwXQDcXBSGgEJvlET0Jv5HqhMEJYS47UblzWpWCuv3ZJQk2sfTR8?= =?us-ascii?q?Kum9IIPOlcP/j7n0oMyKJVwXz2PlMPsydEzw9lSJ8JFOwMNLEeUY8lPxuHxGeu?= =?us-ascii?q?BblytDBGm4uFLC3Pq254Np6C9KuvgspIZqWKT+eLkkH/QDVGx1e10v4IXXkTWL?= =?us-ascii?q?DU7WvjpPGlkRxwFFBwnD8QHSQob6siy8sPF0niadI4m+T68/UC6+tY93WRToj2?= =?us-ascii?q?EBLDd//2bJzoRrgatdrAimphA6x4/PfKmJJfF+eeXbZtpcSm1fGo5KWzdpHpK3?= =?us-ascii?q?b4xJCfEIe+lfsdrTvVwL+AS/AQ2tDeapwXlSgXX7x7Eh++UnDQzCmgcnGoFd+E?= =?us-ascii?q?/Ipcn4Yf9BGdu+y7PFmHCaN/4=3D?= X-IPAS-Result: =?us-ascii?q?A2FKBgD4ULNX/wHyM5BeGgEBAQGDJ4FSpyaUFiOHXEwBAQE?= =?us-ascii?q?BAQEBAgECWyeCMgQDEYIVAgQBAiQTFCAOAwkBARcIIQgIAwEtFREHBwsFGASIE?= =?us-ascii?q?L5mAQoBAQEjiCqGXxEBhXcFjxKKL48ZAolrhViQMFSEGk4BhWCBNgEBAQ?= Received: from unknown (HELO tarius.tycho.ncsc.mil) ([144.51.242.1]) by emsm-gh1-uea11.nsa.gov with ESMTP; 16 Aug 2016 17:49: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 u7GHm5ae010138; Tue, 16 Aug 2016 13:48:26 -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 u7GHT0Si243285 for ; Tue, 16 Aug 2016 13:29:00 -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 u7GHSxvD007848; Tue, 16 Aug 2016 13:28:59 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A1BvBQCWS7NX/yNjr8ZeGgEBAQGDJ4FStzqEDIYdAoFUTAEBAQEBAQECXoUGAgQnUhAgMVcHEogxvlQBAQEBAQEEAQEBASOIKoxoBY8Sii+PGQKPQ5AwVIQaHDIBhxYBAQE X-IPAS-Result: A1BvBQCWS7NX/yNjr8ZeGgEBAQGDJ4FStzqEDIYdAoFUTAEBAQEBAQECXoUGAgQnUhAgMVcHEogxvlQBAQEBAQEEAQEBASOIKoxoBY8Sii+PGQKPQ5AwVIQaHDIBhxYBAQE X-IronPort-AV: E=Sophos;i="5.28,529,1464667200"; d="scan'208";a="5648260" 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; 16 Aug 2016 13:28:53 -0400 IronPort-PHdr: =?us-ascii?q?9a23=3AlLFMth2n0SoM9KgwsmDT+DRfVm0co7zxezQtwd8Z?= =?us-ascii?q?sekSLPad9pjvdHbS+e9qxAeQG96KsrQd1KGP6/GoGTRZp83Q6DZaKN0EfiRGoP?= =?us-ascii?q?1epxYnDs+BBB+zB9/RRAt+Iv5/UkR49WqwK0lfFZW2TVTTpnqv8WxaQU2nZkJL?= =?us-ascii?q?L+j4UrTfk96wn7jrvcaCOkMR23HkOeI6bE3v616A7o9O2coqA51y4yOBmmFPde?= =?us-ascii?q?VSyDEgDnOotDG42P2N+oV++T9bofMr+p0Ie6z7e6MlUe4QV2x+YCgdrffmvhjb?= =?us-ascii?q?TAaJ+mBUEiBPykIJUED560ThU5PwtDbqnvZs0ymde8vtRPY7Xirmp6V0QxbylH?= =?us-ascii?q?0vKy8y8GaRjNd5yq1cvlbpvBF2xYLOZ4CZcf5/Zb/1YcIRRW0HWN1YESNGHMf0?= =?us-ascii?q?dIcUJ/YQNuZf6Y/mrh0BqgXtKxOrAbbwyztMh3bzm6Z8yeMrHBvaxyQhGc4DtD?= =?us-ascii?q?Lfq9CmZ+8pTempwfyQnn34ZPRM1GK4sdCQfw=3D=3D?= X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A0FYBwBDTLNX/yNjr8ZeGwEBAYMngVKnJ?= =?us-ascii?q?pAUhAyGHQKBVEwBAQEBAQEBAgECWyeCMgQBEwGCFAIEJ1IQIDFXBxKIMb5UAQE?= =?us-ascii?q?BAQEBBAEBAQEBIogqjGgFjxKKL48ZAo9DkDBUhBocMgGHFgEBAQ?= X-IPAS-Result: =?us-ascii?q?A0FYBwBDTLNX/yNjr8ZeGwEBAYMngVKnJpAUhAyGHQKBVEw?= =?us-ascii?q?BAQEBAQEBAgECWyeCMgQBEwGCFAIEJ1IQIDFXBxKIMb5UAQEBAQEBBAEBAQEBI?= =?us-ascii?q?ogqjGgFjxKKL48ZAo9DkDBUhBocMgGHFgEBAQ?= X-IronPort-AV: E=Sophos;i="5.28,529,1464652800"; d="scan'208";a="18515583" Received: from fmsmga002-icc.fm.intel.com ([198.175.99.35]) by emsm-gh1-uea11.nsa.gov with ESMTP; 16 Aug 2016 17:28:45 +0000 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos; i="5.28,529,1464678000"; d="scan'208"; a="1042217071" Received: from mtbauma1-mobl.amr.corp.intel.com (HELO wcrobert-MOBL1.amr.corp.intel.com) ([10.255.79.225]) by fmsmga002.fm.intel.com with ESMTP; 16 Aug 2016 10:28:40 -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 v4 2/7] libsepol: ensure key is valid before doing search Date: Tue, 16 Aug 2016 10:28:32 -0700 Message-Id: <1471368517-20552-3-git-send-email-william.c.roberts@intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1471368517-20552-1-git-send-email-william.c.roberts@intel.com> References: <1471368517-20552-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;