1. 21 2月, 2014 1 次提交
  2. 07 1月, 2014 1 次提交
    • T
      SELinux: Fix memory leak upon loading policy · 8ed81460
      Tetsuo Handa 提交于
      Hello.
      
      I got below leak with linux-3.10.0-54.0.1.el7.x86_64 .
      
      [  681.903890] kmemleak: 5538 new suspected memory leaks (see /sys/kernel/debug/kmemleak)
      
      Below is a patch, but I don't know whether we need special handing for undoing
      ebitmap_set_bit() call.
      ----------
      >>From fe97527a90fe95e2239dfbaa7558f0ed559c0992 Mon Sep 17 00:00:00 2001
      From: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
      Date: Mon, 6 Jan 2014 16:30:21 +0900
      Subject: [PATCH] SELinux: Fix memory leak upon loading policy
      
      Commit 2463c26d "SELinux: put name based create rules in a hashtable" did not
      check return value from hashtab_insert() in filename_trans_read(). It leaks
      memory if hashtab_insert() returns error.
      
        unreferenced object 0xffff88005c9160d0 (size 8):
          comm "systemd", pid 1, jiffies 4294688674 (age 235.265s)
          hex dump (first 8 bytes):
            57 0b 00 00 6b 6b 6b a5                          W...kkk.
          backtrace:
            [<ffffffff816604ae>] kmemleak_alloc+0x4e/0xb0
            [<ffffffff811cba5e>] kmem_cache_alloc_trace+0x12e/0x360
            [<ffffffff812aec5d>] policydb_read+0xd1d/0xf70
            [<ffffffff812b345c>] security_load_policy+0x6c/0x500
            [<ffffffff812a623c>] sel_write_load+0xac/0x750
            [<ffffffff811eb680>] vfs_write+0xc0/0x1f0
            [<ffffffff811ec08c>] SyS_write+0x4c/0xa0
            [<ffffffff81690419>] system_call_fastpath+0x16/0x1b
            [<ffffffffffffffff>] 0xffffffffffffffff
      
      However, we should not return EEXIST error to the caller, or the systemd will
      show below message and the boot sequence freezes.
      
        systemd[1]: Failed to load SELinux policy. Freezing.
      Signed-off-by: NTetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
      Acked-by: NEric Paris <eparis@redhat.com>
      Cc: stable@vger.kernel.org
      Signed-off-by: NPaul Moore <pmoore@redhat.com>
      8ed81460
  3. 20 11月, 2013 1 次提交
  4. 26 7月, 2013 1 次提交
    • E
      SELinux: fix selinuxfs policy file on big endian systems · b138004e
      Eric Paris 提交于
      The /sys/fs/selinux/policy file is not valid on big endian systems like
      ppc64 or s390.  Let's see why:
      
      static int hashtab_cnt(void *key, void *data, void *ptr)
      {
      	int *cnt = ptr;
      	*cnt = *cnt + 1;
      
      	return 0;
      }
      
      static int range_write(struct policydb *p, void *fp)
      {
      	size_t nel;
      [...]
      	/* count the number of entries in the hashtab */
      	nel = 0;
      	rc = hashtab_map(p->range_tr, hashtab_cnt, &nel);
      	if (rc)
      		return rc;
      	buf[0] = cpu_to_le32(nel);
      	rc = put_entry(buf, sizeof(u32), 1, fp);
      
      So size_t is 64 bits.  But then we pass a pointer to it as we do to
      hashtab_cnt.  hashtab_cnt thinks it is a 32 bit int and only deals with
      the first 4 bytes.  On x86_64 which is little endian, those first 4
      bytes and the least significant, so this works out fine.  On ppc64/s390
      those first 4 bytes of memory are the high order bits.  So at the end of
      the call to hashtab_map nel has a HUGE number.  But the least
      significant 32 bits are all 0's.
      
      We then pass that 64 bit number to cpu_to_le32() which happily truncates
      it to a 32 bit number and does endian swapping.  But the low 32 bits are
      all 0's.  So no matter how many entries are in the hashtab, big endian
      systems always say there are 0 entries because I screwed up the
      counting.
      
      The fix is easy.  Use a 32 bit int, as the hashtab_cnt expects, for nel.
      Signed-off-by: NEric Paris <eparis@redhat.com>
      Signed-off-by: NPaul Moore <pmoore@redhat.com>
      b138004e
  5. 09 6月, 2013 1 次提交
  6. 10 4月, 2012 2 次提交
    • E
      SELinux: add default_type statements · eed7795d
      Eric Paris 提交于
      Because Fedora shipped userspace based on my development tree we now
      have policy version 27 in the wild defining only default user, role, and
      range.  Thus to add default_type we need a policy.28.
      Signed-off-by: NEric Paris <eparis@redhat.com>
      eed7795d
    • E
      SELinux: allow default source/target selectors for user/role/range · aa893269
      Eric Paris 提交于
      When new objects are created we have great and flexible rules to
      determine the type of the new object.  We aren't quite as flexible or
      mature when it comes to determining the user, role, and range.  This
      patch adds a new ability to specify the place a new objects user, role,
      and range should come from.  For users and roles it can come from either
      the source or the target of the operation.  aka for files the user can
      either come from the source (the running process and todays default) or
      it can come from the target (aka the parent directory of the new file)
      
      examples always are done with
      directory context: system_u:object_r:mnt_t:s0-s0:c0.c512
      process context: unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
      
      [no rule]
      	unconfined_u:object_r:mnt_t:s0   test_none
      [default user source]
      	unconfined_u:object_r:mnt_t:s0   test_user_source
      [default user target]
      	system_u:object_r:mnt_t:s0       test_user_target
      [default role source]
      	unconfined_u:unconfined_r:mnt_t:s0 test_role_source
      [default role target]
      	unconfined_u:object_r:mnt_t:s0   test_role_target
      [default range source low]
      	unconfined_u:object_r:mnt_t:s0 test_range_source_low
      [default range source high]
      	unconfined_u:object_r:mnt_t:s0:c0.c1023 test_range_source_high
      [default range source low-high]
      	unconfined_u:object_r:mnt_t:s0-s0:c0.c1023 test_range_source_low-high
      [default range target low]
      	unconfined_u:object_r:mnt_t:s0 test_range_target_low
      [default range target high]
      	unconfined_u:object_r:mnt_t:s0:c0.c512 test_range_target_high
      [default range target low-high]
      	unconfined_u:object_r:mnt_t:s0-s0:c0.c512 test_range_target_low-high
      Signed-off-by: NEric Paris <eparis@redhat.com>
      aa893269
  7. 06 1月, 2012 1 次提交
  8. 10 9月, 2011 1 次提交
  9. 02 8月, 2011 2 次提交
  10. 15 6月, 2011 1 次提交
  11. 13 5月, 2011 1 次提交
  12. 29 4月, 2011 6 次提交
  13. 20 4月, 2011 1 次提交
  14. 08 4月, 2011 1 次提交
  15. 29 3月, 2011 2 次提交
  16. 02 2月, 2011 1 次提交
    • E
      SELinux: Use dentry name in new object labeling · 652bb9b0
      Eric Paris 提交于
      Currently SELinux has rules which label new objects according to 3 criteria.
      The label of the process creating the object, the label of the parent
      directory, and the type of object (reg, dir, char, block, etc.)  This patch
      adds a 4th criteria, the dentry name, thus we can distinguish between
      creating a file in an etc_t directory called shadow and one called motd.
      
      There is no file globbing, regex parsing, or anything mystical.  Either the
      policy exactly (strcmp) matches the dentry name of the object or it doesn't.
      This patch has no changes from today if policy does not implement the new
      rules.
      Signed-off-by: NEric Paris <eparis@redhat.com>
      652bb9b0
  17. 24 1月, 2011 1 次提交
  18. 01 12月, 2010 4 次提交
  19. 21 10月, 2010 3 次提交
  20. 02 8月, 2010 4 次提交
  21. 17 5月, 2010 1 次提交
  22. 09 4月, 2010 1 次提交
  23. 08 3月, 2010 1 次提交
  24. 04 2月, 2010 1 次提交