qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Alexander Graf <agraf@suse.de>
To: qemu-devel qemu-devel <qemu-devel@nongnu.org>
Cc: riku.voipio@linaro.org
Subject: [Qemu-devel] [PATCH 3/3] linux-user: fix statfs
Date: Tue, 21 Aug 2012 14:43:32 +0200	[thread overview]
Message-ID: <1345553012-19842-4-git-send-email-agraf@suse.de> (raw)
In-Reply-To: <1345553012-19842-1-git-send-email-agraf@suse.de>

The statfs syscall should always memset(0) its full struct extent before
writing to it. Newer versions of the syscall use one of the reserved fields
for flags, which would otherwise get stale values from uncleaned memory.

This fixes libarchive for me, which got confused about the return value of
pathconf("/", _PC_REC_XFER_ALIGN) otherwise, as it some times gave old pointers
as return value.

Signed-off-by: Alexander Graf <agraf@suse.de>
---
 linux-user/syscall.c |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index d19efb8..61f5718 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -6667,6 +6667,12 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
             __put_user(stfs.f_fsid.__val[0], &target_stfs->f_fsid.val[0]);
             __put_user(stfs.f_fsid.__val[1], &target_stfs->f_fsid.val[1]);
             __put_user(stfs.f_namelen, &target_stfs->f_namelen);
+            __put_user(stfs.f_frsize, &target_stfs->f_frsize);
+            __put_user(0, &target_stfs->f_spare[0]);
+            __put_user(0, &target_stfs->f_spare[1]);
+            __put_user(0, &target_stfs->f_spare[2]);
+            __put_user(0, &target_stfs->f_spare[3]);
+            __put_user(0, &target_stfs->f_spare[4]);
             unlock_user_struct(target_stfs, arg2, 1);
         }
         break;
@@ -6695,6 +6701,12 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
             __put_user(stfs.f_fsid.__val[0], &target_stfs->f_fsid.val[0]);
             __put_user(stfs.f_fsid.__val[1], &target_stfs->f_fsid.val[1]);
             __put_user(stfs.f_namelen, &target_stfs->f_namelen);
+            __put_user(stfs.f_frsize, &target_stfs->f_frsize);
+            __put_user(0, &target_stfs->f_spare[0]);
+            __put_user(0, &target_stfs->f_spare[1]);
+            __put_user(0, &target_stfs->f_spare[2]);
+            __put_user(0, &target_stfs->f_spare[3]);
+            __put_user(0, &target_stfs->f_spare[4]);
             unlock_user_struct(target_stfs, arg3, 1);
         }
         break;
-- 
1.6.0.2

  parent reply	other threads:[~2012-08-21 12:49 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-21 12:43 [Qemu-devel] [PATCH 0/3] linux-user: Assorted fixed for libarchive Alexander Graf
2012-08-21 12:43 ` [Qemu-devel] [PATCH 1/3] linux-user: implement FS_IOC_GETFLAGS ioctl Alexander Graf
2012-08-21 13:47   ` Peter Maydell
2012-10-11 13:36     ` Riku Voipio
2012-10-11 13:52       ` Alexander Graf
2012-08-21 12:43 ` [Qemu-devel] [PATCH 2/3] linux-user: implement FS_IOC_SETFLAGS ioctl Alexander Graf
2012-08-21 12:43 ` Alexander Graf [this message]
2012-08-21 14:00   ` [Qemu-devel] [PATCH 3/3] linux-user: fix statfs 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=1345553012-19842-4-git-send-email-agraf@suse.de \
    --to=agraf@suse.de \
    --cc=qemu-devel@nongnu.org \
    --cc=riku.voipio@linaro.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;
as well as URLs for NNTP newsgroup(s).