From patchwork Tue Aug 21 12:43:32 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 179057 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 97A2A2C00BB for ; Tue, 21 Aug 2012 22:49:35 +1000 (EST) Received: from localhost ([::1]:55677 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T3ntl-000843-9s for incoming@patchwork.ozlabs.org; Tue, 21 Aug 2012 08:49:33 -0400 Received: from eggs.gnu.org ([208.118.235.92]:33652) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T3nta-00083o-Cx for qemu-devel@nongnu.org; Tue, 21 Aug 2012 08:49:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1T3ntW-0005v0-M8 for qemu-devel@nongnu.org; Tue, 21 Aug 2012 08:49:22 -0400 Received: from cantor2.suse.de ([195.135.220.15]:43435 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T3ntW-0005ui-D5 for qemu-devel@nongnu.org; Tue, 21 Aug 2012 08:49:18 -0400 Received: from relay1.suse.de (unknown [195.135.220.254]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx2.suse.de (Postfix) with ESMTP id D305AA329E; Tue, 21 Aug 2012 14:49:17 +0200 (CEST) From: Alexander Graf To: qemu-devel qemu-devel Date: Tue, 21 Aug 2012 14:43:32 +0200 Message-Id: <1345553012-19842-4-git-send-email-agraf@suse.de> X-Mailer: git-send-email 1.6.0.2 In-Reply-To: <1345553012-19842-1-git-send-email-agraf@suse.de> References: <1345553012-19842-1-git-send-email-agraf@suse.de> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4-2.6 X-Received-From: 195.135.220.15 Cc: riku.voipio@linaro.org Subject: [Qemu-devel] [PATCH 3/3] linux-user: fix statfs X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.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 --- 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;