From patchwork Thu Jan 28 15:15:25 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prasad Pandit X-Patchwork-Id: 8151411 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 423DFBEEE5 for ; Thu, 28 Jan 2016 15:15:52 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AFD3720304 for ; Thu, 28 Jan 2016 15:15:51 +0000 (UTC) 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.kernel.org (Postfix) with ESMTPS id 050712013D for ; Thu, 28 Jan 2016 15:15:46 +0000 (UTC) Received: from localhost ([::1]:57201 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aOoIT-0003dX-2g for patchwork-qemu-devel@patchwork.kernel.org; Thu, 28 Jan 2016 10:15:45 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42161) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aOoIL-0003dK-M0 for qemu-devel@nongnu.org; Thu, 28 Jan 2016 10:15:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aOoIH-0006if-Bn for qemu-devel@nongnu.org; Thu, 28 Jan 2016 10:15:37 -0500 Received: from mx1.redhat.com ([209.132.183.28]:58416) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aOoIH-0006ia-69 for qemu-devel@nongnu.org; Thu, 28 Jan 2016 10:15:33 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 30564C001268; Thu, 28 Jan 2016 15:15:32 +0000 (UTC) Received: from javelin.localdomain (vpn1-7-33.sin2.redhat.com [10.67.7.33]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u0SFFQca017133 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 28 Jan 2016 10:15:29 -0500 From: P J P To: QEMU Developers Date: Thu, 28 Jan 2016 20:45:25 +0530 Message-Id: <1453994125-23586-1-git-send-email-ppandit@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Paolo Bonzini , John Snow , Prasad J Pandit , Zuozhi fzz Subject: [Qemu-devel] [PATCH] exec: check 'bounce.in_use' flag before using buffer 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Prasad J Pandit When IDE AHCI emulation uses Frame Information Structures(FIS) engine for data transfer, the mapped FIS buffer address is stored in a static 'bounce.buffer'. This is freed when FIS entry is unmapped. If multiple FIS entries are created, it leads to an use after free error. Check 'bounce.in_use' flag to avoid it. Reported-by: Zuozhi fzz Signed-off-by: Prasad J Pandit --- exec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exec.c b/exec.c index 8718a75..ccc5715 100644 --- a/exec.c +++ b/exec.c @@ -2922,7 +2922,7 @@ void address_space_unmap(AddressSpace *as, void *buffer, hwaddr len, memory_region_unref(mr); return; } - if (is_write) { + if (bounce.in_use && is_write) { address_space_write(as, bounce.addr, MEMTXATTRS_UNSPECIFIED, bounce.buffer, access_len); }