Skip to contentSkip to conversation

cobalt: Allow tasks with non-locked memory

RFC PATCH In review Richard Weinberger 2 participants 4 messages May 29, 2019 – May 30, 2019

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 cobalt: Allow tasks with non-locked memory

libsanitizer intercepts mlockall() and makes it a nop. Handle this case here to allow debugging Xenomai applications with ASAN and friends.

While fixing Linux or libsanitizer would be the prettiest approach, making cobalt less strict regarding VM_LOCKED is the most practical way to get libsanitizer work with Xenomai.

---
Hi!

I'm using a variant of this patch to utilize ASAN/UBSAN to test in-house Xenomai applications.

libsanitizer seems do disable mlockall() due to a Linux bug:
https://github.com/gcc-mirror/gcc/blob/master/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc#L5982

Thanks,
//richard

---
 kernel/cobalt/posix/process.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
kernel/cobalt/posix/process.c +3 -5
index 6b10abb699d5..86ceac826ae0 100644
@@ -579,11 +579,9 @@ static inline int disable_ondemand_memory(void)
 	siginfo_t si;
 
 	if ((p->mm->def_flags & VM_LOCKED) == 0) {
-		memset(&si, 0, sizeof(si));
-		si.si_signo = SIGDEBUG;
-		si.si_code = SI_QUEUE;
-		si.si_int = SIGDEBUG_NOMLOCK | sigdebug_marker;
-		send_sig_info(SIGDEBUG, &si, p);
+		printk(XENO_WARNING
+			"%s[%d] Task without VM_LOCKED, latencies expected!\n",
+			current->comm, task_pid_nr(current));
 		return 0;
 	}
 
Signature · 1 line
2.16.4
#1 lore raw
Quoted 34 lines · Richard Weinberger via Xenomai

libsanitizer intercepts mlockall() and makes it a nop. Handle this case here to allow debugging Xenomai applications with ASAN and friends.

While fixing Linux or libsanitizer would be the prettiest approach, making cobalt less strict regarding VM_LOCKED is the most practical way to get libsanitizer work with Xenomai.

---
Hi!

I'm using a variant of this patch to utilize ASAN/UBSAN to test in-house Xenomai applications.

libsanitizer seems do disable mlockall() due to a Linux bug:
https://github.com/gcc-mirror/gcc/blob/master/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc#L5982

Thanks,
//richard

---
  kernel/cobalt/posix/process.c | 8 +++-----
  1 file changed, 3 insertions(+), 5 deletions(-)
kernel/cobalt/posix/process.c +0 -1
index 6b10abb699d5..86ceac826ae0 100644
@@ -579,11 +579,9 @@ static inline int disable_ondemand_memory(void)
  	siginfo_t si;
 
  	if ((p->mm->def_flags & VM_LOCKED) == 0) {
-		memset(&si, 0, sizeof(si));

kernel/cobalt/posix/process.c static inline int disable_ondemand_memory(void) · line 587

Quoted 10 lines
kernel/cobalt/posix/process.c +3 -4
-		si.si_signo = SIGDEBUG;
-		si.si_code = SI_QUEUE;
-		si.si_int = SIGDEBUG_NOMLOCK | sigdebug_marker;
-		send_sig_info(SIGDEBUG, &si, p);
+		printk(XENO_WARNING
+			"%s[%d] Task without VM_LOCKED, latencies expected!\n",
+			current->comm, task_pid_nr(current));
  		return 0;
  	}
 

Why not simply installing a signal handler in the application that swallows this reason for SIGDEBUG when it's under libsanitizer controller? Or setting the whole signal on ignore?

Jan

#2 lore raw

----- Ursprüngliche Mail -----

Quoted 3 lines

Why not simply installing a signal handler in the application that swallows this reason for SIGDEBUG when it's under libsanitizer controller? Or setting the whole signal on ignore?

Simply because I was not sure whether I'm allowed to steal SIGDEBUG from Xenomai since it installs its own signal handler.
If installing my own handler is the preferred way, I'm happy. One patch less to carry around. :-)

Thanks,
//richard

#3 lore raw
Quoted 9 lines · Richard Weinberger

----- Ursprüngliche Mail -----

Quoted 3 lines

Why not simply installing a signal handler in the application that swallows this reason for SIGDEBUG when it's under libsanitizer controller? Or setting the whole signal on ignore?

Simply because I was not sure whether I'm allowed to steal SIGDEBUG from Xenomai since it installs its own signal handler.
If installing my own handler is the preferred way, I'm happy. One patch less to carry around. :-)

libcobalt only installs a fallback handler that does reporting. There is no issue adding your own. Rather, it's the normal pattern when the application wants to react on the various debug reasons.

Jan