From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:41583) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TEfuM-0000He-59 for qemu-devel@nongnu.org; Thu, 20 Sep 2012 08:31:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TEfuJ-0004wU-Sb for qemu-devel@nongnu.org; Thu, 20 Sep 2012 08:31:06 -0400 Received: from cantor2.suse.de ([195.135.220.15]:53631 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TEfuJ-0004wL-Md for qemu-devel@nongnu.org; Thu, 20 Sep 2012 08:31:03 -0400 From: Alexander Graf Date: Wed, 19 Sep 2012 04:39:53 +0200 Message-Id: <1348022393-11312-1-git-send-email-agraf@suse.de> Subject: [Qemu-devel] [PATCH] linux-user: fix statfs List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel qemu-devel Cc: Peter Maydell , riku.voipio@linaro.org 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 --- v1 -> v2: - use memset(0, sizeof(arr)) as suggested by peter maydell --- linux-user/syscall.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 6257a04..0dc1efc 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -6531,6 +6531,8 @@ 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); + memset(target_stfs->f_spare, 0, sizeof(target_stfs->f_spare)); unlock_user_struct(target_stfs, arg2, 1); } break; @@ -6559,6 +6561,8 @@ 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); + memset(target_stfs->f_spare, 0, sizeof(target_stfs->f_spare)); unlock_user_struct(target_stfs, arg3, 1); } break; -- 1.6.0.2