lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAEbykaXUy7HEyW7mBaTNmB94NwyjuJBbA1R-H49Jjk5M-iL_fw@mail.gmail.com>
Date:	Thu, 22 Mar 2012 01:43:22 +0200
From:	Ari Savolainen <ari.m.savolainen@...il.com>
To:	Peter Zijlstra <a.p.zijlstra@...llo.nl>,
	Paul Mackerras <paulus@...ba.org>, Ingo Molnar <mingo@...e.hu>,
	Arnaldo Carvalho de Melo <acme@...stprotocols.net>
Cc:	linux-kernel@...r.kernel.org
Subject: [PATCH] perf: Fix RCU dereference check in perf_event_comm

The warning below is printed when executing a command like
sudo perf record su - user -c "echo hello"

It's fixed by moving the call of perf_event_comm to be protected
by the task lock.

===============================
[ INFO: suspicious RCU usage. ]
3.3.0 #49 Not tainted
-------------------------------
include/linux/cgroup.h:567 suspicious rcu_dereference_check() usage!

other info that might help us debug this:

rcu_scheduler_active = 1, debug_locks = 0
1 lock held by su/3304:
 #0:  (&sig->cred_guard_mutex){+.+.+.}, at: [<ffffffff8117af66>]
prepare_bprm_creds+0x36/0x80

stack backtrace:
Pid: 3304, comm: su Not tainted 3.3.0 #49
Call Trace:
 [<ffffffff8109be55>] lockdep_rcu_suspicious+0xe5/0x100
 [<ffffffff811131fa>] perf_event_comm+0x37a/0x4d0
 [<ffffffff81144525>] ? remove_vma+0x65/0x80
 [<ffffffff810722e1>] ? get_parent_ip+0x11/0x50
 [<ffffffff814e6fad>] ? sub_preempt_count+0x9d/0xd0
 [<ffffffff8117ae05>] set_task_comm+0x75/0x1a0
 [<ffffffff8102b945>] ? mmap_rnd+0x45/0x50
 [<ffffffff8117b6d2>] setup_new_exec+0xa2/0x340
 [<ffffffff811c98f7>] load_elf_binary+0x3c7/0x19d0
 [<ffffffff814e3275>] ? _raw_read_unlock+0x35/0x60
 [<ffffffff8117a313>] ? search_binary_handler+0x1c3/0x530
 [<ffffffff810722e1>] ? get_parent_ip+0x11/0x50
 [<ffffffff814e6fad>] ? sub_preempt_count+0x9d/0xd0
 [<ffffffff814e6fad>] ? sub_preempt_count+0x9d/0xd0
 [<ffffffff811c9530>] ? do_mmap+0x40/0x40
 [<ffffffff8117a2f0>] search_binary_handler+0x1a0/0x530
 [<ffffffff8117a1a7>] ? search_binary_handler+0x57/0x530
 [<ffffffff8117974d>] ? copy_strings.isra.32+0x1fd/0x230
 [<ffffffff8117b44f>] do_execve_common.isra.36+0x43f/0x570
 [<ffffffff8117b166>] ? do_execve_common.isra.36+0x156/0x570
 [<ffffffff81296837>] ? __strncpy_from_user+0x27/0x60
 [<ffffffff8117b59b>] do_execve+0x1b/0x20
 [<ffffffff8100c317>] sys_execve+0x47/0x70
 [<ffffffff814eb39c>] stub_execve+0x6c/0xc0

Signed-off-by: Ari Savolainen <ari.m.savolainen@...il.com>
---
 fs/exec.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/fs/exec.c b/fs/exec.c
index 153dee1..373ff93 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -1067,8 +1067,8 @@ void set_task_comm(struct task_struct *tsk, char *buf)
 	memset(tsk->comm, 0, TASK_COMM_LEN);
 	wmb();
 	strlcpy(tsk->comm, buf, sizeof(tsk->comm));
-	task_unlock(tsk);
 	perf_event_comm(tsk);
+	task_unlock(tsk);
 }

 static void filename_to_taskname(char *tcomm, const char *fn, unsigned int len)
-- 
1.7.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ