[Xenomai-git] Wolfgang Mauerer : Fix handling of deleted message queue objects
Module: xenomai-gch Branch: for-head Commit: 167da0577e4be86bb46e21f2f164e0495d296a24 URL: http://git.xenomai.org/?p=xenomai-gch.git;a=commit;h=167da0577e4be86bb46e21f2f164e0495d296a24 Author: Wolfgang Mauerer Date: Fri Oct 2 10:49:27 2009 +0200 Fix handling of deleted message queue objects When a Xenomai thread tries to access a deleted message queue, it should obtain -ESRCH as error code both from within the kernel and for userland applications. However, userland sometimes receives wrong error codes because failure of the handle lookup operation is not correctly handled, which leads to subsequently different errors. This patch fixes the faulty patterns, and also provides a documentation update. Signed-off-by: Wolfgang Mauerer Signed-off-by: Jan Kiszka Reported-by: Victor Metsch --- ksrc/skins/native/queue.c |2 ++ ksrc/skins/native/syscall.c |6 ++ 2 files changed, 8 insertions(+), 0 deletions(-) diff --git a/ksrc/skins/native/queue.c b/ksrc/skins/native/queue.c index 963c029..527bde8 100644 --- a/ksrc/skins/native/queue.c +++ b/ksrc/skins/native/queue.c @@ -713,6 +713,8 @@ int rt_queue_send(RT_QUEUE *q, void *mbuf, size_t size, int mode) * defined for the queue at creation, or if no memory can be obtained * to convey the message data internally. * + * - -ESRCH is returned if a @a q represents a stale userland handle + * * Environments: * * This service can be called from: diff --git a/ksrc/skins/native/syscall.c b/ksrc/skins/native/syscall.c index 1e8ece9..28c720e 100644 --- a/ksrc/skins/native/syscall.c +++ b/ksrc/skins/native/syscall.c @@ -2270,6 +2270,9 @@ static int __rt_queue_write(struct pt_regs *regs) q = (RT_QUEUE *)xnregistry_fetch(ph.opaque); + if (!q) + return -ESRCH; + /* Buffer to write to the queue. */ buf = (void __user *)__xn_reg_arg2(regs); @@ -2385,6 +2388,9 @@ static int __rt_queue_read(struct pt_regs *regs) q = (RT_QUEUE *)xnregistry_fetch(ph.opaque); + if (!q) + return -ESRCH; + /* Address of message space to write to. */ buf = (void __user *)__xn_reg_arg2(regs); ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Wolfgang Mauerer : Fix handling of deleted message queue objects
Module: xenomai-abe Branch: analogy Commit: 167da0577e4be86bb46e21f2f164e0495d296a24 URL: http://git.xenomai.org/?p=xenomai-abe.git;a=commit;h=167da0577e4be86bb46e21f2f164e0495d296a24 Author: Wolfgang Mauerer Date: Fri Oct 2 10:49:27 2009 +0200 Fix handling of deleted message queue objects When a Xenomai thread tries to access a deleted message queue, it should obtain -ESRCH as error code both from within the kernel and for userland applications. However, userland sometimes receives wrong error codes because failure of the handle lookup operation is not correctly handled, which leads to subsequently different errors. This patch fixes the faulty patterns, and also provides a documentation update. Signed-off-by: Wolfgang Mauerer Signed-off-by: Jan Kiszka Reported-by: Victor Metsch --- ksrc/skins/native/queue.c |2 ++ ksrc/skins/native/syscall.c |6 ++ 2 files changed, 8 insertions(+), 0 deletions(-) diff --git a/ksrc/skins/native/queue.c b/ksrc/skins/native/queue.c index 963c029..527bde8 100644 --- a/ksrc/skins/native/queue.c +++ b/ksrc/skins/native/queue.c @@ -713,6 +713,8 @@ int rt_queue_send(RT_QUEUE *q, void *mbuf, size_t size, int mode) * defined for the queue at creation, or if no memory can be obtained * to convey the message data internally. * + * - -ESRCH is returned if a @a q represents a stale userland handle + * * Environments: * * This service can be called from: diff --git a/ksrc/skins/native/syscall.c b/ksrc/skins/native/syscall.c index 1e8ece9..28c720e 100644 --- a/ksrc/skins/native/syscall.c +++ b/ksrc/skins/native/syscall.c @@ -2270,6 +2270,9 @@ static int __rt_queue_write(struct pt_regs *regs) q = (RT_QUEUE *)xnregistry_fetch(ph.opaque); + if (!q) + return -ESRCH; + /* Buffer to write to the queue. */ buf = (void __user *)__xn_reg_arg2(regs); @@ -2385,6 +2388,9 @@ static int __rt_queue_read(struct pt_regs *regs) q = (RT_QUEUE *)xnregistry_fetch(ph.opaque); + if (!q) + return -ESRCH; + /* Address of message space to write to. */ buf = (void __user *)__xn_reg_arg2(regs); ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git
[Xenomai-git] Wolfgang Mauerer : Fix handling of deleted message queue objects
Module: xenomai-head Branch: master Commit: 167da0577e4be86bb46e21f2f164e0495d296a24 URL: http://git.xenomai.org/?p=xenomai-head.git;a=commit;h=167da0577e4be86bb46e21f2f164e0495d296a24 Author: Wolfgang Mauerer Date: Fri Oct 2 10:49:27 2009 +0200 Fix handling of deleted message queue objects When a Xenomai thread tries to access a deleted message queue, it should obtain -ESRCH as error code both from within the kernel and for userland applications. However, userland sometimes receives wrong error codes because failure of the handle lookup operation is not correctly handled, which leads to subsequently different errors. This patch fixes the faulty patterns, and also provides a documentation update. Signed-off-by: Wolfgang Mauerer Signed-off-by: Jan Kiszka Reported-by: Victor Metsch --- ksrc/skins/native/queue.c |2 ++ ksrc/skins/native/syscall.c |6 ++ 2 files changed, 8 insertions(+), 0 deletions(-) diff --git a/ksrc/skins/native/queue.c b/ksrc/skins/native/queue.c index 963c029..527bde8 100644 --- a/ksrc/skins/native/queue.c +++ b/ksrc/skins/native/queue.c @@ -713,6 +713,8 @@ int rt_queue_send(RT_QUEUE *q, void *mbuf, size_t size, int mode) * defined for the queue at creation, or if no memory can be obtained * to convey the message data internally. * + * - -ESRCH is returned if a @a q represents a stale userland handle + * * Environments: * * This service can be called from: diff --git a/ksrc/skins/native/syscall.c b/ksrc/skins/native/syscall.c index 1e8ece9..28c720e 100644 --- a/ksrc/skins/native/syscall.c +++ b/ksrc/skins/native/syscall.c @@ -2270,6 +2270,9 @@ static int __rt_queue_write(struct pt_regs *regs) q = (RT_QUEUE *)xnregistry_fetch(ph.opaque); + if (!q) + return -ESRCH; + /* Buffer to write to the queue. */ buf = (void __user *)__xn_reg_arg2(regs); @@ -2385,6 +2388,9 @@ static int __rt_queue_read(struct pt_regs *regs) q = (RT_QUEUE *)xnregistry_fetch(ph.opaque); + if (!q) + return -ESRCH; + /* Address of message space to write to. */ buf = (void __user *)__xn_reg_arg2(regs); ___ Xenomai-git mailing list Xenomai-git@gna.org https://mail.gna.org/listinfo/xenomai-git