From patchwork Tue Aug 16 17:28:31 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: 9284337 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 3E1AD60574 for ; Tue, 16 Aug 2016 17:36:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 31E74286BB for ; Tue, 16 Aug 2016 17:36:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2694A288F0; Tue, 16 Aug 2016 17:36:08 +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 D8BB5286BB for ; Tue, 16 Aug 2016 17:36:05 +0000 (UTC) X-IronPort-AV: E=Sophos;i="5.28,529,1464652800"; d="scan'208";a="18515966" IronPort-PHdr: =?us-ascii?q?9a23=3ADFIIehffZu27yc9z2iThUyo8lGMj4u6mDksu8pMi?= =?us-ascii?q?zoh2WeGdxc+5bR7h7PlgxGXEQZ/co6odzbGH6ua5BidZucfJ8ChbNscdD1ld0Y?= =?us-ascii?q?RetjdjKfbNMVf8Iv/uYn5yN+V5f3ghwUuGN1NIEt31fVzYry76xzcTHhLiKVg9?= =?us-ascii?q?fbytScbshsi6n9q/54fUK10RwmHsOPUrc17v9VSZ9pFPx9AzcuBpklqBi0ALUt?= =?us-ascii?q?we/XlvK1OXkkS0zeaL17knzR5tvek8/dVLS6TwcvdwZ7VZCDM7LzJ9v5Wz5lH+?= =?us-ascii?q?Vw/H2l8wGiVTy0IJUED560ThU5PwtDbqnvZs0ymde8vtRPY7Xirmp6V0QxbylH?= =?us-ascii?q?0vKy8y8GaRjNd5yq1cvlbpvBF2xYLOZ4CZcf5/Zb/1YcIRRW0HWN1YESNGHMf0?= =?us-ascii?q?dIcUJ/YQNuZf6Y/mrh0BqgXtKxOrAbbwyztMh3bzm6Z8yeMrHBvaxyQhGc4DtD?= =?us-ascii?q?Lfq9CmZ+8pTempwfyQnn34ZPRM1GK4sdDF?= X-IPAS-Result: =?us-ascii?q?A2FLBgB8TrNX/wHyM5BeGgEBAQGDJ4FSpyaNa4YrI4dbTAE?= =?us-ascii?q?BAQEBAQECAQJbJ4IyBAMRghUCBAECJBMUIA4DCQEBFwghCAgDAS0VEQcHCwUYB?= =?us-ascii?q?IgQvloBCgEBASOIKoZfEQGFdwWPEoovjxkCiWuFWEiPaFSEGk4BhWCBNgEBAQ?= Received: from unknown (HELO tarius.tycho.ncsc.mil) ([144.51.242.1]) by emsm-gh1-uea11.nsa.gov with ESMTP; 16 Aug 2016 17:34:20 +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 u7GHXKJ2008684; Tue, 16 Aug 2016 13:33:38 -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 u7GHSx4v243280 for ; Tue, 16 Aug 2016 13:28:59 -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 u7GHSxvC007848; Tue, 16 Aug 2016 13:28:59 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A1BvBQCWS7NX/yNjr8ZeGgEBAQGDJ4FStRGCKYQMhh0CgVRMAQEBAQEBAQJehQYCBCdSECAxVwcSiDG+VAEBAQEBBQEBAQEjiCqMaAWPEoovjxkCj0NIj2hUhBocMgGHFgEBAQ X-IPAS-Result: A1BvBQCWS7NX/yNjr8ZeGgEBAQGDJ4FStRGCKYQMhh0CgVRMAQEBAQEBAQJehQYCBCdSECAxVwcSiDG+VAEBAQEBBQEBAQEjiCqMaAWPEoovjxkCj0NIj2hUhBocMgGHFgEBAQ X-IronPort-AV: E=Sophos;i="5.28,529,1464667200"; d="scan'208";a="5648259" 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:52 -0400 IronPort-PHdr: =?us-ascii?q?9a23=3AoyZFMBEHUTCsdfWTCuuiEp1GYnF86YWxBRYc798d?= =?us-ascii?q?s5kLTJ74o8qwAkXT6L1XgUPTWs2DsrQf2rOQ6v+rADRRqdbZ6TZZIcQKD0dEwe?= =?us-ascii?q?wt3CUYSPafDkP6KPO4JwcbJ+9lEGFfwnegLEJOE9z/bVCB6le77DoVBwmtfVEt?= =?us-ascii?q?fre9JIfegoyN2vyo/NWLOkMT1WP7OOw5dU3n5UWJ749N0NMkcv5wgjLy4VJwM9?= =?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?A0FZBwBDTLNX/yNjr8ZeGwEBAYMngVKnJ?= =?us-ascii?q?o1rgimEDIYdAoFUTAEBAQEBAQECAQJbJ4IyBAETAYIUAgQnUhAgMVcHEogxvlQ?= =?us-ascii?q?BAQEBAQUBAQEBASKIKoxoBY8Sii+PGQKPQ0iPaFSEGhwyAYcWAQEB?= X-IPAS-Result: =?us-ascii?q?A0FZBwBDTLNX/yNjr8ZeGwEBAYMngVKnJo1rgimEDIYdAoF?= =?us-ascii?q?UTAEBAQEBAQECAQJbJ4IyBAETAYIUAgQnUhAgMVcHEogxvlQBAQEBAQUBAQEBA?= =?us-ascii?q?SKIKoxoBY8Sii+PGQKPQ0iPaFSEGhwyAYcWAQEB?= X-IronPort-AV: E=Sophos;i="5.28,529,1464652800"; d="scan'208";a="18515580" Received: from fmsmga002-icc.fm.intel.com ([198.175.99.35]) by emsm-gh1-uea11.nsa.gov with ESMTP; 16 Aug 2016 17:28:44 +0000 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos; i="5.28,529,1464678000"; d="scan'208"; a="1042217067" 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 1/7] libsepol: fix invalid access of NULL on type_val_to_struct Date: Tue, 16 Aug 2016 10:28:31 -0700 Message-Id: <1471368517-20552-2-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 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