posix: Make CONFIG_XENO_OPT_DEBUG_POSIX_SYNCHRO widely
PATCH 1/1 posix: Make CONFIG_XENO_OPT_DEBUG_POSIX_SYNCHRO widely
From: Jan Kiszka <[email protected]>
This converts the consistency checks for resource ownership from optional into unconditional. The motivation is preventing the risk of kernel crash in the presence of application bugs and the absence of CONFIG_XENO_OPT_DEBUG_POSIX_SYNCHRO which used to control this check.
The only remaining features that this config manages is then printing a warning on mutex deadlocks. This is simply moved under the parent CONFIG_XENO_OPT_DEBUG_USER.
Signed-off-by Jan Kiszka <[email protected]>
--- .travis.yml | 1 - include/cobalt/uapi/corectl.h | 2 +- kernel/cobalt/Kconfig | 11 ----------- kernel/cobalt/posix/cond.c | 3 +-- kernel/cobalt/posix/corectl.c | 2 -- kernel/cobalt/posix/mutex.c | 8 +++----- kernel/cobalt/posix/sem.c | 3 +-- 7 files changed, 6 insertions(+), 24 deletions(-)
.travis.yml +0 -1
@@ -67,7 +67,6 @@ before_script: - ./scripts/config -e XENO_OPT_DEBUG_MEMORY - ./scripts/config -e XENO_OPT_DEBUG_CONTEXT - ./scripts/config -e XENO_OPT_DEBUG_USER - - ./scripts/config -e XENO_OPT_DEBUG_POSIX_SYNCHRO - ./scripts/config -e XENO_OPT_DEBUG_LEGACY - ./scripts/config -e XENO_OPT_DEBUG_TRACE_RELAX - ./scripts/config -e XENO_DRIVERS_16550A
include/cobalt/uapi/corectl.h +1 -1
@@ -29,7 +29,7 @@# define _CC_COBALT_DEBUG_USER 8# define _CC_COBALT_DEBUG_MUTEX_RELAXED 16# define _CC_COBALT_DEBUG_MUTEX_SLEEP 32 -# define _CC_COBALT_DEBUG_POSIX_SYNCHRO 64 +/* bit 6 (64) formerly used for DEBUG_POSIX_SYNCHRO */ # define _CC_COBALT_DEBUG_LEGACY 128# define _CC_COBALT_DEBUG_TRACE_RELAX 256# define _CC_COBALT_DEBUG_NET 512
kernel/cobalt/Kconfig +0 -11
@@ -436,17 +436,6 @@ config XENO_OPT_DEBUG_MUTEX_SLEEP disables the normal fast mutex operations from user-space, causing a system call for each mutex acquisition/release. -config XENO_OPT_DEBUG_POSIX_SYNCHRO - bool "Detect POSIX synchronization issues" - default n - help - When this debug category is enabled, calls to the thread - synchronization services are checked for consistency, beyond - the requirements of the POSIX standard. In most cases, a - faulty call results in error EPERM when detected. - - This option has negligible overhead. - config XENO_OPT_DEBUG_LEGACY bool "Detect usage of legacy constructs/features" default n
kernel/cobalt/posix/cond.c +1 -2
@@ -139,8 +139,7 @@ static inline int cobalt_cond_timedwait_prologue(struct xnthread *cur, goto unlock_and_return; } -if (IS_ENABLED (CONFIG_XENO_OPT_DEBUG_POSIX_SYNCHRO ) && - cond->resnode.scope != +if (cond->resnode.scope !=cobalt_current_resources (cond->attr.pshared)) { err = -EPERM ; goto unlock_and_return;
kernel/cobalt/posix/corectl.c +0 -2
@@ -73,8 +73,6 @@ static int do_conf_option(int option, void __user *u_buf, size_t u_bufsz) val |= _CC_COBALT_DEBUG_MUTEX_RELAXED;if (IS_ENABLED (CONFIG_XENO_OPT_DEBUG_MUTEX_SLEEP )) val |= _CC_COBALT_DEBUG_MUTEX_SLEEP; -if (IS_ENABLED (CONFIG_XENO_OPT_DEBUG_POSIX_SYNCHRO )) - val |= _CC_COBALT_DEBUG_POSIX_SYNCHRO;if (IS_ENABLED (CONFIG_XENO_OPT_DEBUG_LEGACY )) val |= _CC_COBALT_DEBUG_LEGACY;if (IS_ENABLED (CONFIG_XENO_OPT_DEBUG_TRACE_RELAX ))
kernel/cobalt/posix/mutex.c +3 -5
@@ -104,8 +104,7 @@ int cobalt_mutex_release(struct xnthread *curr, if (!cobalt_obj_active(mutex, COBALT_MUTEX_MAGIC, struct cobalt_mutex))return -EINVAL ; -if (IS_ENABLED (CONFIG_XENO_OPT_DEBUG_POSIX_SYNCHRO ) && - mutex->resnode.scope != +if (mutex->resnode.scope !=cobalt_current_resources (mutex->attr.pshared))return -EPERM ;
@@ -159,8 +158,7 @@ redo: goto out; } -if (IS_ENABLED (CONFIG_XENO_OPT_DEBUG_POSIX_SYNCHRO ) && - mutex->resnode.scope != +if (mutex->resnode.scope !=cobalt_current_resources (mutex->attr.pshared)) { ret = -EPERM ; goto out;
@@ -190,7 +188,7 @@ redo:switch (mutex->attr.type) {case PTHREAD_MUTEX_NORMAL :/* Attempting to relock a normal mutex, deadlock. */ -if (IS_ENABLED (CONFIG_XENO_OPT_DEBUG_POSIX_SYNCHRO )) +if (IS_ENABLED (XENO_OPT_DEBUG_USER ))printk (XENO_WARNING "thread %s deadlocks on non-recursive mutex\n" , curr->name);
kernel/cobalt/posix/sem.c +1 -2
@@ -36,8 +36,7 @@ static inline int sem_check(struct cobalt_sem *sem)if (sem ==NULL || sem->magic !=COBALT_SEM_MAGIC )return -EINVAL ; -if (IS_ENABLED (CONFIG_XENO_OPT_DEBUG_POSIX_SYNCHRO ) && - sem->resnode.scope && sem->resnode.scope !=sem_kqueue (sem)) +if (sem->resnode.scope && sem->resnode.scope !=sem_kqueue (sem))return -EPERM ;return 0 ;
Signature · 1 line
2.16.4