From: Akira Takeuchi <takeuchi.akr@jp.panasonic.com>
To: linux-kernel@vger.kernel.org
Cc: torvalds@linux-foundation.org
Subject: [REGRESSION][PATCH] mqueue: Ignore the validity of abs_timeout parameter when message can be performed immediately
Date: Fri, 02 Mar 2012 16:42:35 +0900 [thread overview]
Message-ID: <20120302164234.4938.38390934@jp.panasonic.com> (raw)
This patch fixes up the regression problem of mq_timed{send,receive} syscall.
When a message of mqueue can be performed immediately,
the validity of abs_timeout parameter should not be checked.
According to the manpage of mq_timedreceive:
Under no circumstance shall the operation fail with a timeout
if a message can be removed from the message queue immediately.
The validity of the abstime parameter need not be checked
if a message can be removed from the message queue immediately.
On 2.6.35+ kernel, mq_timed{send,receive} returns EINVAL incorrectly,
in this situation.
I found this problem during the OPTS testcase
"conformance/interfaces/mq_timedreceive/10-2":
# ./10-2.test
FAIL: the validity of abs_timeout is checked
Test FAILED
Signed-off-by: Akira Takeuchi <takeuchi.akr@jp.panasonic.com>
Signed-off-by: Kiyoshi Owada <owada.kiyoshi@jp.panasonic.com>
---
ipc/mqueue.c | 31 +++++++++++++++++++++++++++----
1 files changed, 27 insertions(+), 4 deletions(-)
diff --git a/ipc/mqueue.c b/ipc/mqueue.c
index 86ee272..7cd4411 100644
--- a/ipc/mqueue.c
+++ b/ipc/mqueue.c
@@ -861,14 +861,22 @@ SYSCALL_DEFINE5(mq_timedsend, mqd_t, mqdes, const char __user *, u_msg_ptr,
struct msg_msg *msg_ptr;
struct mqueue_inode_info *info;
ktime_t expires, *timeout = NULL;
+ int timeout_param_error = 0;
struct timespec ts;
int ret;
if (u_abs_timeout) {
int res = prepare_timeout(u_abs_timeout, &expires, &ts);
if (res)
- return res;
- timeout = &expires;
+ /*
+ * The validity of the abs_timeout parameter need not be
+ * checked when there is sufficient room in the queue.
+ * So, do not return here, even if the parameter is
+ * invalid.
+ */
+ timeout_param_error = res;
+ else
+ timeout = &expires;
}
if (unlikely(msg_prio >= (unsigned long) MQ_PRIO_MAX))
@@ -916,6 +924,9 @@ SYSCALL_DEFINE5(mq_timedsend, mqd_t, mqdes, const char __user *, u_msg_ptr,
if (filp->f_flags & O_NONBLOCK) {
spin_unlock(&info->lock);
ret = -EAGAIN;
+ } else if (unlikely(timeout_param_error)) {
+ spin_unlock(&info->lock);
+ ret = timeout_param_error;
} else {
wait.task = current;
wait.msg = (void *) msg_ptr;
@@ -955,13 +966,21 @@ SYSCALL_DEFINE5(mq_timedreceive, mqd_t, mqdes, char __user *, u_msg_ptr,
struct mqueue_inode_info *info;
struct ext_wait_queue wait;
ktime_t expires, *timeout = NULL;
+ int timeout_param_error = 0;
struct timespec ts;
if (u_abs_timeout) {
int res = prepare_timeout(u_abs_timeout, &expires, &ts);
if (res)
- return res;
- timeout = &expires;
+ /*
+ * The validity of the abs_timeout parameter need not be
+ * checked if a message can be removed from the message
+ * queue immediately. So, do not return here, even if
+ * the parameter is invalid.
+ */
+ timeout_param_error = res;
+ else
+ timeout = &expires;
}
audit_mq_sendrecv(mqdes, msg_len, 0, timeout ? &ts : NULL);
@@ -996,6 +1015,10 @@ SYSCALL_DEFINE5(mq_timedreceive, mqd_t, mqdes, char __user *, u_msg_ptr,
if (filp->f_flags & O_NONBLOCK) {
spin_unlock(&info->lock);
ret = -EAGAIN;
+ } else if (unlikely(timeout_param_error)) {
+ spin_unlock(&info->lock);
+ ret = timeout_param_error;
+ msg_ptr = NULL; /* just for shutting up warning */
} else {
wait.task = current;
wait.state = STATE_NONE;
--
1.7.4.1
next reply other threads:[~2012-03-02 7:56 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-02 7:42 Akira Takeuchi [this message]
2012-03-14 21:46 ` Andrew Morton
2012-03-14 22:08 ` Thomas Gleixner
2012-03-15 0:28 ` Thomas Gleixner
2012-03-15 3:48 ` Linus Torvalds
2012-03-15 11:02 ` Thomas Gleixner
2012-03-16 5:11 ` Akira Takeuchi
2012-03-23 0:03 ` Akira Takeuchi
2012-03-23 9:01 ` Thomas Gleixner
2012-03-14 23:02 ` Thomas Gleixner
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=20120302164234.4938.38390934@jp.panasonic.com \
--to=takeuchi.akr@jp.panasonic.com \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@linux-foundation.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®