Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp460953ybl; Tue, 28 Jan 2020 06:19:52 -0800 (PST) X-Google-Smtp-Source: APXvYqyPwxh5ogfdcC5QDrDjjbuAiTxmPXLG7c+NQgL+3I6OHMOw9CLVjevF2MAkK7/j7ev2jtjk X-Received: by 2002:aca:f20b:: with SMTP id q11mr2815561oih.78.1580221192753; Tue, 28 Jan 2020 06:19:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580221192; cv=none; d=google.com; s=arc-20160816; b=MTaNF1jQyCQ1Aki/3iuBQbxG0YiLK5kP/43FN8+cDQh4szj/o6KdiUvjsV2OqeqVBK p/Ode7ST7h+5eVeyqub8lBe2f7i/JzP5UE10RpODP4v0DgwyCUeq1HQRJeZWQtlRImbD dktaFFqSt94Nna4o3C7N/9shR1G7rjLckbHX0jmA/rcoTdEGURkcPzxnBBYVRnH5Mehp XaKu0QwYFO/y9+QZk2g8eN25GoT5O32QC3Kj6g/fjbYot2NDs2oPHar3COkrwN/3mTAh T6cHw0dqfPdO+O60EpBW0AmWAByEJDi2JQljs9oB2O7fExqPXXWSveBl5FZhbTxz37Yf e/7g== 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=3KvQr8VPipqD47rJ6YHfyfVdRnVc1X0+j9w5hdMzI1g=; b=MndPjYJHY0C+bK1k2SgisSTVBO6yIQVxdZ0Ur/1CniZzepSbMEzxUR3OcWtefgwbcQ uQoiE5zNHcdsE/VZnzFCos01sHZn+2FZzaTPwLg7MyAZzueJ+TxtZfaJ9Wf0Ye/ZOg6b /zNdavpLHMUqVzhshWyAPVcZ46ZNm2OBZuyDAGoqIUJOrTakYY4J+BG+IdJgRoolq2ra u5kelnRsTmPMLPGu0efYQMGRuPUAGQeXkMG50XPncLBtr2lDw9kQdjagTKnOAh3HIBcH qp6htuCpChWFU5LYDXs7/q5yFjvGypIjPkzDJISUymwCOVKUsyYTbqSMiJTeSk/XMfFG B7ig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=fcV70F7x; 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 j13si7967529otq.146.2020.01.28.06.19.40; Tue, 28 Jan 2020 06:19:52 -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=fcV70F7x; 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 S1730715AbgA1OSl (ORCPT + 99 others); Tue, 28 Jan 2020 09:18:41 -0500 Received: from mail.kernel.org ([198.145.29.99]:42742 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730497AbgA1OSk (ORCPT ); Tue, 28 Jan 2020 09:18:40 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 2B6EF2468D; Tue, 28 Jan 2020 14:18:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1580221119; bh=ycQ23ixeaeOqETre0ofxhlGMc8IkGjaBNi7nKZ5gf5c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fcV70F7xAT+z4hflFsG9tMHaFBkbXFLYy0PtproEiVH0/LWDyA3zYQS8k7IX5tO1K ueBdo9c2oJLjDS1cjIFoSvHddKSyj8GEqbpa9M2ngNO06vkF/vaFDgDZOq1uXl4IDs MaLvAfu9J8OnRxH7rxSnDY9iO02qFucwKIyAJXDM= 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.9 096/271] xen, cpu_hotplug: Prevent an out of bounds access Date: Tue, 28 Jan 2020 15:04:05 +0100 Message-Id: <20200128135859.742312623@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200128135852.449088278@linuxfoundation.org> References: <20200128135852.449088278@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 f4e59c445964d..17054d6954117 100644 --- a/drivers/xen/cpu_hotplug.c +++ b/drivers/xen/cpu_hotplug.c @@ -53,7 +53,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