From patchwork Mon Aug 15 15:59:08 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: 9281497 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 3483D607FD for ; Mon, 15 Aug 2016 16:19:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1DEE328D9E for ; Mon, 15 Aug 2016 16:19:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1284E28DA3; Mon, 15 Aug 2016 16:19:46 +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]) (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 DDAAD28D9E for ; Mon, 15 Aug 2016 16:19:44 +0000 (UTC) X-IronPort-AV: E=Sophos;i="5.28,525,1464652800"; d="scan'208";a="18476794" IronPort-PHdr: =?us-ascii?q?9a23=3Aqzr46RxikyTBHVXXCy+O+j09IxM/srCxBDY+r6Qd?= =?us-ascii?q?0OkRIJqq85mqBkHD//Il1AaPBtSCrasZwLuN++C4ACpbsM7H6ChDOLV3FDY9wf?= =?us-ascii?q?0MmAIhBMPXQWbaF9XNKxIAIcJZSVV+9Gu6O0UGUOz3ZlnVv2HgpWVKQka3CwN5?= =?us-ascii?q?K6zPF5LIiIzvjqbpqsSVOlgD1WH1Iesrak7n9UOJ7oheqLAhA5558gHOrHpMdr?= =?us-ascii?q?Ye7kJTDnXXoSzB4Nyt9oVo6SVatqFp3cdBVaLnY/ZwFuQAX3wbKWR92OnH/VmG?= =?us-ascii?q?FFPOtTMgVTANnx5JBRXVxA3rVZf29C3hv6xy3zfedc/pRrkuRW6K87ZgSBiujj?= =?us-ascii?q?wOcTE+7iWfkcF5iq5BpxOt4hh+2JL8fJCeNP04eLjUO9wdWy4JRcpKfzBQCYO7?= =?us-ascii?q?KY0UBqwOOvgLgZP6og4RrB+6BACpQuip0DhCi2XqxoU71fgsFUfN2wlzTJo1rH?= =?us-ascii?q?3IoYCtZ+8pWuevwfyNlG3O?= X-IPAS-Result: =?us-ascii?q?A2E5BwDb6rFX/wHyM5BeGgEBAQGDJ4FSpxqNaoYrI4dUTAE?= =?us-ascii?q?BAQEBAQECAQJbJ4IyBAMRghUCBAECJBMUIA4DCQEBFwghCAgDAS0VEQcHCwUYB?= =?us-ascii?q?IgQvXQBCgEBASOIKoZfEQGFdwWPEIoujxYCiWqFV0iPZ1SEGk4BhW2BNgEBAQ?= Received: from unknown (HELO tarius.tycho.ncsc.mil) ([144.51.242.1]) by emsm-gh1-uea11.nsa.gov with ESMTP; 15 Aug 2016 16:17:36 +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 u7FGG129007562; Mon, 15 Aug 2016 12:16:29 -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 u7FFxVjT198288 for ; Mon, 15 Aug 2016 11:59:31 -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 u7FFxUNH005172; Mon, 15 Aug 2016 11:59:31 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A1DGBADi5bFX/yNjr8ZeGgEBAQGDJ4FStQSCKYQMhh0CgU5MAQEBAQEBAQJehQYCBCdSECAxVwcSiDG9bQEBAQEBBQEBAQEjiCqMaAWPEIoujxYCj0FIj2dUhBocMgGHIwEBAQ X-IPAS-Result: A1DGBADi5bFX/yNjr8ZeGgEBAQGDJ4FStQSCKYQMhh0CgU5MAQEBAQEBAQJehQYCBCdSECAxVwcSiDG9bQEBAQEBBQEBAQEjiCqMaAWPEIoujxYCj0FIj2dUhBocMgGHIwEBAQ X-IronPort-AV: E=Sophos;i="5.28,525,1464667200"; d="scan'208";a="5645654" 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; 15 Aug 2016 11:59:23 -0400 IronPort-PHdr: =?us-ascii?q?9a23=3AaSTT4BO1Yh2mP5M/XL8l6mtUPXoX/o7sNwtQ0KIM?= =?us-ascii?q?zox0Kfj/rarrMEGX3/hxlliBBdydsKMdzbOL+PG7ESxYuNDa4ShEKMQNHzY+yu?= =?us-ascii?q?wu1zQ6B8CEDUCpZNXLVAcdWPp4aVl+4nugOlJUEsutL3fbo3m18CJAUk6nbVk9?= =?us-ascii?q?GO35F8bogtit0KjqotuIMlwO3Wf2MOg6bE3v616A7o9O2coqA51y4yOBmmFPde?= =?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?A0FuCAAe5rFX/yNjr8ZeGwEBAYMngVKnG?= =?us-ascii?q?o1qgimEDIYdAoFOTAEBAQEBAQECAQJbJ4IyBAETAYIUAgQnUhAgMVcHEogxvW4?= =?us-ascii?q?BAQEBAQUBAQEBASKIKoxoBY8Qii6PFgKPQUiPZ1SEGhwyAYcjAQEB?= X-IPAS-Result: =?us-ascii?q?A0FuCAAe5rFX/yNjr8ZeGwEBAYMngVKnGo1qgimEDIYdAoF?= =?us-ascii?q?OTAEBAQEBAQECAQJbJ4IyBAETAYIUAgQnUhAgMVcHEogxvW4BAQEBAQUBAQEBA?= =?us-ascii?q?SKIKoxoBY8Qii6PFgKPQUiPZ1SEGhwyAYcjAQEB?= X-IronPort-AV: E=Sophos;i="5.28,525,1464652800"; d="scan'208";a="18475753" Received: from fmsmga002-icc.fm.intel.com ([198.175.99.35]) by emsm-gh1-uea11.nsa.gov with ESMTP; 15 Aug 2016 15:59:19 +0000 Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga002-icc.fm.intel.com with ESMTP; 15 Aug 2016 08:59:18 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos; i="5.28,525,1464678000"; d="scan'208"; a="1014647677" Received: from hkramach-mobl1.amr.corp.intel.com (HELO wcrobert-MOBL1.amr.corp.intel.com) ([10.254.184.14]) by orsmga001.jf.intel.com with ESMTP; 15 Aug 2016 08:59:17 -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 v3 1/7] libsepol: fix invalid access of NULL on type_val_to_struct Date: Mon, 15 Aug 2016 08:59:08 -0700 Message-Id: <1471276754-25266-2-git-send-email-william.c.roberts@intel.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1471276754-25266-1-git-send-email-william.c.roberts@intel.com> References: <1471276754-25266-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 In type_set_expand: When nprim, the table index counter, is greater than the value of initizalized entries in the type_val_to_struct[] array, detect this as invalid and return an error. Signed-off-by: William Roberts --- libsepol/src/expand.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libsepol/src/expand.c b/libsepol/src/expand.c index 0ad57f5..e6d3ef1 100644 --- a/libsepol/src/expand.c +++ b/libsepol/src/expand.c @@ -2514,6 +2514,10 @@ int type_set_expand(type_set_t * set, ebitmap_t * t, policydb_t * p, if (i > p->p_types.nprim - 1) goto err_types; + if (!p->type_val_to_struct[i]) { + goto err_types; + } + if (p->type_val_to_struct[i]->flavor == TYPE_ATTRIB) { if (ebitmap_union