From: Peter Maydell <peter.maydell@linaro.org>
To: qemu-devel@nongnu.org
Cc: Riku Voipio <riku.voipio@iki.fi>, patches@linaro.org
Subject: [Qemu-devel] [PATCH 1/3] linux-user: Allow NULL value pointer in setxattr and getxattr
Date: Wed, 14 Dec 2011 15:37:17 +0000 [thread overview]
Message-ID: <1323877039-19891-2-git-send-email-peter.maydell@linaro.org> (raw)
In-Reply-To: <1323877039-19891-1-git-send-email-peter.maydell@linaro.org>
It's valid to pass a NULL value pointer to setxattr, so don't
fail this case EFAULT.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
linux-user/syscall.c | 24 ++++++++++++++++++------
1 files changed, 18 insertions(+), 6 deletions(-)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index f227097..ca4503d 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -7655,11 +7655,17 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
break;
case TARGET_NR_setxattr:
{
- void *p, *n, *v;
+ void *p, *n, *v = 0;
+ if (arg3) {
+ v = lock_user(VERIFY_READ, arg3, arg4, 1);
+ if (!v) {
+ ret = -TARGET_EFAULT;
+ break;
+ }
+ }
p = lock_user_string(arg1);
n = lock_user_string(arg2);
- v = lock_user(VERIFY_READ, arg3, arg4, 1);
- if (p && n && v) {
+ if (p && n) {
ret = get_errno(setxattr(p, n, v, arg4, arg5));
} else {
ret = -TARGET_EFAULT;
@@ -7671,11 +7677,17 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
break;
case TARGET_NR_getxattr:
{
- void *p, *n, *v;
+ void *p, *n, *v = 0;
+ if (arg3) {
+ v = lock_user(VERIFY_WRITE, arg3, arg4, 0);
+ if (!v) {
+ ret = -TARGET_EFAULT;
+ break;
+ }
+ }
p = lock_user_string(arg1);
n = lock_user_string(arg2);
- v = lock_user(VERIFY_WRITE, arg3, arg4, 0);
- if (p && n && v) {
+ if (p && n) {
ret = get_errno(getxattr(p, n, v, arg4));
} else {
ret = -TARGET_EFAULT;
--
1.7.5.4
next prev parent reply other threads:[~2011-12-14 15:37 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-14 15:37 [Qemu-devel] [PATCH 0/3] linux-user: Implement missing *xattr calls Peter Maydell
2011-12-14 15:37 ` Peter Maydell [this message]
2011-12-14 15:37 ` [Qemu-devel] [PATCH 2/3] linux-user/syscall.c: Implement f and l versions of set/get/removexattr Peter Maydell
2011-12-14 15:37 ` [Qemu-devel] [PATCH 3/3] linux-user: Implement *listxattr syscalls Peter Maydell
2012-01-04 11:39 ` [Qemu-devel] [PATCH 0/3] linux-user: Implement missing *xattr calls Peter Maydell
2012-01-27 14:32 ` Peter Maydell
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=1323877039-19891-2-git-send-email-peter.maydell@linaro.org \
--to=peter.maydell@linaro.org \
--cc=patches@linaro.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).