From patchwork Fri Jan 29 14:43:06 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Auger X-Patchwork-Id: 8163951 Return-Path: X-Original-To: patchwork-linux-arm@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 0E77A9F440 for ; Fri, 29 Jan 2016 14:45:27 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2D18C20382 for ; Fri, 29 Jan 2016 14:45:26 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6613C20265 for ; Fri, 29 Jan 2016 14:45:24 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1aPAH3-0005vZ-2k; Fri, 29 Jan 2016 14:43:45 +0000 Received: from mail-wm0-x22d.google.com ([2a00:1450:400c:c09::22d]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aPAGy-0005sq-Ps for linux-arm-kernel@lists.infradead.org; Fri, 29 Jan 2016 14:43:41 +0000 Received: by mail-wm0-x22d.google.com with SMTP id l66so57427751wml.0 for ; Fri, 29 Jan 2016 06:43:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=ob+jrNycMVEDd3LzzOaV0xJyeHg/ctn18pQ8ayR/b/k=; b=eH8me5sLQEsgjYyAWHMnY/ZYmDt4D2Wb7IWaqRgfhp6Ch9I0A17wDzz0PXNZmAEVEr TZXkyuTiWl/1nIQGmvyyvLaypBj4ZOzZaLCYI1IXn6nVJyQiyElubI+eFS6W91cN6itL V4DZOon/V9Rb2HM7gLj97/KkY55I+QEVPDLak= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=ob+jrNycMVEDd3LzzOaV0xJyeHg/ctn18pQ8ayR/b/k=; b=jsGCog/qCN+ARhI6B7un+kf2TzSlKjlPZp/UV55nFyTUMSwZiZctcUP9nFioj3ieLp C0VE8q0A8z4344gaJX1uOSoERmXG+N/0qef/4SiuKFyD7FGzQb4EE3PUIH+wRdklxJLA JGDSIRWtmL/tA2sFDl5hFMPPIIL9Jv+Wat1M3Mz+Y5Tp3V375qE44ahOawbtGUDCvx8Y vYxaDrxkpaPxYvbV4Od6XntuwESRb8YqiXj4R0IjTWzMIs38E54N+hrDxo85uFMB1Bn7 8JkNKL5D14h2jmnzleXxD3LoyuGqD/2o8xynxZSLlqSHBkC//VsF0MFKf1zmfIIw7IDy 1r8Q== X-Gm-Message-State: AG10YORuNv+bzl5H18J0saoLz0wmskhqudcgpg69B96ajx/svQZoH0k6jJTYRAaUEleQc80m X-Received: by 10.28.186.87 with SMTP id k84mr9258815wmf.13.1454078597348; Fri, 29 Jan 2016 06:43:17 -0800 (PST) Received: from localhost.localdomain (LMontsouris-657-1-37-90.w80-11.abo.wanadoo.fr. [80.11.198.90]) by smtp.gmail.com with ESMTPSA id x2sm15956383wjf.13.2016.01.29.06.43.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 29 Jan 2016 06:43:16 -0800 (PST) From: Eric Auger To: eric.auger@st.com, eric.auger@linaro.org, alex.williamson@redhat.com, linux-arm-kernel@lists.infradead.org, christoffer.dall@linaro.org Subject: [PATCH] vfio: pci: fix oops in case of vfio_msi_set_vector_signal failure Date: Fri, 29 Jan 2016 14:43:06 +0000 Message-Id: <1454078586-5431-1-git-send-email-eric.auger@linaro.org> X-Mailer: git-send-email 1.9.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160129_064341_292466_B5263D93 X-CRM114-Status: GOOD ( 11.32 ) X-Spam-Score: -2.7 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-kernel@vger.kernel.org, patches@linaro.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham 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 In case vfio_msi_set_vector_signal fails we tear down everything. In the tear down loop we compare int j against unsigned start. Given the arithmetic conversion I think it is converted into an unsigned and becomes 0xffffffff, leading to the loop being entered again and things turn bad when accessing vdev->msix[vector].vector. So let's use int parameters instead. Signed-off-by: Eric Auger --- drivers/vfio/pci/vfio_pci_intrs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/vfio/pci/vfio_pci_intrs.c b/drivers/vfio/pci/vfio_pci_intrs.c index 3b3ba15..510c48d 100644 --- a/drivers/vfio/pci/vfio_pci_intrs.c +++ b/drivers/vfio/pci/vfio_pci_intrs.c @@ -374,8 +374,8 @@ static int vfio_msi_set_vector_signal(struct vfio_pci_device *vdev, return 0; } -static int vfio_msi_set_block(struct vfio_pci_device *vdev, unsigned start, - unsigned count, int32_t *fds, bool msix) +static int vfio_msi_set_block(struct vfio_pci_device *vdev, int start, + int count, int32_t *fds, bool msix) { int i, j, ret = 0;