selinux/checkpolicy
Nick Kralevich 908898846a policy_define.c: don't free memory returned from queue_head()
Unlike queue_remove(), queue_head() does not modify the queue, but
rather, returns a pointer to an element within the queue. Freeing the
memory associated with a value returned from that function corrupts
subsequent users of the queue, who may try to reference this
now-deallocated memory.

This causes the following policy generation errors on Android:

  FAILED:
  out/target/product/bullhead/obj/ETC/plat_sepolicy.cil_intermediates/plat_policy_nvr.cil
  /bin/bash -c "out/host/linux-x86/bin/checkpolicy -M -C -c 30 -o
  out/target/product/bullhead/obj/ETC/plat_sepolicy.cil_intermediates/plat_policy_nvr.cil
  out/target/product/bullhead/obj/ETC/plat_sepolicy.cil_intermediates/plat_policy.conf"
  system/sepolicy/public/app.te:241:ERROR 'only ioctl extended permissions
  are supported' at token ';' on line 6784:
  #line 241
  } };
  checkpolicy:  error(s) encountered while parsing configuration

because the value of "id" in:

  id = queue_remove(id_queue);
  if (strcmp(id,"ioctl") == 0) {
    ...
  } else {
    yyerror("only ioctl extended permissions are supported");
    ...
  }

is now garbage.

This is a partial revert of the following commit:

  c1ba8311 checkpolicy: free id where it was leaked

Signed-off-by: Nick Kralevich <nnk@google.com>
2017-01-13 14:43:38 -05:00
..
test checkpolicy: remove -lfl from LDLIBS 2016-11-29 08:46:43 -05:00
.gitignore Repo: update .gitignore 2011-08-02 13:31:51 -04:00
checkmodule.8 checkpolicy: Add support for generating CIL 2015-04-01 13:09:26 -04:00
checkmodule.c checkpolicy: Fix checkmodule output message 2016-05-16 16:33:29 -04:00
checkpolicy.8 checkpolicy: Add support for generating CIL 2015-04-01 13:09:26 -04:00
checkpolicy.c checkpolicy: always include ctypes.h 2017-01-09 16:00:25 -05:00
checkpolicy.h initial import from svn trunk revision 2950 2008-08-19 15:30:36 -04:00
COPYING initial import from svn trunk revision 2950 2008-08-19 15:30:36 -04:00
Makefile checkpolicy: remove -lfl from LDLIBS 2016-11-29 08:46:43 -05:00
module_compiler.c Fix -Wreturn-type issues. 2015-06-12 08:35:22 -04:00
module_compiler.h checkpolicy: Separate tunable from boolean during compile. 2011-09-16 11:54:01 -04:00
parse_util.c initial import from svn trunk revision 2950 2008-08-19 15:30:36 -04:00
parse_util.h initial import from svn trunk revision 2950 2008-08-19 15:30:36 -04:00
policy_define.c policy_define.c: don't free memory returned from queue_head() 2017-01-13 14:43:38 -05:00
policy_define.h checkpolicy: switch operations to extended perms 2015-06-15 09:21:20 -04:00
policy_parse.y Add neverallow support for ioctl extended permissions 2015-09-22 10:52:47 -04:00
policy_scan.l Extend checkpolicy pathname matching. 2016-07-14 11:41:28 -04:00
queue.c checkpolicy: do not leak queue elements in queue_destroy() 2017-01-06 13:33:15 -05:00
queue.h initial import from svn trunk revision 2950 2008-08-19 15:30:36 -04:00
VERSION Update VERSION and ChangeLog files for 2.6 final release. 2016-10-14 11:31:26 -04:00