From patchwork Thu May 5 20:44:19 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Carter X-Patchwork-Id: 9027371 Return-Path: X-Original-To: patchwork-selinux@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id E6E879F6E1 for ; Thu, 5 May 2016 20:46:07 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4998D203DF for ; Thu, 5 May 2016 20:46:06 +0000 (UTC) Received: from emsm-gh1-uea11.nsa.gov (smtp.nsa.gov [8.44.101.9]) by mail.kernel.org (Postfix) with ESMTP id 86D66203E6 for ; Thu, 5 May 2016 20:46:05 +0000 (UTC) X-IronPort-AV: E=Sophos;i="5.24,583,1454976000"; d="scan'208";a="15926907" IronPort-PHdr: =?us-ascii?q?9a23=3ACEE69RcrFXPtgtAsz4qLBnwclGMj4u6mDksu8pMi?= =?us-ascii?q?zoh2WeGdxc6/bB7h7PlgxGXEQZ/co6odzbGG4ua4BSdZvM7JmUtBWaIPfidNsd?= =?us-ascii?q?8RkQ0kDZzNImzAB9muURYHGt9fXkRu5XCxPBsdMs//Y1rPvi/6tmZKSV3BPAZ4?= =?us-ascii?q?bt74BpTVx5zukbviqtuLP04R2WL1SIgxBSv1hD2ZjtMRj4pmJ/R54TryiVwMRd?= =?us-ascii?q?5rw3h1L0mYhRf265T41pdi9yNNp6BprJYYAu3HZaBwcZh0RHRjaTh0t4XXskzY?= =?us-ascii?q?QA+O4GYMenkHmRpPRQ7e5Vf1WYminDH9s79f0SyXJoXdRKooVC7qu6V0QxbylH?= =?us-ascii?q?0vKy8y8GaRjNd5yq1cvkTy9FRE34fIbdTNZ7JFdaTHcIZfHzJM?= X-IPAS-Result: =?us-ascii?q?A2F1BQBnsCtX/wHyM5BfHAGDG4FBD7sXJIc1TAEBAQEBAQI?= =?us-ascii?q?CYieCLYIVAgQBAiQTFCAOAwkBARcpCAgDAS0VEQ4LBRgEiAnADo59EQFohQ0Fm?= =?us-ascii?q?BqOGQKJUIVBjzRihAdQhniBNQEBAQ?= 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; 05 May 2016 20:46:03 +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 u45Kk1Uc014385; Thu, 5 May 2016 16:46:02 -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 u45Kgf3H040143 for ; Thu, 5 May 2016 16:42:41 -0400 Received: from moss-lions.infosec.tycho.ncsc.mil (moss-lions [192.168.25.4]) by tarius.tycho.ncsc.mil (8.14.4/8.14.4) with ESMTP id u45Kgehp013386 for ; Thu, 5 May 2016 16:42:41 -0400 From: James Carter To: selinux@tycho.nsa.gov Subject: [PATCH 6/6 v3] libsepol: When generating CIL use HLL line mark for neverallows Date: Thu, 5 May 2016 16:44:19 -0400 Message-Id: <1462481059-12437-7-git-send-email-jwcart2@tycho.nsa.gov> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1462481059-12437-1-git-send-email-jwcart2@tycho.nsa.gov> References: <1462481059-12437-1-git-send-email-jwcart2@tycho.nsa.gov> 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-Spam-Status: No, score=-4.0 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When converting pp files to CIL or generating CIL using checkpolicy or checkmodule use CIL's HLL line mark annotations to record the original file and line numbers for neverallow rules so that CIL can produce more informative error messages. (Unfortunately, the original line number information is not saved in pp files, so there is no benefit for policy modules.) This is only done for neverallow rules currently. Signed-off-by: James Carter --- libsepol/src/module_to_cil.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/libsepol/src/module_to_cil.c b/libsepol/src/module_to_cil.c index 38f0dc3..b9a4af7 100644 --- a/libsepol/src/module_to_cil.c +++ b/libsepol/src/module_to_cil.c @@ -1073,6 +1073,10 @@ static int avrule_list_to_cil(int indent, struct policydb *pdb, struct avrule *a struct type_set *ts; for (avrule = avrule_list; avrule != NULL; avrule = avrule->next) { + if (avrule->specified == AVRULE_NEVERALLOW && avrule->source_filename) { + cil_println(0, ";;* lmx %lu %s\n",avrule->source_line, avrule->source_filename); + } + ts = &avrule->stypes; rc = process_typeset(indent, pdb, ts, attr_list, &snames, &num_snames); if (rc != 0) { @@ -1103,6 +1107,10 @@ static int avrule_list_to_cil(int indent, struct policydb *pdb, struct avrule *a names_destroy(&snames, &num_snames); names_destroy(&tnames, &num_tnames); + + if (avrule->specified == AVRULE_NEVERALLOW && avrule->source_filename) { + cil_println(0, ";;* lme\n"); + } } return 0;