From: Max Filippov <jcmvbkbc@gmail.com>
To: qemu-devel@nongnu.org
Cc: Max Filippov <jcmvbkbc@gmail.com>,
Lionel Landwerlin <lionel.landwerlin@openwide.fr>,
"Kirill A . Shutemov" <kirill.shutemov@linux.intel.com>,
Riku Voipio <riku.voipio@iki.fi>,
Aurelien Jarno <aurelien@aurel32.net>,
Laurent Vivier <laurent@vivier.eu>
Subject: [Qemu-devel] [PATCH] linux-user: fix mq_getsetattr implementation
Date: Sat, 31 Mar 2018 09:23:36 -0700 [thread overview]
Message-ID: <20180331162336.20158-1-jcmvbkbc@gmail.com> (raw)
mq_getsetattr implementation does not set errno correctly in case of
error. Also in the presence of both 2nd and 3rd arguments it calls both
mq_getattr and mq_setattr, whereas only the latter call would suffice.
Don't call mq_getattr in the presence of the 3rd argument. Use get_errno
to set errno value.
This fixes test rt/tst-mqueue2 from the glibc testsuite.
Cc: Lionel Landwerlin <lionel.landwerlin@openwide.fr>
Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Cc: Riku Voipio <riku.voipio@iki.fi>
Cc: Aurelien Jarno <aurelien@aurel32.net>
Cc: Laurent Vivier <laurent@vivier.eu>
Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
---
linux-user/syscall.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 18ea79140f16..8b364551c311 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -12092,15 +12092,16 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
{
struct mq_attr posix_mq_attr_in, posix_mq_attr_out;
ret = 0;
- if (arg3 != 0) {
- ret = mq_getattr(arg1, &posix_mq_attr_out);
- copy_to_user_mq_attr(arg3, &posix_mq_attr_out);
- }
if (arg2 != 0) {
copy_from_user_mq_attr(&posix_mq_attr_in, arg2);
- ret |= mq_setattr(arg1, &posix_mq_attr_in, &posix_mq_attr_out);
+ ret = mq_setattr(arg1, &posix_mq_attr_in, &posix_mq_attr_out);
+ } else if (arg3 != 0) {
+ ret = mq_getattr(arg1, &posix_mq_attr_out);
}
-
+ if (arg3 != 0) {
+ copy_to_user_mq_attr(arg3, &posix_mq_attr_out);
+ }
+ ret = get_errno(ret);
}
break;
#endif
--
2.11.0
next reply other threads:[~2018-03-31 16:24 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-31 16:23 Max Filippov [this message]
2018-03-31 16:57 ` [Qemu-devel] [PATCH] linux-user: fix mq_getsetattr implementation Laurent Vivier
2018-03-31 17:03 ` Laurent Vivier
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=20180331162336.20158-1-jcmvbkbc@gmail.com \
--to=jcmvbkbc@gmail.com \
--cc=aurelien@aurel32.net \
--cc=kirill.shutemov@linux.intel.com \
--cc=laurent@vivier.eu \
--cc=lionel.landwerlin@openwide.fr \
--cc=qemu-devel@nongnu.org \
--cc=riku.voipio@iki.fi \
/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.