From patchwork Tue Mar 8 07:00:45 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 8530041 Return-Path: X-Original-To: patchwork-qemu-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 8928B9F372 for ; Tue, 8 Mar 2016 07:03:07 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EFDFB2017D for ; Tue, 8 Mar 2016 07:03:06 +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 4CC3E2015E for ; Tue, 8 Mar 2016 07:03:06 +0000 (UTC) Received: from localhost ([::1]:60754 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1adBfd-0005cc-OB for patchwork-qemu-devel@patchwork.kernel.org; Tue, 08 Mar 2016 02:03:05 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52734) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1adBeM-0003J7-UB for qemu-devel@nongnu.org; Tue, 08 Mar 2016 02:01:47 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1adBeM-0006YQ-6H for qemu-devel@nongnu.org; Tue, 08 Mar 2016 02:01:46 -0500 Received: from mx1.redhat.com ([209.132.183.28]:57395) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1adBeM-0006YL-1y for qemu-devel@nongnu.org; Tue, 08 Mar 2016 02:01:46 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id A3C9529AFE for ; Tue, 8 Mar 2016 07:01:45 +0000 (UTC) Received: from pxdev.xzpeter.org.com (vpn1-5-232.pek2.redhat.com [10.72.5.232]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u2870qvR019713; Tue, 8 Mar 2016 02:01:41 -0500 From: Peter Xu To: qemu-devel@nongnu.org Date: Tue, 8 Mar 2016 15:00:45 +0800 Message-Id: <1457420446-25276-8-git-send-email-peterx@redhat.com> In-Reply-To: <1457420446-25276-1-git-send-email-peterx@redhat.com> References: <1457420446-25276-1-git-send-email-peterx@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Amit Shah , pbonzini@redhat.com, peterx@redhat.com, Juan Quintela Subject: [Qemu-devel] [PATCH 7/8] migration: fix unbounded stack for source_return_path_thread 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 Suggested-by: Paolo Bonzini CC: Juan Quintela CC: Amit Shah Signed-off-by: Peter Xu Reviewed-by: Juan Quintela --- migration/migration.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 0129d9f..f1a3976 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -1265,11 +1265,11 @@ static void migrate_handle_rp_req_pages(MigrationState *ms, const char* rbname, */ static void *source_return_path_thread(void *opaque) { +#define __MAX_LEN (512) MigrationState *ms = opaque; QEMUFile *rp = ms->rp_state.from_dst_file; uint16_t header_len, header_type; - const int max_len = 512; - uint8_t buf[max_len]; + uint8_t buf[__MAX_LEN]; uint32_t tmp32, sibling_error; ram_addr_t start = 0; /* =0 to silence warning */ size_t len = 0, expected_len; @@ -1292,7 +1292,7 @@ static void *source_return_path_thread(void *opaque) if ((rp_cmd_args[header_type].len != -1 && header_len != rp_cmd_args[header_type].len) || - header_len > max_len) { + header_len > __MAX_LEN) { error_report("RP: Received '%s' message (0x%04x) with" "incorrect length %d expecting %zu", rp_cmd_args[header_type].name, header_type, header_len, @@ -1372,6 +1372,7 @@ out: ms->rp_state.from_dst_file = NULL; qemu_fclose(rp); return NULL; +#undef __MAX_LEN } static int open_return_path_on_source(MigrationState *ms)