From patchwork Mon Oct 30 02:55:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 117435 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp2059346qgn; Sun, 29 Oct 2017 19:56:13 -0700 (PDT) X-Google-Smtp-Source: ABhQp+SVsLKUb+3wFun2s9esxXIPUmw7ps/PFR8od3zPV1SqVvaMMqOnIr+ZXs2I7rbtPnKmG+ON X-Received: by 10.99.149.15 with SMTP id p15mr6516023pgd.406.1509332173822; Sun, 29 Oct 2017 19:56:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1509332173; cv=none; d=google.com; s=arc-20160816; b=R9FY2kRJg2Ed7LUiUfkYc7G41DMMoVwV/+MpmIVbNaSalWZDLthotS864Dz930a9wx X9EjeJ6n1GeIrsrOJst6JWuVlAkgXfpICO5uEDVOQnxGlpSMzAbeeDWta/usqV1TWNbK cRGdpYZUephYYigF5ojRSrITO1dQCOj6D7aIa0Tqx2vmFTJS1wXjJ13ciUwIvqJL0TM2 bN2TlIxccywZp1QGkt+qrNGKsAJaeopR+S6nnZBONa0cB3zfIUYbowz8Lj0uD8HaV9fr OoyylYIbF8jEdY926VT8MS0WpB0B1U9jnMUTXOC7egrrfydsM1XedbfNr5SUxYw6lPJG oIEg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=q9nmbJxbxPgn0BsGyQlVJTCNZwqTNzJZOiPh1QA6UkM=; b=Dfgr7FdOjvPmfaJoTMCa/VdDd8oWZRvQgK+wx///QPQfCpcAg8PdC7FIzGeXxhuT+h E0oJCYC0LmrRd1jVVAdJdlCJc4dXPhXh5ir+EJ8luWm6KUEymMbbUInUzpuRzog2byFD myUDZoBHAgghUEdoGMlmWk9nMSLgJ2suMJx97pAMyS3xjVQDs/JCaXvz9vA0Uv2xWw3X yloF83T8gyN6qZ3Q7ktDt1hoq1eOy5jTE4htYe+iiB1taNbkauJJBvgP6eC/1s57MVuh mkV5uKvcj8pjXRhimKMlg37wmOAEOh5HHcifKdpvBKruxxLBvC95mmtVC62ejtxxRxS9 8svg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CzOXMe7H; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 85si9736578pfz.417.2017.10.29.19.56.13; Sun, 29 Oct 2017 19:56:13 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CzOXMe7H; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751909AbdJ3C4L (ORCPT + 9 others); Sun, 29 Oct 2017 22:56:11 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:46885 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750929AbdJ3C4K (ORCPT ); Sun, 29 Oct 2017 22:56:10 -0400 Received: by mail-wm0-f66.google.com with SMTP id m72so12945078wmc.1 for ; Sun, 29 Oct 2017 19:56:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=q9nmbJxbxPgn0BsGyQlVJTCNZwqTNzJZOiPh1QA6UkM=; b=CzOXMe7HM844TST4Es68U/3g0ve3ovv+aAZDB5/vbAq4rO3rxZqfFawXCxf8Fu64xs MZI1GJ/hjZl7F0CNNzxsdJbTMdDd35CU2xXauhDS9OhegB9Q5PDMhKk4asyFgYSrZXZF KEDE5oOtKQmQqG55Rkv253G3LynYY5S4XJBW8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=q9nmbJxbxPgn0BsGyQlVJTCNZwqTNzJZOiPh1QA6UkM=; b=queFCGVZgU+9pgp+KyLViE0EOEBWD5+9Y7hKn04IU/Y7iKJ17jYm2HdJYNyqd9bmK1 QSqV0IhLbT1kytZ7ot0Ws81WTmhH1qneRnpOuT00hKfQPqbFcoxHvIuq3phG4CCTmzL0 NjtHIlMRoMT+9iDsu2DmsonmxsjlpfKVXdI7qAfjNPFo9ANbYnAJJcvOExMEqfr6SxyL x1tmoxpWYiQKm6yKjeABsbg4YMzqPysF1qqNfOKGkIUMqsZTK9l2m4BJVjFT1yYRspfI 67U7FmEbIYgCZEAGiF6Z2628uFQd5r3PT2mtMZax0YqXWWqyD2zXMzRou+55+CjJogx/ RmpQ== X-Gm-Message-State: AMCzsaUYYopCS7txiiqgqjZY5DvUYpxsiiGBSpG+rPO/9TOTYK8rpzIm FI7r8CZchCa+rss3pg1NdrUm/w== X-Received: by 10.80.153.48 with SMTP id k45mr10032786edb.208.1509332169614; Sun, 29 Oct 2017 19:56:09 -0700 (PDT) Received: from localhost.localdomain (xd93dd96b.cust.hiper.dk. [217.61.217.107]) by smtp.gmail.com with ESMTPSA id u14sm7856415edd.47.2017.10.29.19.56.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 29 Oct 2017 19:56:08 -0700 (PDT) From: Christoffer Dall To: Paolo Bonzini , =?utf-8?b?UmFkaW0gS3LEjW3DocWZ?= Cc: Marc Zyngier , kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Christoffer Dall , stable@vger.kernel.org Subject: [PULL 1/8] KVM: arm64: its: Fix missing dynamic allocation check in scan_its_table Date: Mon, 30 Oct 2017 03:55:56 +0100 Message-Id: <20171030025603.23550-2-christoffer.dall@linaro.org> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171030025603.23550-1-christoffer.dall@linaro.org> References: <20171030025603.23550-1-christoffer.dall@linaro.org> Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org We currently allocate an entry dynamically, but we never check if the allocation actually succeeded. We actually don't need a dynamic allocation, because we know the maximum size of an ITS table entry, so we can simply use an allocation on the stack. Cc: Signed-off-by: Christoffer Dall --- virt/kvm/arm/vgic/vgic-its.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) -- 2.14.2 diff --git a/virt/kvm/arm/vgic/vgic-its.c b/virt/kvm/arm/vgic/vgic-its.c index f51c1e1b3f70..77652885a7c1 100644 --- a/virt/kvm/arm/vgic/vgic-its.c +++ b/virt/kvm/arm/vgic/vgic-its.c @@ -1801,37 +1801,33 @@ typedef int (*entry_fn_t)(struct vgic_its *its, u32 id, void *entry, static int scan_its_table(struct vgic_its *its, gpa_t base, int size, int esz, int start_id, entry_fn_t fn, void *opaque) { - void *entry = kzalloc(esz, GFP_KERNEL); struct kvm *kvm = its->dev->kvm; unsigned long len = size; int id = start_id; gpa_t gpa = base; + char entry[esz]; int ret; + memset(entry, 0, esz); + while (len > 0) { int next_offset; size_t byte_offset; ret = kvm_read_guest(kvm, gpa, entry, esz); if (ret) - goto out; + return ret; next_offset = fn(its, id, entry, opaque); - if (next_offset <= 0) { - ret = next_offset; - goto out; - } + if (next_offset <= 0) + return next_offset; byte_offset = next_offset * esz; id += next_offset; gpa += byte_offset; len -= byte_offset; } - ret = 1; - -out: - kfree(entry); - return ret; + return 1; } /**