From patchwork Thu Oct 18 11:30:57 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Riku Voipio X-Patchwork-Id: 192311 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 89E1C2C008D for ; Thu, 18 Oct 2012 23:19:51 +1100 (EST) Received: from localhost ([::1]:42542 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TOoKP-0001cl-Kn for incoming@patchwork.ozlabs.org; Thu, 18 Oct 2012 07:31:53 -0400 Received: from eggs.gnu.org ([208.118.235.92]:45900) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TOoJm-0008Mo-JS for qemu-devel@nongnu.org; Thu, 18 Oct 2012 07:31:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TOoJi-0005VV-Kq for qemu-devel@nongnu.org; Thu, 18 Oct 2012 07:31:14 -0400 Received: from afflict.kos.to ([92.243.29.197]:57387) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TOoJi-0005V1-Db for qemu-devel@nongnu.org; Thu, 18 Oct 2012 07:31:10 -0400 Received: by afflict.kos.to (Postfix, from userid 1000) id D8E9C264C1; Thu, 18 Oct 2012 13:31:07 +0200 (CEST) From: riku.voipio@linaro.org To: qemu-devel@nongnu.org Date: Thu, 18 Oct 2012 14:30:57 +0300 Message-Id: <229d3376a38bf97aa09b6f73a957c5389badcd06.1350559608.git.riku.voipio@linaro.org> X-Mailer: git-send-email 1.7.2.5 In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 92.243.29.197 Cc: Alexander Graf Subject: [Qemu-devel] [PATCH 01/11] 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 From: Alexander Graf 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 Signed-off-by: Riku Voipio --- linux-user/syscall.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 471d060..1a38169 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -6529,6 +6529,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; @@ -6557,6 +6559,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;