Re: [PATCH] libsepol/cil: Add userattribute{set} functionality

2015-09-11 Thread James Carter
On 09/10/2015 12:56 PM, Yuli Khodorkovskiy wrote: This adds a userattribute statement that may be used in userroles and constraints. The syntax is the same as typeattributset. Also, disallow roleattributes where roles are accepted in contexts. Specify a userattribute (userattribute foo)

Re: [PATCH] libsepol/cil: Fix uninitialized false positive in cil_binary

2015-09-11 Thread James Carter
= NULL; int start_new_range; -- James Carter <jwca...@tycho.nsa.gov> National Security Agency ___ Selinux mailing list Selinux@tycho.nsa.gov To unsubscribe, send email to selinux-le...@tycho.nsa.gov. To get help, send an email containing "help

Re: secilc: any idea why this commit causes secilc to segfault?

2015-09-09 Thread James Carter
linux-requ...@tycho.nsa.gov. -- James Carter <jwca...@tycho.nsa.gov> National Security Agency ___ Selinux mailing list Selinux@tycho.nsa.gov To unsubscribe, send email to selinux-le...@tycho.nsa.gov. To get help, send an email containing "

Re: secilc: in segfault

2015-09-09 Thread James Carter
On 09/03/2015 09:20 AM, Dominick Grift wrote: On Thu, Sep 03, 2015 at 08:18:17AM -0400, James Carter wrote: On 09/03/2015 05:48 AM, Dominick Grift wrote: Anyone tried "secilc test/in_test.cil" lately? It dumps core here. $ secilc test/in_test.cil Segmentation fault (core dumped)

Re: [PATCH] libsepol/cil: fix NULL pointer dereference when copying classpermission/set

2015-09-09 Thread James Carter
classpermissionset *orig = data; struct cil_classpermissionset *new = NULL; + cil_classpermissionset_init(); + new->set_str = orig->set_str; cil_copy_classperms_list(orig->classperms, >classperms); -- James Carter <jwca...@tycho.

Re: Find attributes for a type with sepol

2015-09-24 Thread James Carter
On 09/23/2015 06:39 PM, Roberts, William C wrote: How would one find all the attributes of a type with libsepol, can someone point me to any relevant structures or functions? The policydb_t structure has type_attr_map field which maps types to an ebitmap of attributes. Jim -- James

Re: [PATCH] libsepol/cil: Validate extended avrules and permissionxs

2015-12-08 Thread James Carter
(db, node); break; + case CIL_AVRULEX: + rc = __cil_verify_avrulex(node); + break; + case CIL_PERMISSIONX: + rc = __cil_verify_permissionx(node->data, node); +

Re: [PATCH 1/2] libsepol/cil: Add support for neverallowx

2015-12-02 Thread James Carter
On 12/01/2015 10:38 AM, Steve Lawrence wrote: Add a new statement, neverallowx, which has the same syntax as allowx: (neverallowx foo bar (ioctl file (0x2000 20FF))) This should be: (neverallowx foo bar (ioctl file (range 0x2000 0x20FF))) (allowx foo bar (ioctl file (0x20A0))) ; this

Re: CIL Wiki Translate

2016-01-05 Thread James Carter
a FreeBSD license and you are free to upload and share that (and any translation) from your website under that license. Thanks for your interest in CIL and your work! Jim Kind Regards, OMO -- James Carter <jwca...@tycho.nsa.gov> National Security

Re: [PATCH] policycoreutils/sandbox: Fix sandbox to propagate specified MCS/MLS Security Level.

2015-11-20 Thread James Carter
ions.level or self.__options.session: - return - if self.__options.homedir: selinux.chcon(self.__options.homedir, self.__filecon, recursive=True) self.__homedir = self.__options.homedir -- James Carter <jwca...@

Re: [PATCH] policycoreutils: improve sepolicy command line interface

2015-11-19 Thread James Carter
; 1: +parser_args = sys.argv[1:] else: -args = parser.parse_args() +parser_args = ["-h"] +args = parser.parse_args(args=parser_args) args.func(args) sys.exit(0) except ValueError, e:

Re: [PATCH] policycoreutils: Require at least one argument for 'semanage permissive -d'

2015-11-19 Thread James Carter
permissiveParser.add_argument('type', nargs='?', default=None, help=_('type')) +permissiveParser.add_argument('type', nargs='+', default=None, help=_('type')) permissiveParser.set_defaults(func=handlePermissive) -- James Carter <jwca...@tycho.nsa.gov> National Security Agency ___

Re: [PATCH] policycoreutils: fix typos in semanage manpages

2016-06-06 Thread James Carter
age/semanage-port.8 +++ b/policycoreutils/semanage/semanage-port.8 @@ -53,7 +53,7 @@ Protocol for the specified port (tcp|udp) or internet protocol version for the s .SH EXAMPLE .nf -List all port defitions +List all port definitions # semanage port \-l Allow Apache to listen on tcp port 81

Re: [PATCH] Sort object files for deterministic linking order

2016-06-06 Thread James Carter
,$(sort $(wildcard $(CILDIR)/src/*.c)) $(CIL_GENERATED))) override CFLAGS += -I$(CILDIR)/include endif -- James Carter <jwca...@tycho.nsa.gov> National Security Agency ___ Selinux mailing list Selinux@tycho.nsa.gov To unsubscribe,

Re: [PATCH] policycoreutils/semodule: Fix the documentation of -l,--list

2016-06-06 Thread James Carter
); printf(" -X,--priority=PRIORITYset priority for following operations (1-999)\n"); -- James Carter <jwca...@tycho.nsa.gov> National Security Agency ___ Selinux mailing list Selinux@tycho.nsa.gov To unsubscr

Re: Strange AVC with latest rawhide kernel.

2016-02-26 Thread James Carter
fails. Nothing crazy happened though. I don't currently have a rawhide machine to try it on. -- James Carter <jwca...@tycho.nsa.gov> National Security Agency ___ Selinux mailing list Selinux@tycho.nsa.gov To unsubscribe, send email to seli

Re: User range vs. context's range

2016-01-22 Thread James Carter
that there was a difference. -- James Carter <jwca...@tycho.nsa.gov> National Security Agency ___ Selinux mailing list Selinux@tycho.nsa.gov To unsubscribe, send email to selinux-le...@tycho.nsa.gov. To get help, send an email containing "help"

Re: [PATCH] libsepol/cil: fix bug when resetting class permission values

2016-03-19 Thread James Carter
_perms -= common->num_perms; -- James Carter <jwca...@tycho.nsa.gov> National Security Agency ___ Selinux mailing list Selinux@tycho.nsa.gov To unsubscribe, send email to selinux-le...@tycho.nsa.gov. To get help, send an email containing "help" to selinux-requ...@tycho.nsa.gov.

[PATCH 0/2 v2] Warn if module name different than output filename

2016-04-07 Thread James Carter
re are now only two checks and the base filename is used in the warning message, it no longer made sense to create common helper functions in libsepol. James Carter (2): policycoreutils/hll/pp: Warn if module name different than output filename checkpolicy: Warn if module name different t

[PATCH 1/2 v3] policycoreutils/hll/pp: Warn if module name different than output filename

2016-04-08 Thread James Carter
to it by its filename. Because of this, provide a warning message when converting a policy package to CIL and the output filename is different than the module name. Signed-off-by: James Carter <jwca...@tycho.nsa.gov> --- policycoreutils/hll/pp/pp.c | 33 +

[PATCH 0/2 v3] Check if module name different than output filename

2016-04-08 Thread James Carter
me - Since there are now only two checks and the base filename is used in the warning message, it no longer made sense to create common helper functions in libsepol. Changes from v2: - Check if strdup() returns NULL - Have checkmodule fail rather than give a warning James Carter (2): policycoreut

[PATCH 2/2 v3] checkpolicy: Fail if module name different than output base filename

2016-04-08 Thread James Carter
to it by its filename. Because of this, have checkmodule fail when compiling a module and the output base filename is different than the module name. Signed-off-by: James Carter <jwca...@tycho.nsa.gov> --- checkpolicy/checkmodule.c | 20 1 file changed, 20 insertions(+)

Re: [PATCH 0/2 v3] Check if module name different than output filename

2016-04-12 Thread James Carter
On 04/08/2016 11:02 AM, James Carter wrote: Since CIL treats files as modules and does not have a separate module statement it can cause confusion when a Refpolicy module has a name that is not the same as its base filename because older SELinux userspaces will refer to the module by its module

Re: [PATCH] libselinux: Fix typo in sefcontext_compile.8

2016-04-12 Thread James Carter
.B sefcontext_compile -writes the compiled prce file with the +writes the compiled pcre file with the .B .bin suffix appended (e.g. \fIinputfile\fB.bin\fR). .SH OPTIONS -- James Carter <jwca...@tycho.nsa.gov> National Security Agency ___

[PATCH 3/3] checkpolicy: Warn if module name different than filenames

2016-03-25 Thread James Carter
Since the usual convention is for the module name to be same as the base filename of the module, provide a warning message if they are different. Also warn if the output filename is different than the module name. Signed-off-by: James Carter <jwca...@tycho.nsa.gov> --- checkpolicy/checkmo

[PATCH 1/3] libsepol: Add function to check if module name matches filename

2016-03-25 Thread James Carter
The function sepol_module_check_name_matches_filename() compares the module name with a filename (after stripping off path and file extension) and returns 0 if they match. The function sepol_module_get_name() returns the name of the module. Signed-off-by: James Carter <jwca...@tycho.nsa.

[PATCH 2/3] policycoreutils/hll/pp: Warn if module name different from filenames

2016-03-25 Thread James Carter
filename. When converting a policy package to CIL warn if the module name is different from the pp filename or the CIL filename. Signed-off-by: James Carter <jwca...@tycho.nsa.gov> --- policycoreutils/hll/pp/pp.c | 29 + 1 file changed, 25 insertions(+), 4 del

Re: [PATCH 3/3] checkpolicy: Warn if module name different than filenames

2016-03-25 Thread James Carter
On 03/25/2016 02:48 PM, Stephen Smalley wrote: On 03/25/2016 02:04 PM, James Carter wrote: Since the usual convention is for the module name to be same as the base filename of the module, provide a warning message if they are different. Also warn if the output filename is different than

Re: [PATCH 3/6] libsepol/cil: Add cil_tree_log() and supporting functions

2016-04-20 Thread James Carter
On 04/20/2016 10:47 AM, Steve Lawrence wrote: On 04/19/2016 10:26 AM, James Carter wrote: Provide more detailed log messages containing all relevant CIL and high-level language source file information through cil_tree_log(). cil_tree_log() uses two new functions: cil_tree_get_next_path

Re: [PATCH] libsepol: Only apply bounds checking to source types in rules

2016-04-29 Thread James Carter
On 04/29/2016 04:06 PM, Stephen Smalley wrote: On 04/29/2016 03:53 PM, James Carter wrote: The current bounds checking of both source and target types requires allowing any domain that has access to the child domain to also have the same permissions to the parent, which is undesirable. Drop

Re: [PATCH] libsepol/cil: Do not add an attribute as a type in the attr_type_map

2016-04-29 Thread James Carter
On 04/29/2016 02:26 PM, Stephen Smalley wrote: On 04/29/2016 01:47 PM, James Carter wrote: The attribute to type map is used to get all of the types that are asociated with an attribute. To make neverallow and bounds checking easier it was convienent to map a type to itself. However, CIL

[PATCH] libsepol: Change logic of bounds checking

2016-05-03 Thread James Carter
A:unix_stream_socket ; to also be allowed in policy. Signed-off-by: James Carter <jwca...@tycho.nsa.gov> --- libsepol/src/hierarchy.c | 17 + 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/libsepol/src/hierarchy.c b/libsepol/src/hierarchy.c index b24b39e..778541a

[PATCH] libsepol: Change which attributes CIL keeps in the binary policy

2016-05-06 Thread James Carter
Signed-off-by: James Carter <jwca...@tycho.nsa.gov> --- libsepol/cil/src/cil_post.c | 27 +++ libsepol/src/module_to_cil.c | 8 +--- 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/libsepol/cil/src/cil_post.c b/libsepol/cil/src/cil_post.c index a694b33

Re: [PATCH] libsepol: Change which attributes CIL keeps in the binary policy

2016-05-06 Thread James Carter
On 05/06/2016 03:39 PM, Roberts, William C wrote: -Original Message- From: Selinux [mailto:selinux-boun...@tycho.nsa.gov] On Behalf Of Roberts, William C Sent: Friday, May 6, 2016 12:25 PM To: William Roberts <bill.c.robe...@gmail.com>; James Carter <jwca...@tycho.nsa.gov>

Re: [PATCH] libsepol: Change which attributes CIL keeps in the binary policy

2016-05-06 Thread James Carter
On 05/06/2016 04:06 PM, Roberts, William C wrote: -Original Message- From: James Carter [mailto:jwca...@tycho.nsa.gov] Sent: Friday, May 6, 2016 12:47 PM To: Roberts, William C <william.c.robe...@intel.com>; William Roberts <bill.c.robe...@gmail.com> Cc: selinux@tycho.nsa

Re: [PATCH 0/6 v2] libsepol/cil: Add high-level language line marking support

2016-05-05 Thread James Carter
On 05/05/2016 12:15 PM, Steve Lawrence wrote: On 05/04/2016 04:41 PM, James Carter wrote: This patch set adds support for tracking original file and line numbers for better error reporting when a high-level language is translated into CIL. It then uses that support to provide better error

[PATCH 2/6 v2] libsepol/cil: Store CIL filename in parse tree and AST

2016-05-04 Thread James Carter
Use some of the functionality recently added to support high-level language line marking to track the CIL filename. The goal is to eventually remove the path field from the tree node struct and offset the addtion of the hll_line field. Signed-off-by: James Carter <jwca...@tycho.nsa.

[PATCH 4/6 v2] libsepol/cil: Replace cil_log() calls with cil_tree_log()

2016-05-04 Thread James Carter
Replace all calls to cil_log() that print path information with a call to cil_tree_log() which will also print information about any high-level sources. Signed-off-by: James Carter <jwca...@tycho.nsa.gov> --- libsepol/cil/src/cil.c | 3 +- libsepol/cil/src/cil_binary.c

[PATCH 0/6 v2] libsepol/cil: Add high-level language line marking support

2016-05-04 Thread James Carter
ng the AST from the associated macro or block. James Carter (6): libsepol/cil: Add high-level language line marking support libsepol/cil: Store CIL filename in parse tree and AST libsepol/cil: Add cil_tree_log() and supporting functions libsepol/cil: Replace cil_log() calls with ci

[PATCH 3/6 v2] libsepol/cil: Add cil_tree_log() and supporting functions

2016-05-04 Thread James Carter
11 of foo.hll) (from line 2 of bar.hll) Signed-off-by: James Carter <jwca...@tycho.nsa.gov> --- libsepol/cil/src/cil_tree.c | 86 + libsepol/cil/src/cil_tree.h | 4 +++ 2 files changed, 90 insertions(+) diff --git a/libsepol/cil/src/cil_tr

[PATCH 4/6] libsepol/cil: Replace cil_log() calls with cil_tree_log()

2016-04-19 Thread James Carter
Replace all calls to cil_log() that print path information with a call to cil_tree_log() which will also print information about any high-level sources. Signed-off-by: James Carter <jwca...@tycho.nsa.gov> --- libsepol/cil/src/cil.c | 3 +- libsepol/cil/src/cil_binary.c

[PATCH 6/6] libsepol: When generating CIL use HLL line mark for neverallows

2016-04-19 Thread James Carter
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 <jwca...@tycho.nsa.gov> --- libsepol/src/module_to_cil.c | 8 1 file changed, 8 insertions(+) diff --git a/libsepol/src/module_to_c

[PATCH 3/6] libsepol/cil: Add cil_tree_log() and supporting functions

2016-04-19 Thread James Carter
11 of foo.hll) (from line 2 of bar.hll) Signed-off-by: James Carter <jwca...@tycho.nsa.gov> --- libsepol/cil/src/cil_tree.c | 76 + libsepol/cil/src/cil_tree.h | 4 +++ 2 files changed, 80 insertions(+) diff --git a/libsepol/cil/src/cil_tr

[PATCH 5/6] libsepol/cil: Remove path field from cil_tree_node struct

2016-04-19 Thread James Carter
Remove path field from cil_tree_node struct and all references to it in CIL. This will reduce memory usage by 5%. Signed-off-by: James Carter <jwca...@tycho.nsa.gov> --- libsepol/cil/src/cil_binary.c| 14 +- libsepol/cil/src/cil_build_ast.c | 2 -- libsepol/c

[PATCH 2/6] libsepol/cil: Store CIL filename in parse tree and AST

2016-04-19 Thread James Carter
Use some of the functionality recently added to support high-level language line marking to track the CIL filename. The goal is to eventually remove the path field from the tree node struct and offset the addtion of the hll_line field. Signed-off-by: James Carter <jwca...@tycho.nsa.

[PATCH 1/3] libsepol/cil: Fixed bug in cil_type_match_any()

2016-04-13 Thread James Carter
of providing a quick match anytime the attributes are the same. Signed-off-by: James Carter <jwca...@tycho.nsa.gov> --- libsepol/cil/src/cil_find.c | 6 +- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libsepol/cil/src/cil_find.c b/libsepol/cil/src/cil_find.c index 7

[PATCH 2/3] libsepol/cil: Improve type bounds check reporting

2016-04-13 Thread James Carter
that if a match is not found (there should always be a match) a seg fault will not occur. To reduce the amount of error reporting, only print a trace of a matching rule if it is different from the previous one. Signed-off-by: James Carter <jwca...@tycho.nsa.gov> --- libsepol/cil/src/cil_binary.

[PATCH 3/3] libsepol/cil: Cleanup neverallow checking and fail if bounds checking fails

2016-04-13 Thread James Carter
For both neverallow and bounds checking keep neverallow and bounds failures separate from program faults. Have secilc exit with an error (and fail to build a binary policy) when bounds checks fail. Signed-off-by: James Carter <jwca...@tycho.nsa.gov> --- libsepol/cil/src/cil_binary.

Re: [PATCH 0/3] libsepol/cil: Fixes to neverallow and bounds checking

2016-04-18 Thread James Carter
On 04/13/2016 03:19 PM, James Carter wrote: Dan Walsh found a bug that resulted in a seg fault while working on docker policy. Steve Smalley was able to reproduce and find out where it was occuring in secilc. This patch set fixes that bug and makes other improvements in the bounds

[PATCH 0/3] libsepol/cil: Fixes to neverallow and bounds checking

2016-04-13 Thread James Carter
Dan Walsh found a bug that resulted in a seg fault while working on docker policy. Steve Smalley was able to reproduce and find out where it was occuring in secilc. This patch set fixes that bug and makes other improvements in the bounds and neverallow checking. James Carter (3): libsepol

[PATCH] libsepol/cil: Warn instead of fail if permission is not resolve

2016-07-28 Thread James Carter
not been installed. Signed-off-by: James Carter <jwca...@tycho.nsa.gov> --- libsepol/cil/src/cil_resolve_ast.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libsepol/cil/src/cil_resolve_ast.c b/libsepol/cil/src/cil_resolve_ast.c index 70e4462..8348d57

Re: [PATCH] semanage: swap tcp and udp protocol numbers

2016-08-10 Thread James Carter
p": 6, + "udp": 17, "ipv4": 4, "ipv6": 41} -- James Carter <jwca...@tycho.nsa.gov> National Security Agency ___ Selinux mailing list Selinux@t

Re: [PATCH] libsepol: Add missing return to sepol_node_query()

2016-07-12 Thread James Carter
e) < 0) goto err; + return STATUS_SUCCESS; } } break; -- James Carter <jwca...@tycho.nsa.gov> National

Re: Python3 support in policycoreutils

2016-08-08 Thread James Carter
. ___ Selinux mailing list Selinux@tycho.nsa.gov To unsubscribe, send email to selinux-le...@tycho.nsa.gov. To get help, send an email containing "help" to selinux-requ...@tycho.nsa.gov. -- James Carter <jwca...@tycho.nsa.gov> N

Re: [PATCH] semanage: add auditing of changes in records

2016-08-09 Thread James Carter
t;Could not delete the file context %s") % target) semanage_fcontext_key_free(k) +self.mylog.log_change("resrc=fcontext op=delete %s ftype=%s" % (audit.audit_encode_nv_string("tglob", target, 0), ftype_to_audit[ftype_str])) + self.equiv = {} self.equal_ind = True self.commit() @@ -1972,6 +2042,9 @@ class fcontextRecords(semanageRecords): if target in self.equiv.keys(): self.equiv.pop(target) self.equal_ind = True + +self.mylog.log_change("resrc=fcontext op=delete-equal %s ftype=%s" % (audit.audit_encode_nv_string("tglob", target, 0), ftype_to_audit[ftype])) + return (rc, k) = semanage_fcontext_key_create(self.sh, target, file_types[ftype]) @@ -1996,6 +2069,8 @@ class fcontextRecords(semanageRecords): semanage_fcontext_key_free(k) +self.mylog.log_change("resrc=fcontext op=delete %s ftype=%s" % (audit.audit_encode_nv_string("tglob", target, 0), ftype_to_audit[ftype])) + def delete(self, target, ftype): self.begin() self.__delete(target, ftype) -- James Carter <jwca...@tycho.nsa.gov> National Security Agency ___ Selinux mailing list Selinux@tycho.nsa.gov To unsubscribe, send email to selinux-le...@tycho.nsa.gov. To get help, send an email containing "help" to selinux-requ...@tycho.nsa.gov.

Re: [PATCH] policycoreutils: Don't use subprocess.getstatusoutput() in Python 2 code

2016-08-09 Thread James Carter
e(newcat, objects, login_ind): for f in objects: cmd = "%s %s" % (cmd, f) -rc = subprocess.getstatusoutput(cmd) +rc = getstatusoutput(cmd) if rc[0] != 0: print(rc[1]) errors += 1 -- James Carter <jwca...@tycho.nsa.gov> National Security Agency

Re: [PATCH] libsepol: fix invalid read when policy file is corrupt

2016-08-09 Thread James Carter
val_to_struct[i]->flavor == TYPE_ATTRIB) { if (ebitmap_union -- James Carter <jwca...@tycho.nsa.gov> National Security Agency ___ Selinux mailing list Selinux@tycho.n

Re: [PATCH] policycoreutils: 'fixfiles check' should not change anything

2016-08-09 Thread James Carter
PREFCTEMPFILE} fi } @@ -222,7 +223,7 @@ if [ ! -z "$PREFC" ]; then exit $? fi if [ ! -z "$BOOTTIME" ]; then -newer $BOOTTIME +newer $BOOTTIME $* exit $? fi [ -x /usr/sbin/genhomedircon ] && /usr/sbin/genhomedircon -- James Carter &l

Re: [PATCH] libsepol: fix memory leak in expand.c

2016-08-09 Thread James Carter
___ Selinux mailing list Selinux@tycho.nsa.gov To unsubscribe, send email to selinux-le...@tycho.nsa.gov. To get help, send an email containing "help" to selinux-requ...@tycho.nsa.gov. -- James Carter <jwca...@tycho.nsa.gov> National

Re: [PATCH] genhomedircon: add support for %group syntax

2016-08-15 Thread James Carter
*errors = STATUS_ERR; - break; - } } cleanup: - free(rbuf); if (*errors) { for (; head; pop_user_entry()) { /* the pop function takes care of all the cleanup _

Re: Fix AFL Found Bugs in libsepol v4

2016-08-17 Thread James Carter
] libsepol: fix unitialized jmp and invalid dereference [PATCH v4 7/7] libsepol: fix overflow and 0 length allocations Applied all patches. Thanks, Jim -- James Carter <jwca...@tycho.nsa.gov> National Security Agency ___ Selinux mailing list Selin

Re: [PATCH 0/5] checkpolicy: Cleanup declare and require functions

2017-02-03 Thread James Carter
On 01/31/2017 02:41 PM, James Carter wrote: Cleanup declare and require functions in module_compiler.c to improve maintainability and clarity. Functionality is not changed. James Carter (5): checkpolicy: Create common function for type declares and requires checkpolicy: Create common

[PATCH 3/5] checkpolicy: Create common function for user declares and requires

2017-01-31 Thread James Carter
Move common code out of declare_user() and require_user() into the new function create_user(). Signed-off-by: James Carter <jwca...@tycho.nsa.gov> --- checkpolicy/module_compiler.c | 224 +- 1 file changed, 114 insertions(+), 110 deletions(-) diff

[PATCH 4/5] checkpolicy: Cleanup error messages

2017-01-31 Thread James Carter
Add the new function print_error_msg() to print an error message based on the local error number and symbol_type. Remove the duplicate switch statements used throughout module_complier.c to display error messages. Signed-off-by: James Carter <jwca...@tycho.nsa.gov> --- check

[PATCH] checkpolicy: Improve check for identifier flavor mismatch

2017-01-31 Thread James Carter
type in the same scope. There are no checks if the require comes first and there are no checks for roles. Check for an identifier flavor mismatch for both roles and types whenever a declaration or requirement tries to add an identifier that is already in the symtab. Signed-off-by: James Carter

[PATCH 2/5] checkpolicy: Create common function for role declares and requires

2017-01-31 Thread James Carter
Move common code out of declare_role() and require_role_or_attribute() into the new function create_role(). Signed-off-by: James Carter <jwca...@tycho.nsa.gov> --- checkpolicy/module_compiler.c | 252 ++ 1 file changed, 130 insertions(+), 122 del

[PATCH 0/5] checkpolicy: Cleanup declare and require functions

2017-01-31 Thread James Carter
Cleanup declare and require functions in module_compiler.c to improve maintainability and clarity. Functionality is not changed. James Carter (5): checkpolicy: Create common function for type declares and requires checkpolicy: Create common function for role declares and requires

[PATCH 2/2] checkpolicy: Remove uneeded return check in require_symbol()

2017-01-31 Thread James Carter
Since symtab_insert() no longer returns -2 in the case of a declaration of an identifier followed by a require of the same symbol, remove the uneeded check. Signed-off-by: James Carter <jwca...@tycho.nsa.gov> --- checkpolicy/module_compiler.c | 20 ++-- 1 file chan

[PATCH 1/2] libsepol: Return +1 when declaration is followed by a require

2017-01-31 Thread James Carter
means returning +1). Signed-off-by: James Carter <jwca...@tycho.nsa.gov> --- libsepol/src/policydb.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/libsepol/src/policydb.c b/libsepol/src/policydb.c index 5b9b9f0..3cff6d2 100644 --- a/libsepol/src/policydb.c +++ b/libsepol/src/poli

Re: [PATCH 1/1] Introduce Travis-CI tests

2017-02-08 Thread James Carter
ror: missing .gitignore entry for/p' | (! grep '^') + + # Clean up everything and show which file would be added to "make clean" + - make clean distclean + - |- +git ls-files --ignored --others --exclude-standard | sed 's/^/error: "make clean distclean" did not remove /' | (

[PATCH] libsepol/cil: Destroy cil_tree_node stacks when finished resolving AST

2017-02-08 Thread James Carter
the stacks will be empty, but this is not the case when exiting with an error. Destroy both tree node stacks when exiting to ensure that they are empty. Signed-off-by: James Carter <jwca...@tycho.nsa.gov> --- libsepol/cil/src/cil_resolve_ast.c | 24 1 file changed, 16 inse

Re: [PATCH 1/1] libsepol/cil: fix type confusion in cil_copy_ast

2017-02-08 Thread James Carter
cil_tree_log(NODE(data), CIL_ERR, "Note: conflicting declaration"); + rc = SEPOL_ERR; + goto exit; + } rc = cil_symtab_insert(symtab, ((struct cil_symtab_datum*)orig->data)->name,

Re: [PATCH 3/8] policycoreutils/semodule: hide -Wwrite-strings warnings

2017-02-06 Thread James Carter
n" }; + const char *genhomedirconargv[] = { "genhomedircon", "-B", "-n" }; create_signal_handlers(); if (strcmp(basename(argv[0]), "genhomedircon") == 0) { argc = 3; - argv=genhomedirconargv; +

Re: [PATCH 1/8] libsepol: fix -Wwrite-strings warnings

2017-02-06 Thread James Carter
os && (ebitmap_cardinality(pos) > 0); int has_negative = neg && (ebitmap_cardinality(neg) > 0); char **val_to_name; -- James Carter <jwca...@tycho.nsa.gov> National Security Agency ___ Selinux mailing list Selinux@tycho.nsa.gov To unsubscribe, send email to selinux-le...@tycho.nsa.gov. To get help, send an email containing "help" to selinux-requ...@tycho.nsa.gov.

Re: [PATCH 0/5] checkpolicy: Cleanup declare and require functions

2017-02-03 Thread James Carter
On 02/02/2017 06:19 PM, Nicolas Iooss wrote: On Tue, Jan 31, 2017 at 8:41 PM, James Carter <jwca...@tycho.nsa.gov <mailto:jwca...@tycho.nsa.gov>> wrote: Cleanup declare and require functions in module_compiler.c to improve maintainability and clarity. Functionality is

Re: [PATCH] checkpolicy: Fix bug in handling type declaration in optional block.

2017-01-23 Thread James Carter
On 01/21/2017 08:58 AM, Nicolas Iooss wrote: On Wed, Jan 18, 2017 at 9:53 PM, James Carter <jwca...@tycho.nsa.gov <mailto:jwca...@tycho.nsa.gov>> wrote: Nicolas Iooss discovered that requiring a type in an optional block after the type has already been declared in another op

Re: [PATCH 1/4] checkpolicy: always free id in define_type()

2017-01-23 Thread James Carter
(id); return -1; } if (attr->flavor != TYPE_ATTRIB) { yyerror2("%s is a type, not an attribute", id); + free(id); return -1; } -- James Car

Re: [PATCH] libsepol: fix pp module to cil nodecon statement

2017-01-25 Thread James Carter
goto exit; } - cil_printf("(nodecon %s %s ", addr, mask); + cil_printf("(nodecon (%s) (%s) ", addr, mask); context_to_cil(pdb, >context[0]); -- James Car

Re: [PATCH] libsepol/cil: Destroy cil_tree_node stacks when finished resolving AST

2017-02-17 Thread James Carter
On 02/08/2017 11:17 AM, James Carter wrote: CIL uses separate cil_tree_node stacks for optionals and blocks to check for statements not allowed in optionals or blocks and to know which optional to disable when necessary. But these stacks were not being destroyed when exiting cil_resolve_ast

Re: Support for multiple types in typeattribute

2017-02-24 Thread James Carter
ho.nsa.gov. ___ Selinux mailing list Selinux@tycho.nsa.gov To unsubscribe, send email to selinux-le...@tycho.nsa.gov. To get help, send an email containing "help" to selinux-requ...@tycho.nsa.gov. -- James Carter <jwca...@tycho.nsa.gov>

Re: [PATCH 2/5] libsepol/cil: destroy bitmap when __cil_permx_str_to_int() fails

2017-02-21 Thread James Carter
ebitmap_destroy(bitmap); goto exit; } return SEPOL_OK; exit: + ebitmap_destroy(bitmap); return rc; } -- James Carter <jwca...@tycho.nsa.gov> National Security Agency ___ Selinux mailing list Selinux@tycho.ns

Re: [PATCH] sepolgen: strip non-printable characters when parsing audit messages

2017-02-21 Thread James Carter
;\x1c\x1d\x1e\x85") for x in line.split()] for i in rec: found = False if i == "avc:" or i == "message=avc:" or i == "msg='avc:": -- James Carter <jwca...@tycho.nsa.gov> National Security Agency

Re: [PATCH 1/1] libselinux, libsemanage: make PYPREFIX computation more robust

2017-02-21 Thread James Carter
PYTHON ?= python -PYPREFIX ?= $(notdir $(PYTHON)) +PYPREFIX ?= $(shell $(PYTHON) -c 'import sys;print("python-%d.%d" % sys.version_info[:2])') RUBY ?= ruby RUBYPREFIX ?= $(notdir $(RUBY)) PKG_CONFIG ?= pkg-config -- James Carter <jwca...@tycho.nsa.gov> National Security Agency

Re: [PATCH 1/1] checkpolicy: do not leak memory when declaring a type which has been required

2017-01-23 Thread James Carter
tly older version of fedora policy to fail to build. I am looking at refactoring declare_type() and require_type() and will try to fix the memory leak and other issues at the same time. Jim + } } else { /* error occurred (can't have duplicate type declarations) */

Re: [PATCH 1/1] checkpolicy: do not leak memory when declaring a type which has been required

2017-01-18 Thread James Carter
ype_datum_destroy(typdatum); + free(typdatum); + return NULL; + } } else { /* error occurred (can't have duplicate type declarations) */ free(id); -- James Carter <jwca...@tycho.nsa.gov> National Security Agency

Re: [PATCH] checkpolicy: Fix bug in handling type declaration in optional block.

2017-01-18 Thread James Carter
On 01/18/2017 03:58 PM, Dominick Grift wrote: On 01/18/2017 09:53 PM, James Carter wrote: Nicolas Iooss discovered that requiring a type in an optional block after the type has already been declared in another optional block results in a duplicate declaration error. from what i have been

[PATCH] checkpolicy: Fix bug in handling type declaration in optional block.

2017-01-18 Thread James Carter
which is interpreted as a duplicate declaration error. The function should return 1 instead which means that they symbol was not added and needs to be freed later. Signed-off-by: James Carter <jwca...@tycho.nsa.gov> --- checkpolicy/module_compiler.c | 16 +++- 1 file chan

Re: [PATCH] checkpolicy: Fix bug in handling type declaration in optional block.

2017-01-20 Thread James Carter
On 01/19/2017 04:22 PM, Dominick Grift wrote: On 01/19/2017 06:21 PM, Stephen Smalley wrote: On Wed, 2017-01-18 at 21:58 +0100, Dominick Grift wrote: On 01/18/2017 09:53 PM, James Carter wrote: Nicolas Iooss discovered that requiring a type in an optional block after the type has already

Re: [PATCH v2 1/2] libsepol: calloc all the *_to_val_structs

2016-08-19 Thread James Carter
RS] = tmp_ptr; + policydb->p_user_val_to_name[policydb->p_users.nprim] = NULL; /* Need to copy the user name */ name = strdup(cname); -- James Carter <jwca...@tycho.nsa.gov> National Security Agency ___

Re: [PATCH v3 5/7] libsepol: fix overflow and 0 length allocations

2016-08-16 Thread James Carter
if (zero_or_saturated(len)) + goto bad; if ((p->version = malloc(len + 1)) == NULL) { goto bad; } diff --git a/libsepol/src/private.h b/libsepol/src/private.h index 9c700c9..0beb4d4 100644 --- a/libsepol/src

Re: [PATCH 1/6] semodule_package: do not leak memory when using -u or -s

2017-03-01 Thread James Carter
free(file_contexts); free(outfile); free(module); + free(seusers); + free(user_extra); exit(0); } -- James Carter <jwca...@tycho.nsa.gov> National Security Agency ___ Selinux mailing list Selinux@tycho.nsa.gov To

Re: [PATCH] libsepol: Produce more meaningful error messages for conflicting type rules

2016-09-06 Thread James Carter
ue, cil_rule, cond_node, cond_flavor); if (rc != SEPOL_OK) goto exit; } } ___ Selinux mailing list Selinux@tycho.nsa.gov To unsubscribe, send email to selinux-le...@tycho.nsa.gov. To get help, send an email containing "hel

Re: [PATCH 0/5] Fix some cil_gen_policy() bugs.

2016-09-09 Thread James Carter
On 09/09/2016 08:29 AM, James Carter wrote: On 09/08/2016 04:37 PM, Daniel Cashman wrote: On 09/08/2016 01:30 PM, Daniel Cashman wrote: From: dcashman <dcash...@android.com> cil_gen_policy() appears to exist to generate a policy.conf corresponding to the original SELinux HLL from a

Re: [PATCH 0/5] Fix some cil_gen_policy() bugs.

2016-09-09 Thread James Carter
becoming more invasive (similar to the 5th patch in this set) and less bug-fix-like. Thank You, Dan -- James Carter <jwca...@tycho.nsa.gov> National Security Agency ___ Selinux mailing list Selinux@tycho.nsa.gov To unsubscribe, send email to selinux

Re: [PATCH] policycoreutils: setfiles - Add option to stop setting the digest

2016-09-26 Thread James Carter
9,9 +417,9 @@ int main(int argc, char **argv) } else if (argc == 1) usage(argv[0]); - /* Set selabel_open options. Always request a digest. */ + /* Set selabel_open options. */ r_opts.selabel_opt_validate = (ctx_validate ? (char *)1 : NULL); - r_opts.selabel_o

Re: [PATCH 0/2] selinux: Add features to find security.restorecon_last entries

2016-09-26 Thread James Carter
-- James Carter <jwca...@tycho.nsa.gov> National Security Agency ___ Selinux mailing list Selinux@tycho.nsa.gov To unsubscribe, send email to selinux-le...@tycho.nsa.gov. To get help, send an email containing "help" to selinux-requ...@tycho.nsa.gov.

Re: [PATCH] libsemanage: use pp module headers as a source for a module name

2016-09-26 Thread James Carter
On 09/25/2016 05:41 PM, Petr Lautrbach wrote: On Fri, Sep 23, 2016 at 01:37:26PM -0400, James Carter wrote: On 09/23/2016 12:05 PM, Petr Lautrbach wrote: On 09/23/2016 05:31 PM, James Carter wrote: On 09/23/2016 05:23 AM, Petr Lautrbach wrote: When a user installs a module, the filename

Re: [PATCH v2] libsemanage: Use pp module name instead of filename

2016-09-26 Thread James Carter
arning: SELinux userspace will refer to the module from %s as %s rather than %s\n", ifile, cil_name, mod_name); + fprintf(stderr, "Warning: SELinux userspace will refer to the module from %s as %s rather than %s\n", ifile, mod_name, cil_name);

[PATCH] libsepol/cil: Check for too many permissions in classes and commons

2016-09-29 Thread James Carter
] /usr/bin/secilc[0x40273b] /usr/lib/libc.so.6(__libc_start_main+0xf1)[0x77657291] /usr/bin/secilc[0x402f7a] This bug has been found by fuzzing secilc with american fuzzy lop. Signed-off-by: James Carter <jwca...@tycho.nsa.gov> --- libsepol/cil/src/cil_build_ast.c | 9 + li

Re: [PATCH] libsepol/cil: Check for too many permissions in classes and commons

2016-09-29 Thread James Carter
On 09/29/2016 02:38 PM, Steve Lawrence wrote: On 09/29/2016 02:07 PM, James Carter wrote: Fixes bug found by Nicolas Iooss as described below in the way suggested by Steve Lawrence. Nicolass reported: When compiling a CIL policy with more than 32 items in a class (e.g. in (class capability

  1   2   3   >