Module: xenomai-2.6
Branch: master
Commit: 90f306bd9b19bcb409585369805505f1b6738cb3
URL:    
http://git.xenomai.org/?p=xenomai-2.6.git;a=commit;h=90f306bd9b19bcb409585369805505f1b6738cb3

Author: Gilles Chanteperdrix <gilles.chanteperd...@xenomai.org>
Date:   Mon Jun 20 14:54:40 2016 +0200

nucleus/shadow: fix crash with debugs enabled

When running the sigdebug test with debugs enabled, we get the following
crash:
[   13.352576] Xenomai: bug at kernel/xenomai/nucleus/shadow.c:1413 (__c != 
xnpod_current_thread())
[   13.356437]
[   13.356437]  CPU  PID    PRI      TIMEOUT  STAT      NAME
[   13.356437] >  0  0       -1      0        00500080  ROOT
[   13.356437]    0  612      0      0        00b00380  main_task
[   13.356437] Master time base: clock=19096966371
[   13.356437]  00000001 ec995ef4 b01a9b4d b05d99cb b05d3d64 00000585 b05d9bc4 
ec995e8c
[   13.356437]  b019b635 00000086 b01b7800 00000000 00000003 715f7b87 00000004 a
fd95bd8
[   13.356437]  00000000 00000001 00000000 00000000 00000001 00000000 00000000 
00000005
[   13.356437] Call Trace:
[   13.356437]  [<b01a9b4d>] xnshadow_map+0x625/0x62e
[   13.356437]  [<b019b635>] ? xnregistry_enter+0x24b/0x58f
[   13.356437]  [<b01b7800>] ? rt_task_create+0x382/0x478
[   13.356437]  [<b01bfff8>] __rt_task_create+0x1c7/0x1f4
[   13.356437]  [<b016b59f>] ? ipipe_trace_function+0x21/0x23
[   13.356437]  [<b01a3dce>] losyscall_event+0x93/0x204
[   13.356437]  [<b016b907>] ipipe_syscall_hook+0x24/0x27
[   13.356437]  [<b0168f5e>] __ipipe_notify_syscall+0x51/0x1b2
[   13.356437]  [<b050501d>] pipeline_sysenter+0x7/0x1e

When xnshadow_harden() fails because of a signal, the call to
xnarch_trace_pid() which follows it xn xnshadow_map() triggers an
assertion in xnthread_current_task(). Avoid this by not calling
xnarch_trace_pid() when xnshadow_harden() failed.

---

 ksrc/nucleus/shadow.c |   11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/ksrc/nucleus/shadow.c b/ksrc/nucleus/shadow.c
index f6f7ca2..c93e29f 100644
--- a/ksrc/nucleus/shadow.c
+++ b/ksrc/nucleus/shadow.c
@@ -1408,8 +1408,15 @@ int xnshadow_map(xnthread_t *curr, xncompletion_t __user 
*u_completion,
         */
        xnthread_set_info(curr, XNPRIOSET);
 
-       xnarch_trace_pid(xnthread_current_user_pid(curr),
-                        xnthread_current_priority(curr));
+       if (ret == 0)
+               /*
+                * Calling xnthread_current_task() via
+                * xnthread_current_user_pid() from secondary mode causes
+                * the assertion curr != xnpod_current_thread() to trigger, so
+                * do not call xnarch_trace_pid() if xnshadow_harden() failed
+                */
+               xnarch_trace_pid(xnthread_current_user_pid(curr),
+                               xnthread_current_priority(curr));
 
        return ret;
 }


_______________________________________________
Xenomai-git mailing list
Xenomai-git@xenomai.org
https://xenomai.org/mailman/listinfo/xenomai-git

Reply via email to