From patchwork Mon Jan 11 19:33:50 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Snow X-Patchwork-Id: 566086 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 62DE81402C9 for ; Tue, 12 Jan 2016 06:36:24 +1100 (AEDT) Received: from localhost ([::1]:56519 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aIiGM-00086w-8U for incoming@patchwork.ozlabs.org; Mon, 11 Jan 2016 14:36:22 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38497) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aIiEC-0003lA-Cm for qemu-devel@nongnu.org; Mon, 11 Jan 2016 14:34:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aIiE8-0004hQ-Gt for qemu-devel@nongnu.org; Mon, 11 Jan 2016 14:34:08 -0500 Received: from mx1.redhat.com ([209.132.183.28]:39855) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aIiE8-0004hJ-BR for qemu-devel@nongnu.org; Mon, 11 Jan 2016 14:34:04 -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 03ECE8E694; Mon, 11 Jan 2016 19:34:03 +0000 (UTC) Received: from scv.usersys.redhat.com (dhcp-17-163.bos.redhat.com [10.18.17.163]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u0BJY1sj000629; Mon, 11 Jan 2016 14:34:02 -0500 From: John Snow To: qemu-devel@nongnu.org Date: Mon, 11 Jan 2016 14:33:50 -0500 Message-Id: <1452540840-23433-2-git-send-email-jsnow@redhat.com> In-Reply-To: <1452540840-23433-1-git-send-email-jsnow@redhat.com> References: <1452540840-23433-1-git-send-email-jsnow@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: peter.maydell@linaro.org, Mark Cave-Ayland , jsnow@redhat.com Subject: [Qemu-devel] [PULL v2 01/11] macio: fix overflow in lba to offset conversion for ATAPI devices 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: Mark Cave-Ayland As the IDEState lba field is an int32_t, make sure we cast to int64_t before shifting to calculate the offset. Otherwise we end up with an overflow when trying to access sectors beyond 2GB as can occur when using DVD images. [Maintainer edit: fixed extraneous parentheses. --js] Signed-off-by: Mark Cave-Ayland Reviewed-by: John Snow Message-id: 1451928613-29476-1-git-send-email-mark.cave-ayland@ilande.co.uk Signed-off-by: John Snow --- hw/ide/macio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/ide/macio.c b/hw/ide/macio.c index 9771261..d4031b6 100644 --- a/hw/ide/macio.c +++ b/hw/ide/macio.c @@ -280,7 +280,7 @@ static void pmac_ide_atapi_transfer_cb(void *opaque, int ret) } /* Calculate current offset */ - offset = (int64_t)(s->lba << 11) + s->io_buffer_index; + offset = ((int64_t)s->lba << 11) + s->io_buffer_index; pmac_dma_read(s->blk, offset, io->len, pmac_ide_atapi_transfer_cb, io); return;