<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux/security, branch v3.4.80</title>
<subtitle>Linux kernel source tree</subtitle>
<id>https://git.amat.us/linux/atom/security?h=v3.4.80</id>
<link rel='self' href='https://git.amat.us/linux/atom/security?h=v3.4.80'/>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/'/>
<updated>2014-02-13T19:51:07Z</updated>
<entry>
<title>SELinux: Fix memory leak upon loading policy</title>
<updated>2014-02-13T19:51:07Z</updated>
<author>
<name>Tetsuo Handa</name>
<email>penguin-kernel@I-love.SAKURA.ne.jp</email>
</author>
<published>2014-01-06T12:28:15Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=ef609edc523e00e7b8cf6be348f52f6d6577d63e'/>
<id>urn:sha1:ef609edc523e00e7b8cf6be348f52f6d6577d63e</id>
<content type='text'>
commit 8ed814602876bec9bad2649ca17f34b499357a1c upstream.

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.
----------
&gt;&gt;From fe97527a90fe95e2239dfbaa7558f0ed559c0992 Mon Sep 17 00:00:00 2001
From: Tetsuo Handa &lt;penguin-kernel@I-love.SAKURA.ne.jp&gt;
Date: Mon, 6 Jan 2014 16:30:21 +0900
Subject: 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:
      [&lt;ffffffff816604ae&gt;] kmemleak_alloc+0x4e/0xb0
      [&lt;ffffffff811cba5e&gt;] kmem_cache_alloc_trace+0x12e/0x360
      [&lt;ffffffff812aec5d&gt;] policydb_read+0xd1d/0xf70
      [&lt;ffffffff812b345c&gt;] security_load_policy+0x6c/0x500
      [&lt;ffffffff812a623c&gt;] sel_write_load+0xac/0x750
      [&lt;ffffffff811eb680&gt;] vfs_write+0xc0/0x1f0
      [&lt;ffffffff811ec08c&gt;] SyS_write+0x4c/0xa0
      [&lt;ffffffff81690419&gt;] system_call_fastpath+0x16/0x1b
      [&lt;ffffffffffffffff&gt;] 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: Tetsuo Handa &lt;penguin-kernel@I-love.SAKURA.ne.jp&gt;
Acked-by: Eric Paris &lt;eparis@redhat.com&gt;
Signed-off-by: Paul Moore &lt;pmoore@redhat.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>SELinux: Fix possible NULL pointer dereference in selinux_inode_permission()</title>
<updated>2014-01-29T13:10:42Z</updated>
<author>
<name>Steven Rostedt</name>
<email>rostedt@goodmis.org</email>
</author>
<published>2014-01-10T02:46:34Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=9e74d93d657ae6662cfd5e3e9ca67d05cfffbd9a'/>
<id>urn:sha1:9e74d93d657ae6662cfd5e3e9ca67d05cfffbd9a</id>
<content type='text'>
commit 3dc91d4338d698ce77832985f9cb183d8eeaf6be upstream.

While running stress tests on adding and deleting ftrace instances I hit
this bug:

  BUG: unable to handle kernel NULL pointer dereference at 0000000000000020
  IP: selinux_inode_permission+0x85/0x160
  PGD 63681067 PUD 7ddbe067 PMD 0
  Oops: 0000 [#1] PREEMPT
  CPU: 0 PID: 5634 Comm: ftrace-test-mki Not tainted 3.13.0-rc4-test-00033-gd2a6dde-dirty #20
  Hardware name:                  /DG965MQ, BIOS MQ96510J.86A.0372.2006.0605.1717 06/05/2006
  task: ffff880078375800 ti: ffff88007ddb0000 task.ti: ffff88007ddb0000
  RIP: 0010:[&lt;ffffffff812d8bc5&gt;]  [&lt;ffffffff812d8bc5&gt;] selinux_inode_permission+0x85/0x160
  RSP: 0018:ffff88007ddb1c48  EFLAGS: 00010246
  RAX: 0000000000000000 RBX: 0000000000800000 RCX: ffff88006dd43840
  RDX: 0000000000000001 RSI: 0000000000000081 RDI: ffff88006ee46000
  RBP: ffff88007ddb1c88 R08: 0000000000000000 R09: ffff88007ddb1c54
  R10: 6e6576652f6f6f66 R11: 0000000000000003 R12: 0000000000000000
  R13: 0000000000000081 R14: ffff88006ee46000 R15: 0000000000000000
  FS:  00007f217b5b6700(0000) GS:ffffffff81e21000(0000) knlGS:0000000000000000
  CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033^M
  CR2: 0000000000000020 CR3: 000000006a0fe000 CR4: 00000000000007f0
  Call Trace:
    security_inode_permission+0x1c/0x30
    __inode_permission+0x41/0xa0
    inode_permission+0x18/0x50
    link_path_walk+0x66/0x920
    path_openat+0xa6/0x6c0
    do_filp_open+0x43/0xa0
    do_sys_open+0x146/0x240
    SyS_open+0x1e/0x20
    system_call_fastpath+0x16/0x1b
  Code: 84 a1 00 00 00 81 e3 00 20 00 00 89 d8 83 c8 02 40 f6 c6 04 0f 45 d8 40 f6 c6 08 74 71 80 cf 02 49 8b 46 38 4c 8d 4d cc 45 31 c0 &lt;0f&gt; b7 50 20 8b 70 1c 48 8b 41 70 89 d9 8b 78 04 e8 36 cf ff ff
  RIP  selinux_inode_permission+0x85/0x160
  CR2: 0000000000000020

Investigating, I found that the inode-&gt;i_security was NULL, and the
dereference of it caused the oops.

in selinux_inode_permission():

	isec = inode-&gt;i_security;

	rc = avc_has_perm_noaudit(sid, isec-&gt;sid, isec-&gt;sclass, perms, 0, &amp;avd);

Note, the crash came from stressing the deletion and reading of debugfs
files.  I was not able to recreate this via normal files.  But I'm not
sure they are safe.  It may just be that the race window is much harder
to hit.

What seems to have happened (and what I have traced), is the file is
being opened at the same time the file or directory is being deleted.
As the dentry and inode locks are not held during the path walk, nor is
the inodes ref counts being incremented, there is nothing saving these
structures from being discarded except for an rcu_read_lock().

The rcu_read_lock() protects against freeing of the inode, but it does
not protect freeing of the inode_security_struct.  Now if the freeing of
the i_security happens with a call_rcu(), and the i_security field of
the inode is not changed (it gets freed as the inode gets freed) then
there will be no issue here.  (Linus Torvalds suggested not setting the
field to NULL such that we do not need to check if it is NULL in the
permission check).

Note, this is a hack, but it fixes the problem at hand.  A real fix is
to restructure the destroy_inode() to call all the destructor handlers
from the RCU callback.  But that is a major job to do, and requires a
lot of work.  For now, we just band-aid this bug with this fix (it
works), and work on a more maintainable solution in the future.

Link: http://lkml.kernel.org/r/20140109101932.0508dec7@gandalf.local.home
Link: http://lkml.kernel.org/r/20140109182756.17abaaa8@gandalf.local.home

Signed-off-by: Steven Rostedt &lt;rostedt@goodmis.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>selinux: process labeled IPsec TCP SYN-ACK packets properly in selinux_ip_postroute()</title>
<updated>2014-01-08T17:42:12Z</updated>
<author>
<name>Paul Moore</name>
<email>pmoore@redhat.com</email>
</author>
<published>2013-12-10T19:58:01Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=420cc6d77fd83ab28ebed7ab1dc9018ab351ec12'/>
<id>urn:sha1:420cc6d77fd83ab28ebed7ab1dc9018ab351ec12</id>
<content type='text'>
commit c0828e50485932b7e019df377a6b0a8d1ebd3080 upstream.

Due to difficulty in arriving at the proper security label for
TCP SYN-ACK packets in selinux_ip_postroute(), we need to check packets
while/before they are undergoing XFRM transforms instead of waiting
until afterwards so that we can determine the correct security label.

Reported-by: Janak Desai &lt;Janak.Desai@gtri.gatech.edu&gt;
Signed-off-by: Paul Moore &lt;pmoore@redhat.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>selinux: look for IPsec labels on both inbound and outbound packets</title>
<updated>2014-01-08T17:42:12Z</updated>
<author>
<name>Paul Moore</name>
<email>pmoore@redhat.com</email>
</author>
<published>2013-12-10T19:57:54Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=73ec955cd6954d69540c7a761182ee84d2bad189'/>
<id>urn:sha1:73ec955cd6954d69540c7a761182ee84d2bad189</id>
<content type='text'>
commit 817eff718dca4e54d5721211ddde0914428fbb7c upstream.

Previously selinux_skb_peerlbl_sid() would only check for labeled
IPsec security labels on inbound packets, this patch enables it to
check both inbound and outbound traffic for labeled IPsec security
labels.

Reported-by: Janak Desai &lt;Janak.Desai@gtri.gatech.edu&gt;
Signed-off-by: Paul Moore &lt;pmoore@redhat.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>selinux: selinux_setprocattr()-&gt;ptrace_parent() needs rcu_read_lock()</title>
<updated>2014-01-08T17:42:10Z</updated>
<author>
<name>Oleg Nesterov</name>
<email>oleg@redhat.com</email>
</author>
<published>2013-12-23T22:45:01Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=58c2314ac41e8f24a2a594bd866915e38de9648e'/>
<id>urn:sha1:58c2314ac41e8f24a2a594bd866915e38de9648e</id>
<content type='text'>
commit c0c1439541f5305b57a83d599af32b74182933fe upstream.

selinux_setprocattr() does ptrace_parent(p) under task_lock(p),
but task_struct-&gt;alloc_lock doesn't pin -&gt;parent or -&gt;ptrace,
this looks confusing and triggers the "suspicious RCU usage"
warning because ptrace_parent() does rcu_dereference_check().

And in theory this is wrong, spin_lock()-&gt;preempt_disable()
doesn't necessarily imply rcu_read_lock() we need to access
the -&gt;parent.

Reported-by: Evan McNabb &lt;emcnabb@redhat.com&gt;
Signed-off-by: Oleg Nesterov &lt;oleg@redhat.com&gt;
Signed-off-by: Paul Moore &lt;pmoore@redhat.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>selinux: fix broken peer recv check</title>
<updated>2014-01-08T17:42:10Z</updated>
<author>
<name>Chad Hanson</name>
<email>chanson@trustedcs.com</email>
</author>
<published>2013-12-23T22:45:01Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=351381d8cea3036cfe021eb29994584d0e5c0e73'/>
<id>urn:sha1:351381d8cea3036cfe021eb29994584d0e5c0e73</id>
<content type='text'>
commit 46d01d63221c3508421dd72ff9c879f61053cffc upstream.

Fix a broken networking check. Return an error if peer recv fails.  If
secmark is active and the packet recv succeeds the peer recv error is
ignored.

Signed-off-by: Chad Hanson &lt;chanson@trustedcs.com&gt;
Signed-off-by: Paul Moore &lt;pmoore@redhat.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>selinux: handle TCP SYN-ACK packets correctly in selinux_ip_postroute()</title>
<updated>2013-12-20T15:34:20Z</updated>
<author>
<name>Paul Moore</name>
<email>pmoore@redhat.com</email>
</author>
<published>2013-12-04T21:10:51Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=2ea04e5a3d579032632c72584ea67b623321064c'/>
<id>urn:sha1:2ea04e5a3d579032632c72584ea67b623321064c</id>
<content type='text'>
commit 446b802437f285de68ffb8d6fac3c44c3cab5b04 upstream.

In selinux_ip_postroute() we perform access checks based on the
packet's security label.  For locally generated traffic we get the
packet's security label from the associated socket; this works in all
cases except for TCP SYN-ACK packets.  In the case of SYN-ACK packet's
the correct security label is stored in the connection's request_sock,
not the server's socket.  Unfortunately, at the point in time when
selinux_ip_postroute() is called we can't query the request_sock
directly, we need to recreate the label using the same logic that
originally labeled the associated request_sock.

See the inline comments for more explanation.

Reported-by: Janak Desai &lt;Janak.Desai@gtri.gatech.edu&gt;
Tested-by: Janak Desai &lt;Janak.Desai@gtri.gatech.edu&gt;
Signed-off-by: Paul Moore &lt;pmoore@redhat.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>selinux: handle TCP SYN-ACK packets correctly in selinux_ip_output()</title>
<updated>2013-12-20T15:34:20Z</updated>
<author>
<name>Paul Moore</name>
<email>pmoore@redhat.com</email>
</author>
<published>2013-12-04T21:10:45Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=1c5d9d1527ceb57e66001fba3d84c766d89baf2e'/>
<id>urn:sha1:1c5d9d1527ceb57e66001fba3d84c766d89baf2e</id>
<content type='text'>
commit 47180068276a04ed31d24fe04c673138208b07a9 upstream.

In selinux_ip_output() we always label packets based on the parent
socket.  While this approach works in almost all cases, it doesn't
work in the case of TCP SYN-ACK packets when the correct label is not
the label of the parent socket, but rather the label of the larval
socket represented by the request_sock struct.

Unfortunately, since the request_sock isn't queued on the parent
socket until *after* the SYN-ACK packet is sent, we can't lookup the
request_sock to determine the correct label for the packet; at this
point in time the best we can do is simply pass/NF_ACCEPT the packet.
It must be said that simply passing the packet without any explicit
labeling action, while far from ideal, is not terrible as the SYN-ACK
packet will inherit any IP option based labeling from the initial
connection request so the label *should* be correct and all our
access controls remain in place so we shouldn't have to worry about
information leaks.

Reported-by: Janak Desai &lt;Janak.Desai@gtri.gatech.edu&gt;
Tested-by: Janak Desai &lt;Janak.Desai@gtri.gatech.edu&gt;
Signed-off-by: Paul Moore &lt;pmoore@redhat.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>selinux: correct locking in selinux_netlbl_socket_connect)</title>
<updated>2013-12-04T18:50:32Z</updated>
<author>
<name>Paul Moore</name>
<email>pmoore@redhat.com</email>
</author>
<published>2013-09-26T21:00:46Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=17af9d91523a6e44a3721cea48cd3ade66a8b416'/>
<id>urn:sha1:17af9d91523a6e44a3721cea48cd3ade66a8b416</id>
<content type='text'>
commit 42d64e1add3a1ce8a787116036163b8724362145 upstream.

The SELinux/NetLabel glue code has a locking bug that affects systems
with NetLabel enabled, see the kernel error message below.  This patch
corrects this problem by converting the bottom half socket lock to a
more conventional, and correct for this call-path, lock_sock() call.

 ===============================
 [ INFO: suspicious RCU usage. ]
 3.11.0-rc3+ #19 Not tainted
 -------------------------------
 net/ipv4/cipso_ipv4.c:1928 suspicious rcu_dereference_protected() usage!

 other info that might help us debug this:

 rcu_scheduler_active = 1, debug_locks = 0
 2 locks held by ping/731:
  #0:  (slock-AF_INET/1){+.-...}, at: [...] selinux_netlbl_socket_connect
  #1:  (rcu_read_lock){.+.+..}, at: [&lt;...&gt;] netlbl_conn_setattr

 stack backtrace:
 CPU: 1 PID: 731 Comm: ping Not tainted 3.11.0-rc3+ #19
 Hardware name: Bochs Bochs, BIOS Bochs 01/01/2011
  0000000000000001 ffff88006f659d28 ffffffff81726b6a ffff88003732c500
  ffff88006f659d58 ffffffff810e4457 ffff88006b845a00 0000000000000000
  000000000000000c ffff880075aa2f50 ffff88006f659d90 ffffffff8169bec7
 Call Trace:
  [&lt;ffffffff81726b6a&gt;] dump_stack+0x54/0x74
  [&lt;ffffffff810e4457&gt;] lockdep_rcu_suspicious+0xe7/0x120
  [&lt;ffffffff8169bec7&gt;] cipso_v4_sock_setattr+0x187/0x1a0
  [&lt;ffffffff8170f317&gt;] netlbl_conn_setattr+0x187/0x190
  [&lt;ffffffff8170f195&gt;] ? netlbl_conn_setattr+0x5/0x190
  [&lt;ffffffff8131ac9e&gt;] selinux_netlbl_socket_connect+0xae/0xc0
  [&lt;ffffffff81303025&gt;] selinux_socket_connect+0x135/0x170
  [&lt;ffffffff8119d127&gt;] ? might_fault+0x57/0xb0
  [&lt;ffffffff812fb146&gt;] security_socket_connect+0x16/0x20
  [&lt;ffffffff815d3ad3&gt;] SYSC_connect+0x73/0x130
  [&lt;ffffffff81739a85&gt;] ? sysret_check+0x22/0x5d
  [&lt;ffffffff810e5e2d&gt;] ? trace_hardirqs_on_caller+0xfd/0x1c0
  [&lt;ffffffff81373d4e&gt;] ? trace_hardirqs_on_thunk+0x3a/0x3f
  [&lt;ffffffff815d52be&gt;] SyS_connect+0xe/0x10
  [&lt;ffffffff81739a59&gt;] system_call_fastpath+0x16/0x1b

Signed-off-by: Paul Moore &lt;pmoore@redhat.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>Revert "ima: policy for RAMFS"</title>
<updated>2013-11-29T18:50:34Z</updated>
<author>
<name>Mimi Zohar</name>
<email>zohar@linux.vnet.ibm.com</email>
</author>
<published>2013-10-17T11:34:02Z</published>
<link rel='alternate' type='text/html' href='https://git.amat.us/linux/commit/?id=7288f91dd5b55d82e1dee9f0d24e9f4730d57392'/>
<id>urn:sha1:7288f91dd5b55d82e1dee9f0d24e9f4730d57392</id>
<content type='text'>
commit 08de59eb144d7c41351a467442f898d720f0f15f upstream.

This reverts commit 4c2c392763a682354fac65b6a569adec4e4b5387.

Everything in the initramfs should be measured and appraised,
but until the initramfs has extended attribute support, at
least measured.

Signed-off-by: Mimi Zohar &lt;zohar@us.ibm.com&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
</feed>
