From: Philippe Gerum <rpm@xenomai.org>
To: Jan Kiszka <jan.kiszka@domain.hid>
Cc: xenomai-core <xenomai@xenomai.org>
Subject: Re: [Xenomai-core] [PATCH] Catch multiple xnshadow_map attempts
Date: Fri, 21 Nov 2008 16:03:15 +0100 [thread overview]
Message-ID: <4926CDB3.2000601@domain.hid> (raw)
In-Reply-To: <4926CCEF.8050106@domain.hid>
Philippe Gerum wrote:
> Jan Kiszka wrote:
>> Philippe Gerum wrote:
>>> Jan Kiszka wrote:
>>>> My customer managed to find another hidden door to Xenomai's hell:
>>>> Trying to create a Xenomai POSIX thread from within a native thread. A
>>>> think the other way around would "work" as well. The precise scenario
>>>> was native thread -> dlopen(libs that's linked against libpthread_rt) ->
>>>> __init_posix_interface -> __wrap_pthread_setschedparam -> oops. That
>>>> scenario revealed two more issues in fact.
>>>>
>>>> Here is a patch to remove this hell gate by catching xnshadow_map
>>>> invocations from withing already mapped shadow thread.
>>>>
>>> Any reason why the XNMAPPED predicate did not work in your case?
>> Sorry, which one? Keep in mind that the thread thrown at the second
>> xnshadow_map is a virgin one, just allocated from scratch.
>>
>
> Ok, got it, it's the converse case, so let's deal for that:
>
> --- ksrc/nucleus/shadow.c (revision 4411)
> +++ ksrc/nucleus/shadow.c (working copy)
> @@ -1331,7 +1331,7 @@
> * case, the real-time mapping operation has failed globally, and no
> * Xenomai resource remains attached to it.
> *
> - * - -EINVAL is returned if the thread control block does not bear the
> + * - -EBUSY is returned if the thread control block does not bear the
> * XNSHADOW bit, or if the thread has already been mapped.
> *
> * Environments:
> @@ -1354,8 +1354,8 @@
> if (!xnthread_test_state(thread, XNSHADOW))
> return -EINVAL;
>
> - if (xnthread_test_state(thread, XNMAPPED))
> - return -EINVAL;
> + if (xnshadow_thread(current) || xnthread_test_state(thread, XNMAPPED))
> + return -EBUSY;
>
> if (!access_wok(u_mode, sizeof(*u_mode)))
> return -EFAULT;
>
--- ksrc/nucleus/shadow.c (revision 4411)
+++ ksrc/nucleus/shadow.c (working copy)
@@ -1332,8 +1332,10 @@
* Xenomai resource remains attached to it.
*
* - -EINVAL is returned if the thread control block does not bear the
- * XNSHADOW bit, or if the thread has already been mapped.
+ * XNSHADOW bit.
*
+ * - -EBUSY is returned if the thread has already been mapped.
+ *
* Environments:
--
Philippe.
next prev parent reply other threads:[~2008-11-21 15:03 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-11-21 10:18 [Xenomai-core] [PATCH] Catch multiple xnshadow_map attempts Jan Kiszka
2008-11-21 11:19 ` Philippe Gerum
2008-11-21 11:48 ` Jan Kiszka
2008-11-21 14:59 ` Philippe Gerum
2008-11-21 15:03 ` Philippe Gerum [this message]
2008-11-21 15:23 ` Jan Kiszka
2008-11-21 16:40 ` Philippe Gerum
2008-11-21 16:45 ` Jan Kiszka
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4926CDB3.2000601@domain.hid \
--to=rpm@xenomai.org \
--cc=jan.kiszka@domain.hid \
--cc=xenomai@xenomai.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.