From patchwork Tue Sep 27 04:44:10 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Qiang X-Patchwork-Id: 9351485 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 78AB56077A for ; Tue, 27 Sep 2016 04:44:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6B93D28F3F for ; Tue, 27 Sep 2016 04:44:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5F97628F4B; Tue, 27 Sep 2016 04:44:48 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C4FD628F3F for ; Tue, 27 Sep 2016 04:44:47 +0000 (UTC) Received: from localhost ([::1]:47986 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bokG6-0003xE-EI for patchwork-qemu-devel@patchwork.kernel.org; Tue, 27 Sep 2016 00:44:46 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40305) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bokFj-0003vQ-55 for qemu-devel@nongnu.org; Tue, 27 Sep 2016 00:44:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bokFh-0007r0-9i for qemu-devel@nongnu.org; Tue, 27 Sep 2016 00:44:22 -0400 Received: from mail-oi0-x244.google.com ([2607:f8b0:4003:c06::244]:34376) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bokFh-0007ql-2p for qemu-devel@nongnu.org; Tue, 27 Sep 2016 00:44:21 -0400 Received: by mail-oi0-x244.google.com with SMTP id a62so170373oib.1 for ; Mon, 26 Sep 2016 21:44:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:from:to:cc:subject:date; bh=Byw4eVSC47K03S0Vmss+RFrapV9H6Jf5XGY088q3Poc=; b=LkMdg4e2kMry2KC3q7P91q4TeozB2uvYK0jK4qgsFiCVFTWWLUOsKr1uMI+YUPs7IH X+NWBTSMQWbuvUs5e6dBg8Iiz8kBvaMMvJ9aEEdfPQPwn2b08MHbNJUQsGp2JlS1nzGj hNZlXBJsDl3Wy7VdLNwmLBgkEbIHB3l9TM1rIyqxxy43Ycs57z4DbAMhej33Z3jAbY63 OU1YpSSP41xnRnX0NAl3+jv0qHUUhTJUut+ozGkMPBDTl5JS7k/R5+FZ2fFG/CS0mH+e 3bvJqoprQI7kax6nlIHuWjcBqsrxgplD3NhxU/kucOO/TVrDJgRk58kzBzQ7wLpUtJV/ hMWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:from:to:cc:subject:date; bh=Byw4eVSC47K03S0Vmss+RFrapV9H6Jf5XGY088q3Poc=; b=KrsIOmunaLAnT7wL4P6IbyA2D9Nx+LcVddTwEh1/3qP7JIFFBHhy+6MpVWQ3N4pwrd WwDaX3B9ukuG7vD+UAA18xrNzEdrxePaDGrOa5ReEaWaFCxzDShfOZcj5m6WUFJizOIJ pg6QepEO/DcPB5icqbC+WBhKOT6xiFHR5dZJ6b04w8XpFcogzDDpoXr0FPAtIq6mxPEJ cZSssSYogmcxrRdfPTnrFC1kPsppEpXLnIH4ahBalbiT+nkVi+nHFBkiMqi64QjYPnLr +e8ypV8Hd0LaM1euyak4KJbacoM3yIkh2qif77fbBM7q3h6kdCWkPBhJAk8Tvsggc/5A IOyg== X-Gm-Message-State: AE9vXwO45kFIsCtygA80mt7EkbVm0bWr0OYtPiXri9USP7Sid5YI4tBmUpuzSmT+diNvSA== X-Received: by 10.202.77.69 with SMTP id a66mr32994207oib.0.1474951460348; Mon, 26 Sep 2016 21:44:20 -0700 (PDT) Received: from localhost.localdomain.localdomain ([104.192.110.250]) by smtp.gmail.com with ESMTPSA id v5sm176771oie.8.2016.09.26.21.44.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 26 Sep 2016 21:44:19 -0700 (PDT) Message-ID: <57e9f923.05acca0a.3dec3.0ccc@mx.google.com> X-Google-Original-Message-ID: <1474951450-16222-1-git-send-email-Qiang(liqiang6-s@360.cn)> From: Li Qiang X-Google-Original-From: Li Qiang(liqiang6-s@360.cn) To: aneesh.kumar@linux.vnet.ibm.com, groug@kaod.org, qemu-devel@nongnu.org Date: Mon, 26 Sep 2016 21:44:10 -0700 X-Mailer: git-send-email 1.8.3.1 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:4003:c06::244 Subject: [Qemu-devel] [PATCH] 9pfs: fix information leak in xattr read X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Li Qiang Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Li Qiang 9pfs uses g_malloc() to allocate the xattr memory space, if the guest reads this memory before writing to it, this will leak host heap memory to the guest. This patch avoid this. Signed-off-by: Li Qiang --- hw/9pfs/9p.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c index b1ff8e7..4db1bd8 100644 --- a/hw/9pfs/9p.c +++ b/hw/9pfs/9p.c @@ -3291,7 +3291,7 @@ static void v9fs_xattrcreate(void *opaque) xattr_fidp->fs.xattr.flags = flags; v9fs_string_init(&xattr_fidp->fs.xattr.name); v9fs_string_copy(&xattr_fidp->fs.xattr.name, &name); - xattr_fidp->fs.xattr.value = g_malloc(size); + xattr_fidp->fs.xattr.value = g_malloc0(size); err = offset; put_fid(pdu, file_fidp); out_nofid: