From patchwork Fri Jun 3 15:09:26 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joshua Brindle X-Patchwork-Id: 9153313 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 AC9406074E for ; Fri, 3 Jun 2016 15:13:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9DEE827BFA for ; Fri, 3 Jun 2016 15:13:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 92DC428304; Fri, 3 Jun 2016 15:13:20 +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=-1.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, T_DKIM_INVALID autolearn=no 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 6D79627BFA for ; Fri, 3 Jun 2016 15:13:18 +0000 (UTC) X-IronPort-AV: E=Sophos;i="5.26,412,1459814400"; d="scan'208";a="16632787" IronPort-PHdr: =?us-ascii?q?9a23=3AcGPmuBI50azprm23nNmcpTZWNBhigK39O0sv0rFi?= =?us-ascii?q?tYgULf7xwZ3uMQTl6Ol3ixeRBMOAu6MC1bGd4/uocFdDyKjCmUhKSIZLWR4BhJ?= =?us-ascii?q?detC0bK+nBN3fGKuX3ZTcxBsVIWQwt1Xi6NU9IBJS2PAWK8TWM5DIfUi/yKRBy?= =?us-ascii?q?brysXNWC3oLpjKvioNX6WEZhunmUWftKNhK4rAHc5IE9oLBJDeIP8CbPuWZCYO?= =?us-ascii?q?9MxGlldhq5lhf44dqsrtY4q3wD888784Z8dYmyP+FhFf0LRAghZns44MztqAmL?= =?us-ascii?q?GRCC4noaT3U+jgtDAw+D6grzGJj2rH2pmPB63Xy4Otb2ULl8cy6j6atvRVe8gj?= =?us-ascii?q?0GMTI9/UnOl8Vqj7lWqw+7pgBuhYXTZdfGZ7JFYqrBcIZCFiJ6VcFLWnkEW9ux?= X-IPAS-Result: =?us-ascii?q?A2F+AwAbnlFX/wHyM5BcgzqBU7YnhiAihzRMAQEBAQEBAgJ?= =?us-ascii?q?iJ4IwfiwISAEbAgEDAQIPFRMGAQEMIAwCAwkBARcpCAgDAS0DAQUBCxEGCAsFG?= =?us-ascii?q?AQBiA2jXYExPjGKVIUoAQEFjREIEIQLimkCEQGFdgGYSY4miTElhURFjU4wgQ9?= =?us-ascii?q?UhApSiE4PF4EeAQEB?= Received: from unknown (HELO tarius.tycho.ncsc.mil) ([144.51.242.1]) by emsm-gh1-uea11.nsa.gov with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 Jun 2016 15:13:12 +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 u53F9kFR015544; Fri, 3 Jun 2016 11:10:43 -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 u53F9ew8081897 for ; Fri, 3 Jun 2016 11:09:40 -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 u53F9Yee015535 for ; Fri, 3 Jun 2016 11:09:40 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A1DVAQCpnFFXfqvYVdFcHoRvtiaCI4QIhhICgTZMAQEBAQEBEwEBCQ0JCSGEdQIBAxIVGQEBNwEPUTQBBQEcBhMiiA2jW4ExPjGKVIUoAQEFjGYBAQEBAQEEAgEcCBCEC4pphgqYSo4miTGFaUWNTjCBD4JOghBSiE6BRAEBAQ X-IPAS-Result: A1DVAQCpnFFXfqvYVdFcHoRvtiaCI4QIhhICgTZMAQEBAQEBEwEBCQ0JCSGEdQIBAxIVGQEBNwEPUTQBBQEcBhMiiA2jW4ExPjGKVIUoAQEFjGYBAQEBAQEEAgEcCBCEC4pphgqYSo4miTGFaUWNTjCBD4JOghBSiE6BRAEBAQ X-IronPort-AV: E=Sophos;i="5.26,412,1459828800"; d="scan'208";a="5488254" 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; 03 Jun 2016 11:09:36 -0400 IronPort-PHdr: =?us-ascii?q?9a23=3A6ePPnB983y3d4/9uRHKM819IXTAuvvDOBiVQ1KB9?= =?us-ascii?q?1u0cTK2v8tzYMVDF4r011RmSDdSdtakP27GempujcFJDyK7JiGoFfp1IWk1Nou?= =?us-ascii?q?QttCtkPvS4D1bmJuXhdS0wEZcKflZk+3amLRodQ56mNBXsq3G/pQQfBg/4fVIs?= =?us-ascii?q?YL+lS8iM1I/njKibwN76XUZhvHKFe7R8LRG7/036l/I9ps9cEJs30QbDuXBSeu?= =?us-ascii?q?5blitCLFOXmAvgtI/rpMYwu3cYh/V07MNEUKPnb+xsVrFcDTI7I0gp9cbrsl/F?= =?us-ascii?q?VgLJ6XwCBDY4iB1NVirC9xHnV9/bqCr8uu5wkH2QJ8zwQbQ5cS2/5r1oUxLjlT?= =?us-ascii?q?0GKy9/+2bS3J8jxJlHqQ6s8kQsi7XfZ5uYYaJz?= X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A0GoAQDrnFFXfqvYVdFcHoRvtiaCI4QIh?= =?us-ascii?q?hICgTZMAQEBAQEBAgIPAQEJDQkJIS+CMH4sCEgBARoCAQMSFRkBATcBD1E0AQU?= =?us-ascii?q?BHAYTIogNo1yBMT4xilSFKAEBBYxmAQEBAQEBBAIBHAgQhAuKaYYKmEqOJokxh?= =?us-ascii?q?WlFjU4wgQ+CToIQUohOgUQBAQE?= X-IPAS-Result: =?us-ascii?q?A0GoAQDrnFFXfqvYVdFcHoRvtiaCI4QIhhICgTZMAQEBAQE?= =?us-ascii?q?BAgIPAQEJDQkJIS+CMH4sCEgBARoCAQMSFRkBATcBD1E0AQUBHAYTIogNo1yBM?= =?us-ascii?q?T4xilSFKAEBBYxmAQEBAQEBBAIBHAgQhAuKaYYKmEqOJokxhWlFjU4wgQ+CToI?= =?us-ascii?q?QUohOgUQBAQE?= X-IronPort-AV: E=Sophos;i="5.26,412,1459814400"; d="scan'208";a="16632601" Received: from mail-qt0-f171.google.com ([209.85.216.171]) by emsm-gh1-uea11.nsa.gov with ESMTP/TLS/AES128-GCM-SHA256; 03 Jun 2016 15:09:36 +0000 Received: by mail-qt0-f171.google.com with SMTP id d51so11989268qte.2 for ; Fri, 03 Jun 2016 08:09:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quarksecurity.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=mlkA3bgJLva8llEzMXgMdcCN2hgc0DoDYNJjfNoUyXk=; b=Y5GmUMXEWTwWhYbLTeOGjZ5UoF+kP3cVBb7sl4K2NSSVB4PNkB81/qJBPO8QybYQPz m394tJD4pvEN7H2eC8nkzHFyek6kyV0z27RIss3Hw1tJK4q9Tsz8Lyzz1P98gklh0Fos eNpIYuQPBPWzNHGKPDpXzcYx1vW6KvG3tWguw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=mlkA3bgJLva8llEzMXgMdcCN2hgc0DoDYNJjfNoUyXk=; b=DgbO3jA/aHDcmCbkeTD8JOknRAEyk/FO1AQTgsPVq3iE8O6ycOlNmv6ZmOJyoxg9yu aDi4WBRkjHHMeWPtdM+xaWXHNucdXTBLJ+mzN3heIZOIkdt4oqwbEHdN2IzMFj8i9XAk TudEN7+iBrFr0eS9SDqjKsoIFb9GOfxrc5SXZ8+M8xns8Yhhy+LJNv28G/SAHcZRHwFv a1LklzKGSfsL33ttf0IuVTKimAta+NE6j+f2oyTaodKGm38nGLSmJcUZWvIogudT/l/S sVVi0sv8xevgEXHjUje1w80YRyvU8jCR1JBmCoKzJWCxwsl37KTanDuzdOavDEH2m0de UpQQ== X-Gm-Message-State: ALyK8tLpXYS0hqRljHQOZSBpuz2YQy6piIR/YiLoGxKqttb5Y5vGu+J7W9qvAM3+0drYgtyl X-Received: by 10.200.55.251 with SMTP id e56mr3751798qtc.42.1464966574781; Fri, 03 Jun 2016 08:09:34 -0700 (PDT) Received: from charmzilla.localdomain ([50.253.7.1]) by smtp.gmail.com with ESMTPSA id 96sm1157940qkz.5.2016.06.03.08.09.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 03 Jun 2016 08:09:34 -0700 (PDT) From: Joshua Brindle To: selinux Subject: [PATCH 2/2] Correctly detect unknown classes in sepol_string_to_security_class Date: Fri, 3 Jun 2016 11:09:26 -0400 Message-Id: <1464966566-14597-2-git-send-email-brindle@quarksecurity.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1464966566-14597-1-git-send-email-brindle@quarksecurity.com> References: <1464966566-14597-1-git-send-email-brindle@quarksecurity.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 Bail before running off the end of the class index Change-Id: I47c4eaac3c7d789f8d85047e34e37e3f0bb38b3a Signed-off-by: Joshua Brindle --- libsepol/src/services.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libsepol/src/services.c b/libsepol/src/services.c index d64a8e8..8679545 100644 --- a/libsepol/src/services.c +++ b/libsepol/src/services.c @@ -1155,7 +1155,7 @@ int hidden sepol_string_to_security_class(const char *class_name, char *class = NULL; sepol_security_class_t id; - for (id = 1;; id++) { + for (id = 1; id < policydb->p_classes.nprim; id++) { class = policydb->p_class_val_to_name[id - 1]; if (class == NULL) { ERR(NULL, "could not convert %s to class id", class_name); @@ -1166,6 +1166,8 @@ int hidden sepol_string_to_security_class(const char *class_name, return STATUS_SUCCESS; } } + ERR(NULL, "unrecognized class %s", class_name); + return -EINVAL; } /*