From patchwork Fri Jun 26 14:49:30 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= X-Patchwork-Id: 488896 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 1B55C140187 for ; Sat, 27 Jun 2015 01:19:22 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=LCOitP3P; dkim-atps=neutral Received: from localhost ([::1]:60676 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z8VPT-0003uL-U7 for incoming@patchwork.ozlabs.org; Fri, 26 Jun 2015 11:19:19 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57387) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z8UyB-0005Hw-04 for qemu-devel@nongnu.org; Fri, 26 Jun 2015 10:51:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z8Uy8-0002Pb-CJ for qemu-devel@nongnu.org; Fri, 26 Jun 2015 10:51:06 -0400 Received: from mail-qk0-x236.google.com ([2607:f8b0:400d:c09::236]:35800) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z8Uy8-0002PF-81 for qemu-devel@nongnu.org; Fri, 26 Jun 2015 10:51:04 -0400 Received: by qkbp125 with SMTP id p125so56293351qkb.2 for ; Fri, 26 Jun 2015 07:51:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; bh=HuWQLij6yATXPkSJJp1O2gJcLfUDx0o7kEfVbmC46D0=; b=LCOitP3Pk3JurzVzo/OZOvTMIxOTV1vPGfy26c8qCVduT2ciFF6B+F5ovEUJnjgTjC 54AZ3o3MLQsZ97pYRMG3GWXjLl39WkyF78v+8cdeotNTvj/9zuNOYija8lXATKFGx5I8 li4v4R4ecmtgBcdjG0q5tWbj6r1k8p1LQLP1tp6dvRjbSGaZUoVtcGLcafRCHzzpBZ02 g/yWPx/qaCOzdnGlsYuGtwoTz+Z/aSB9aQW2Rki3Za0a7DHDEMV1YT4+R0/c9yTR5Yt1 666e7ys7jkhNGhd4NdzcNf2xck9CErqSOFaX0z+BXnN6jH2DpEu3RDNzO3ku2YUIRTb1 ASfA== X-Received: by 10.140.144.131 with SMTP id 125mr2841029qhq.75.1435330263904; Fri, 26 Jun 2015 07:51:03 -0700 (PDT) Received: from localhost (bne75-h02-31-39-163-232.dsl.sta.abo.bbox.fr. [31.39.163.232]) by mx.google.com with ESMTPSA id x79sm5870628qha.10.2015.06.26.07.51.02 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 26 Jun 2015 07:51:03 -0700 (PDT) From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Fri, 26 Jun 2015 16:49:30 +0200 Message-Id: <1435330185-23248-25-git-send-email-marcandre.lureau@gmail.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1435330185-23248-1-git-send-email-marcandre.lureau@gmail.com> References: <1435330185-23248-1-git-send-email-marcandre.lureau@gmail.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:400d:c09::236 Cc: cam@cs.ualberta.ca, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , stefanha@redhat.com Subject: [Qemu-devel] [PATCH 24/39] ivshmem: check shm isn't already initialized 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 The server should not be allowed to change the shm, this isn't handled by qemu (perhaps it could be though). Signed-off-by: Marc-André Lureau --- hw/misc/ivshmem.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/hw/misc/ivshmem.c b/hw/misc/ivshmem.c index 9085f7c..b8167d9 100644 --- a/hw/misc/ivshmem.c +++ b/hw/misc/ivshmem.c @@ -534,6 +534,12 @@ static void ivshmem_read(void *opaque, const uint8_t *buf, int size) if (incoming_posn == -1) { void * map_ptr; + if (s->shm_fd >= 0) { + error_report("shm already initialized"); + close(incoming_fd); + return; + } + if (check_shm_size(s, incoming_fd, &err) == -1) { error_report_err(err); close(incoming_fd);