Enhancements of signal_copyinfo extension
cover Enhancements of signal_copyinfo extension
Please see patches for details.
Jan
Jan Kiszka (4):
cobalt/posix: Move signal_put_siginfo unmodified cobalt/posix: Convert put_siginfo callback into boolean cobalt/posix: Provide compat version signal_copyinfo extension cobalt/posix: Evaluate return code of signal_copyinfo extensions
kernel/cobalt/posix/extension.h | 4 ++ kernel/cobalt/posix/signal.c | 112 +++++++++++++++++++++------------------- kernel/cobalt/posix/signal.h | 8 +-- kernel/cobalt/posix/syscall32.c | 4 +- 4 files changed, 67 insertions(+), 61 deletions(-)
Signature · 1 line
2.13.7
PATCH 1/4 cobalt/posix: Move signal_put_siginfo unmodified
From: Jan Kiszka <[email protected]>
We will need it inside signal_wait. No functional changes.
--- kernel/cobalt/posix/signal.c | 62 ++++++++++++++++++++++---------------------- 1 file changed, 31 insertions(+), 31 deletions(-)
kernel/cobalt/posix/signal.c +31 -31
@@ -201,6 +201,37 @@ void cobalt_signal_flush(struct cobalt_thread *thread)sigemptyset (&thread->sigpending); } +static int signal_put_siginfo (void __user *u_si,const struct siginfo *si, +int overrun) +{ +struct siginfo __user *u_p = u_si; +int ret; + + ret =__xn_put_user (si->si_signo, &u_p->si_signo); + ret |=__xn_put_user (si->si_errno, &u_p->si_errno); + ret |=__xn_put_user (si->si_code, &u_p->si_code); + +/* +* Copy the generic/standard siginfo bits to userland. +*/ +switch (si->si_code) { +case SI_TIMER : + ret |=__xn_put_user (si->si_tid, &u_p->si_tid); + ret |=__xn_put_user (si->si_ptr, &u_p->si_ptr); + ret |=__xn_put_user (overrun, &u_p->si_overrun); +break ; +case SI_QUEUE : +case SI_MESGQ : + ret |=__xn_put_user (si->si_ptr, &u_p->si_ptr); +/* falldown wanted. */ +case SI_USER : + ret |=__xn_put_user (si->si_pid, &u_p->si_pid); + ret |=__xn_put_user (si->si_uid, &u_p->si_uid); + } + +return ret; +} + static int signal_wait(sigset_t *set, xnticks_t timeout, void __user *u_si, int (*put_siginfo)(void __user *u_si,
@@ -335,37 +366,6 @@ fail:return ret; } -static int signal_put_siginfo (void __user *u_si,const struct siginfo *si, -int overrun) -{ -struct siginfo __user *u_p = u_si; -int ret; - - ret =__xn_put_user (si->si_signo, &u_p->si_signo); - ret |=__xn_put_user (si->si_errno, &u_p->si_errno); - ret |=__xn_put_user (si->si_code, &u_p->si_code); - -/* -* Copy the generic/standard siginfo bits to userland. -*/ -switch (si->si_code) { -case SI_TIMER : - ret |=__xn_put_user (si->si_tid, &u_p->si_tid); - ret |=__xn_put_user (si->si_ptr, &u_p->si_ptr); - ret |=__xn_put_user (overrun, &u_p->si_overrun); -break ; -case SI_QUEUE : -case SI_MESGQ : - ret |=__xn_put_user (si->si_ptr, &u_p->si_ptr); -/* falldown wanted. */ -case SI_USER : - ret |=__xn_put_user (si->si_pid, &u_p->si_pid); - ret |=__xn_put_user (si->si_uid, &u_p->si_uid); - } - -return ret; -} -int __cobalt_sigwait (sigset_t *set) {return signal_wait (set,XN_INFINITE ,NULL ,NULL );
Signature · 1 line
2.13.7
PATCH 2/4 cobalt/posix: Convert put_siginfo callback into boolean
In reply to Jan KiszkaFrom: Jan Kiszka <[email protected]>
We want to pass the information "compat invocation" to the extension signal_copyinfo as well and therefore need it in boolean form. To avoid unneeded conversions, pass it as bool from the source to the sink.
--- kernel/cobalt/posix/signal.c | 33 ++++++++++++++++----------------- kernel/cobalt/posix/signal.h | 8 ++------ kernel/cobalt/posix/syscall32.c | 4 ++-- 3 files changed, 20 insertions(+), 25 deletions(-)
kernel/cobalt/posix/signal.c +16 -17
@@ -17,6 +17,7 @@*/ #include <linux/sched.h> #include <cobalt/kernel/assert.h> +#include <cobalt/kernel/compat.h> #include "internal.h" #include "signal.h" #include "thread.h"
@@ -233,10 +234,7 @@ static int signal_put_siginfo(void __user *u_si, const struct siginfo *si, }static int signal_wait (sigset_t *set,xnticks_t timeout, -void __user *u_si, -int (*put_siginfo)(void __user *u_si, -const struct siginfo *si, -int overrun)) +void __user *u_si,bool compat) {struct cobalt_sigpending *sigp =NULL ;struct cobalt_sigwait_context swc;
@@ -338,7 +336,12 @@ done:if (u_si ==NULL ) goto out;/* Return signo only. */ - ret =put_siginfo (u_si, sip, overrun); +#ifdef CONFIG_XENO_ARCH_SYS3264 +if (compat) + ret =sys32_put_siginfo (u_si, sip, overrun); + else +#endif + ret =signal_put_siginfo (u_si, sip, overrun);if (ret) goto out;
@@ -368,7 +371,7 @@ fail:int __cobalt_sigwait (sigset_t *set) { -return signal_wait (set,XN_INFINITE ,NULL ,NULL ); +return signal_wait (set,XN_INFINITE ,NULL , false); } COBALT_SYSCALL(sigwait, primary,
@@ -380,7 +383,7 @@ COBALT_SYSCALL(sigwait, primary,if (cobalt_copy_from_user (&set, u_set,sizeof (set)))return -EFAULT ; - sig =signal_wait (&set,XN_INFINITE ,NULL ,NULL ); + sig =signal_wait (&set,XN_INFINITE ,NULL , false);if (sig <0 )return sig;
@@ -390,9 +393,7 @@ COBALT_SYSCALL(sigwait, primary,int __cobalt_sigtimedwait (sigset_t *set,const struct timespec *timeout,void __user *u_si, -int (*put_siginfo)(void __user *u_si, -const struct siginfo *si, -int overrun)) +bool compat) {xnticks_t ticks;
@@ -403,7 +404,7 @@ int __cobalt_sigtimedwait(sigset_t *set,if (ticks++ ==0 ) ticks =XN_NONBLOCK ; -return signal_wait (set, ticks, u_si, put_siginfo); +return signal_wait (set, ticks, u_si, compat); } COBALT_SYSCALL(sigtimedwait, nonrestartable,
@@ -420,16 +421,14 @@ COBALT_SYSCALL(sigtimedwait, nonrestartable,if (cobalt_copy_from_user (&timeout, u_timeout,sizeof (timeout)))return -EFAULT ; -return __cobalt_sigtimedwait (&set, &timeout, u_si, signal_put_siginfo); +return __cobalt_sigtimedwait (&set, &timeout, u_si, false); }int __cobalt_sigwaitinfo (sigset_t *set,void __user *u_si, -int (*put_siginfo)(void __user *u_si, -const struct siginfo *si, -int overrun)) +bool compat) { -return signal_wait (set,XN_INFINITE , u_si, put_siginfo); +return signal_wait (set,XN_INFINITE , u_si, compat); } COBALT_SYSCALL(sigwaitinfo, nonrestartable,
@@ -440,7 +439,7 @@ COBALT_SYSCALL(sigwaitinfo, nonrestartable,if (cobalt_copy_from_user (&set, u_set,sizeof (set)))return -EFAULT ; -return __cobalt_sigwaitinfo (&set, u_si, signal_put_siginfo); +return __cobalt_sigwaitinfo (&set, u_si, false); }COBALT_SYSCALL (sigpending, primary, (old_sigset_t__user *u_set))
kernel/cobalt/posix/signal.h +2 -6
@@ -61,15 +61,11 @@ int __cobalt_sigwait(sigset_t *set);int __cobalt_sigtimedwait (sigset_t *set,const struct timespec *timeout,void __user *u_si, -int (*put_siginfo)(void __user *u_si, -const struct siginfo *si, -int overrun)); +bool compat);int __cobalt_sigwaitinfo (sigset_t *set,void __user *u_si, -int (*put_siginfo)(void __user *u_si, -const struct siginfo *si, -int overrun)); +bool compat);int __cobalt_sigqueue (pid_t pid,int sig,const union sigval *value);
kernel/cobalt/posix/syscall32.c +2 -2
@@ -613,7 +613,7 @@ COBALT_SYSCALL32emu(sigtimedwait, nonrestartable,if (ret)return ret; -return __cobalt_sigtimedwait (&set, &timeout, u_si, sys32_put_siginfo); +return __cobalt_sigtimedwait (&set, &timeout, u_si, true); } COBALT_SYSCALL32emu(sigwaitinfo, nonrestartable,
@@ -627,7 +627,7 @@ COBALT_SYSCALL32emu(sigwaitinfo, nonrestartable,if (ret)return ret; -return __cobalt_sigwaitinfo (&set, u_si, sys32_put_siginfo); +return __cobalt_sigwaitinfo (&set, u_si, true); }COBALT_SYSCALL32emu (sigpending, primary, (compat_old_sigset_t__user *u_set))
Signature · 1 line
2.13.7
PATCH 3/4 cobalt/posix: Provide compat version signal_copyinfo extension
In reply to Jan KiszkaFrom: Jan Kiszka <[email protected]>
Enables compat-capable implementations of this extension.
--- kernel/cobalt/posix/extension.h | 4 ++++ kernel/cobalt/posix/signal.c | 20 +++++++++++++------- 2 files changed, 17 insertions(+), 7 deletions(-)
kernel/cobalt/posix/extension.h +4 -0
@@ -54,6 +54,10 @@ struct cobalt_extension {void __user *u_si, const struct siginfo *si, int overrun); +int (*signal_copyinfo_compat)(struct cobalt_extref *refthread, +void __user *u_si, +const struct siginfo *si, +int overrun);int (*sched_yield)(struct cobalt_extref *curref); int (*thread_setsched)(struct cobalt_extref *refthread, /* nklocked, IRQs off. */ struct xnsched_class *sched_class,
kernel/cobalt/posix/signal.c +13 -7
@@ -337,17 +337,23 @@ done: goto out;/* Return signo only. */ #ifdef CONFIG_XENO_ARCH_SYS3264 -if (compat) +if (compat) { ret =sys32_put_siginfo (u_si, sip, overrun); - else +if (!ret) +/* Allow an extended target to receive more data. */ +cobalt_call_extension (signal_copyinfo_compat, + &curr->extref, ret, u_si, sip, + overrun); + } else#endif + { ret =signal_put_siginfo (u_si, sip, overrun); -if (ret) - goto out; +if (!ret) +/* Allow an extended target to receive more data. */ +cobalt_call_extension (signal_copyinfo, &curr->extref, + ret, u_si, sip, overrun); + } -/* Allow an extended target to receive more data. */ -cobalt_call_extension (signal_copyinfo, &curr->extref, - ret, u_si, sip, overrun); out:/* * If we pulled the signal information from a sigpending
Signature · 1 line
2.13.7
PATCH 4/4 cobalt/posix: Evaluate return code of signal_copyinfo extensions
In reply to Jan KiszkaFrom: Jan Kiszka <[email protected]>
They may fail as well, requiring us to return that code to the caller of signal_wait.
--- kernel/cobalt/posix/signal.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
kernel/cobalt/posix/signal.c +6 -5
@@ -341,17 +341,18 @@ done: ret =sys32_put_siginfo (u_si, sip, overrun);if (!ret)/* Allow an extended target to receive more data. */ -cobalt_call_extension (signal_copyinfo_compat, - &curr->extref, ret, u_si, sip, - overrun); + ret =cobalt_call_extension (signal_copyinfo_compat, + &curr->extref, ret, u_si, + sip, overrun); } else#endif { ret =signal_put_siginfo (u_si, sip, overrun);if (!ret)/* Allow an extended target to receive more data. */ -cobalt_call_extension (signal_copyinfo, &curr->extref, - ret, u_si, sip, overrun); + ret =cobalt_call_extension (signal_copyinfo, + &curr->extref, ret, u_si, + sip, overrun); } out:
Signature · 1 line
2.13.7