From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7A461C2D0DB for ; Tue, 28 Jan 2020 14:44:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 52E3524683 for ; Tue, 28 Jan 2020 14:44:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1580222693; bh=ycQ23ixeaeOqETre0ofxhlGMc8IkGjaBNi7nKZ5gf5c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=Z70Gu1zLZAC1rkEKNCztwyvKuNCJEt+2yJTo6eCCQZn6NnDfebTwMDfePp+wLFAiP Htf4N4kDe1btqUrK5I0gVm8U3ZNyqV+53kiJNFQGPLWUFWNJku7c3PXfCgwZ3GFt08 VbK+zpEUA52UKaXJrmhUQcJ6qmOK7gJh1xZGcheg= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728899AbgA1OJa (ORCPT ); Tue, 28 Jan 2020 09:09:30 -0500 Received: from mail.kernel.org ([198.145.29.99]:57892 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727982AbgA1OJa (ORCPT ); Tue, 28 Jan 2020 09:09:30 -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 EB6AA24685; Tue, 28 Jan 2020 14:09:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1580220569; bh=ycQ23ixeaeOqETre0ofxhlGMc8IkGjaBNi7nKZ5gf5c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZJ9PgiuF5y90cnjXapb2iM2EuTIM/sjT7lzudtbFOvZjND7/EHoGnGcXHJIjLKOzU UO8uJ7nYigPzjFnkhZRPT0nHpNGMQsL6aKx1kiNihZxvhTDNwQSjRZ7zVT0EwBhxER flh4CL+eI319X9otscAcxOMaUwbnacQhXCY9PFhE= 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.4 059/183] xen, cpu_hotplug: Prevent an out of bounds access Date: Tue, 28 Jan 2020 15:04:38 +0100 Message-Id: <20200128135835.811982048@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200128135829.486060649@linuxfoundation.org> References: <20200128135829.486060649@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@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