Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1351188 > unrolled thread

Re: [PATCH v4 0/2] make sigaltstack() compatible with swapcontext()

Started bySzabolcs Nagy <nsz@port70.net>
First post2016-03-06 21:10 +0100
Last post2016-03-06 21:30 +0100
Articles 3 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: [PATCH v4 0/2] make sigaltstack() compatible with swapcontext() Szabolcs Nagy <nsz@port70.net> - 2016-03-06 21:10 +0100
    Re: [PATCH v4 0/2] make sigaltstack() compatible with swapcontext() Szabolcs Nagy <nsz@port70.net> - 2016-03-06 21:30 +0100
    Re: [PATCH v4 0/2] make sigaltstack() compatible with swapcontext() Stas Sergeev <stsp@list.ru> - 2016-03-06 21:30 +0100

#1351188 — Re: [PATCH v4 0/2] make sigaltstack() compatible with swapcontext()

FromSzabolcs Nagy <nsz@port70.net>
Date2016-03-06 21:10 +0100
SubjectRe: [PATCH v4 0/2] make sigaltstack() compatible with swapcontext()
Message-ID<r9Na2-1n4-15@gated-at.bofh.it>
* Stas Sergeev <stsp@list.ru> [2016-03-01 00:29:03 +0300]:
> The following patches make it possible to use swapcontext()
> in a sighandler that works on sigaltstack.

i don't think that's possible, the (obsolete) userspace
*context functions cannot operate on kernel provided
ucontext_t structs, so they are not usable in signal
handlers.

at least not on most target archs.

so i don't understand how the tests can work portably.

> The approach is inspired by Andy Lutomirski's suggestion that
> sigaltstack should disarm itself after saving into uc_stack:
> https://lkml.org/lkml/2016/2/1/594
> 
> I add the SS_AUTODISARM flag that does exactly that.
> On sighandler exit, the sigaltstack is restored from uc_stack.
> Another possible name could be SS_ONESHOT, but, since it gets
> always re-enabled, I choose SS_AUTODISARM.
> 
> [PATCH 1/2] sigaltstack: implement SS_AUTODISARM flag
> 	This patch implements SS_AUTODISARM flag
> [PATCH 2/2] selftests: Add test for sigaltstack(SS_AUTODISARM)
> 	This patch adds the selftest code for new functionality
> 
> CC: linux-kernel@vger.kernel.org
> CC: linux-api@vger.kernel.org
> CC: Andy Lutomirski <luto@amacapital.net>
> CC: Oleg Nesterov <oleg@redhat.com>
> CC: Shuah Khan <shuahkh@osg.samsung.com>
> 
> Diffstat:
>  include/linux/sched.h                        |    8 +
>  include/linux/signal.h                       |    4 
>  include/uapi/linux/signal.h                  |    3 
>  kernel/fork.c                                |    2 
>  kernel/signal.c                              |   23 ++--
>  tools/testing/selftests/Makefile             |    1 
>  tools/testing/selftests/sigaltstack/Makefile |    8 +
>  tools/testing/selftests/sigaltstack/sas.c    |  151 +++++++++++++++++++++++++++
>  8 files changed, 187 insertions(+), 13 deletions(-)
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-api" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

[toc] | [next] | [standalone]


#1351193

FromSzabolcs Nagy <nsz@port70.net>
Date2016-03-06 21:30 +0100
Message-ID<r9Ntn-1uz-1@gated-at.bofh.it>
In reply to#1351188
* Szabolcs Nagy <nsz@port70.net> [2016-03-06 21:02:08 +0100]:
> * Stas Sergeev <stsp@list.ru> [2016-03-01 00:29:03 +0300]:
> > The following patches make it possible to use swapcontext()
> > in a sighandler that works on sigaltstack.
> 
> i don't think that's possible, the (obsolete) userspace
> *context functions cannot operate on kernel provided
> ucontext_t structs, so they are not usable in signal
> handlers.
> 
> at least not on most target archs.
> 
> so i don't understand how the tests can work portably.
> 

i see the test does not use the kernel ucontext_t
and only synchronous context switch is done

sorry for the noise.

[toc] | [prev] | [next] | [standalone]


#1351194

FromStas Sergeev <stsp@list.ru>
Date2016-03-06 21:30 +0100
Message-ID<r9Nto-1uz-3@gated-at.bofh.it>
In reply to#1351188
06.03.2016 23:02, Szabolcs Nagy пишет:
> * Stas Sergeev <stsp@list.ru> [2016-03-01 00:29:03 +0300]:
>> The following patches make it possible to use swapcontext()
>> in a sighandler that works on sigaltstack.
> i don't think that's possible, the (obsolete) userspace
> *context functions cannot operate on kernel provided
> ucontext_t structs,
It doesn't have to.
It does the normal getcontext()/swapcontext() sequences,
as if it would be switching from any casual code place.
Kernel-provided context structs are completely irrelevant.
For more details please see the test-case I posted in that patch series.
It shows what can be done and how.

>   so they are not usable in signal
> handlers.
Please note the fact that swapcontext() also replaces the
signal mask as part of the context switching. This is a very
strong hint that it was intended to work with signal handlers.
And in fact it perfectly does.
What I want is only to make it friendly to sigaltstack.
I am not making it friendly to signal handlers in general,
because it already is.

> at least not on most target archs.
>
> so i don't understand how the tests can work portably.
If you apply my patch series, you can immediately test
it on any arch you want, thanks to the test-case my patch
adds to the kernel. Please let me know on what arch it fails.

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web