SELinux: Fix RCU deref check warning in sel_netport_insert()
PATCH 1/1 SELinux: Fix RCU deref check warning in sel_netport_insert()
Fix the following bug in sel_netport_insert() where rcu_dereference() should be rcu_dereference_protected() as sel_netport_lock is held.
===================================================
[ INFO: suspicious rcu_dereference_check() usage. ]
---------------------------------------------------security/selinux/netport.c:127 invoked rcu_dereference_check() without protection!
other info that might help us debug this:
rcu_scheduler_active = 1, debug_locks = 0
1 lock held by ossec-rootcheck/3323:
#0: (sel_netport_lock){+.....}, at: [<ffffffff8117d775>] sel_netport_sid+0xbb/0x226
stack backtrace: Pid: 3323, comm: ossec-rootcheck Not tainted 3.1.0-rc8-fsdevel+ #1095 Call Trace: [<ffffffff8105cfb7>] lockdep_rcu_dereference+0xa7/0xb0 [<ffffffff8117d871>] sel_netport_sid+0x1b7/0x226 [<ffffffff8117d6ba>] ? sel_netport_avc_callback+0xbc/0xbc [<ffffffff8117556c>] selinux_socket_bind+0x115/0x230 [<ffffffff810a5388>] ? might_fault+0x4e/0x9e [<ffffffff810a53d1>] ? might_fault+0x97/0x9e [<ffffffff81171cf4>] security_socket_bind+0x11/0x13 [<ffffffff812ba967>] sys_bind+0x56/0x95 [<ffffffff81380dac>] ? sysret_check+0x27/0x62 [<ffffffff8105b767>] ? trace_hardirqs_on_caller+0x11e/0x155 [<ffffffff81076fcd>] ? audit_syscall_entry+0x17b/0x1ae [<ffffffff811b5eae>] ? trace_hardirqs_on_thunk+0x3a/0x3f [<ffffffff81380d7b>] system_call_fastpath+0x16/0x1b
---
security/selinux/netport.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-)
security/selinux/netport.c +3 -1
@@ -123,7 +123,9 @@ static void sel_netport_insert(struct sel_netport *port)if (sel_netport_hash[idx].size ==SEL_NETPORT_HASH_BKT_LIMIT ) {struct sel_netport *tail; tail =list_entry ( -rcu_dereference (sel_netport_hash[idx].list.prev), +rcu_dereference_protected ( + sel_netport_hash[idx].list.prev, +lockdep_is_held (&sel_netport_lock)), struct sel_netport, list);list_del_rcu (&tail->list);kfree_rcu (tail, rcu);
--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
Quoted 3 lines · David Howells
Fix the following bug in
sel_netport_insert()wherercu_dereference()should bercu_dereference_protected()assel_netport_lockis held.
Which kernel should this go to?
Quoted 53 lines
===================================================
[ INFO: suspiciousrcu_dereference_check()usage. ]
---------------------------------------------------security/selinux/netport.c:127invokedrcu_dereference_check()without protection!other info that might help us debug this:
rcu_scheduler_active= 1,debug_locks= 0
1 lock held by ossec-rootcheck/3323:
#0: (sel_netport_lock){+.....}, at: [<ffffffff8117d775>]sel_netport_sid+0xbb/0x226stack backtrace: Pid: 3323, comm: ossec-rootcheck Not tainted 3.1.0-rc8-fsdevel+ #1095 Call Trace: [<ffffffff8105cfb7>] lockdep_rcu_dereference+0xa7/0xb0 [<ffffffff8117d871>] sel_netport_sid+0x1b7/0x226 [<ffffffff8117d6ba>] ? sel_netport_avc_callback+0xbc/0xbc [<ffffffff8117556c>] selinux_socket_bind+0x115/0x230 [<ffffffff810a5388>] ? might_fault+0x4e/0x9e [<ffffffff810a53d1>] ? might_fault+0x97/0x9e [<ffffffff81171cf4>] security_socket_bind+0x11/0x13 [<ffffffff812ba967>] sys_bind+0x56/0x95 [<ffffffff81380dac>] ? sysret_check+0x27/0x62 [<ffffffff8105b767>] ? trace_hardirqs_on_caller+0x11e/0x155 [<ffffffff81076fcd>] ? audit_syscall_entry+0x17b/0x1ae [<ffffffff811b5eae>] ? trace_hardirqs_on_thunk+0x3a/0x3f [<ffffffff81380d7b>] system_call_fastpath+0x16/0x1bSigned-off-by David Howells <[email protected]>Acked-by Paul Moore <[email protected]>Acked-by Eric Dumazet <[email protected]>---
security/selinux/netport.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-)security/selinux/netport.c +3
-1@@ -123,7 +123,9 @@ static void sel_netport_insert(struct sel_netport *port)if (sel_netport_hash[idx].size ==SEL_NETPORT_HASH_BKT_LIMIT ) {struct sel_netport *tail; tail =list_entry ( -rcu_dereference (sel_netport_hash[idx].list.prev), +rcu_dereference_protected ( + sel_netport_hash[idx].list.prev, +lockdep_is_held (&sel_netport_lock)), struct sel_netport, list);list_del_rcu (&tail->list);kfree_rcu (tail, rcu);
Signature · 7 lines
James Morris <[email protected]> -- This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
Quoted 7 lines · James Morris
Quoted 3 lines · David Howells
Fix the following bug in
sel_netport_insert()wherercu_dereference()should bercu_dereference_protected()assel_netport_lockis held.Which kernel should this go to?
I'm applying it to Linus's git head. It probably needs to go to some stable trees too, I suppose.
David
--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.