Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp783537ybl; Fri, 24 Jan 2020 09:28:11 -0800 (PST) X-Google-Smtp-Source: APXvYqzIoojtv356Xf2dijAMNvQCgNNEC1haHOh47n7YwGhgFrt/LDeSiWM7hO5XfP8cWa50jqIp X-Received: by 2002:a05:6808:251:: with SMTP id m17mr36405oie.15.1579886891547; Fri, 24 Jan 2020 09:28:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579886891; cv=none; d=google.com; s=arc-20160816; b=GBKkJQR3KHvNzo1zodEIjwXq9RMjx+6/JKAVfe2Jgzxv0kjvtGJ968ovebAZskrcpC 8D//ub/i3YqsMQGJbrge3TL3Ifh+ZcPatdZ+nnibpMWo5Vz+cW9B1Qw900ln012Y6twU FCD001pDL0ch+19kpBa22eHYU0wUixC/0V7EMKaYZsCkLlkTIhPDfSUEL/bbo/zHMVoj 9o1Jw2lSUlSQjN6bXmrBRrB032r2f2XzQ5SaZUFSD2DEfyZznZZrPU5or1ijInD5BTSV M3K/HvCRXB3HDLzSdxkZ3JRJfiNLeQtUShGgbOP9fLy9Tg+mc4HD9ReTeWmZaEWHqshC ZNlg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=v1rBhG5vfQ8h7+VaH4gCRPHhyYBaABr4d8yqOwjAGoc=; b=ouaWWu1+SqY7+VZOrdIcKaiXXOTdI7ObMIusn9OEbg5b0XMUgZ/iSUpQNbeCCHdBfS NQtd0HA7bJPSFw6JPNywRVYnyhpOAylHy11y90ujvVcLP4Yf+0yY3TwCL8pyz9w9wtOq PwGLDWk3cilc9rQhxbD6VdSnfEN/p/atajfLQKCtDc3v0pFQ+0b0fQHuis3VFYe4kZZp yKF8XRZ2vuPAdQxua/Pa3K8Qx4gJyDw2S+iiFJVVubUhYMNQemmuxV/qTWZXjcae4SFh 4Nd+d5lZqU5oDEQI1LUlWzjZp31chfNAcvhCzh1AGTn7r5BkK0MVLinF+0Mas8xaO/10 ER8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Rw2AM8IR; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m20si3192707otk.279.2020.01.24.09.27.59; Fri, 24 Jan 2020 09:28:11 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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=@kernel.org header.s=default header.b=Rw2AM8IR; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390074AbgAXLNj (ORCPT + 99 others); Fri, 24 Jan 2020 06:13:39 -0500 Received: from mail.kernel.org ([198.145.29.99]:49914 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389655AbgAXLNe (ORCPT ); Fri, 24 Jan 2020 06:13:34 -0500 Received: from localhost (ip-213-127-102-57.ip.prioritytelecom.net [213.127.102.57]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id CA6482075D; Fri, 24 Jan 2020 11:13:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1579864414; bh=/NX5NIOkf2dcZHN/pvg6AC1JzczEJW6QgsLSmhgP8wg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Rw2AM8IRGS+0ZMf53ztlQb3ptIgCZpXFh8e92qhyqlqIWOXAB/tw17v6+E9g82C81 UqZq3zwJJZvmQHkkySDwdccAyo5a2E0hVkZK0HJ3fVfP8rJreRIIrRYS6QxLPrE+9L 8LExmgQAh8zDDyWyh1vJ0yVATxO0IptCCNTyBOio= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Carpenter , Juergen Gross , Sasha Levin Subject: [PATCH 4.19 258/639] xen, cpu_hotplug: Prevent an out of bounds access Date: Fri, 24 Jan 2020 10:27:08 +0100 Message-Id: <20200124093119.036574042@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200124093047.008739095@linuxfoundation.org> References: <20200124093047.008739095@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dan Carpenter [ Upstream commit 201676095dda7e5b31a5e1d116d10fc22985075e ] The "cpu" variable comes from the sscanf() so Smatch marks it as untrusted data. We can't pass a higher value than "nr_cpu_ids" to cpu_possible() or it results in an out of bounds access. Fixes: d68d82afd4c8 ("xen: implement CPU hotplugging") Signed-off-by: Dan Carpenter Reviewed-by: Juergen Gross Signed-off-by: Juergen Gross Signed-off-by: Sasha Levin --- drivers/xen/cpu_hotplug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/xen/cpu_hotplug.c b/drivers/xen/cpu_hotplug.c index b1357aa4bc552..f192b6f42da9f 100644 --- a/drivers/xen/cpu_hotplug.c +++ b/drivers/xen/cpu_hotplug.c @@ -54,7 +54,7 @@ static int vcpu_online(unsigned int cpu) } static void vcpu_hotplug(unsigned int cpu) { - if (!cpu_possible(cpu)) + if (cpu >= nr_cpu_ids || !cpu_possible(cpu)) return; switch (vcpu_online(cpu)) { -- 2.20.1