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=-15.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=ham 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 7886CC433DB for ; Wed, 10 Mar 2021 12:14:17 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 520D764FD9 for ; Wed, 10 Mar 2021 12:14:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 520D764FD9 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kaod.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4DwWGG2s5Yz3d59 for ; Wed, 10 Mar 2021 23:14:14 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=kaod.org (client-ip=188.165.49.222; helo=6.mo52.mail-out.ovh.net; envelope-from=clg@kaod.org; receiver=) Received: from 6.mo52.mail-out.ovh.net (6.mo52.mail-out.ovh.net [188.165.49.222]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4DwWFv3vvFz2xxp for ; Wed, 10 Mar 2021 23:13:54 +1100 (AEDT) Received: from mxplan5.mail.ovh.net (unknown [10.108.16.53]) by mo52.mail-out.ovh.net (Postfix) with ESMTPS id 6778A23CE18; Wed, 10 Mar 2021 12:18:51 +0100 (CET) Received: from kaod.org (37.59.142.95) by DAG4EX1.mxp5.local (172.16.2.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2106.2; Wed, 10 Mar 2021 12:18:50 +0100 Authentication-Results: garm.ovh; auth=pass (GARM-95G001ec6da1e9-b4b1-4b66-8e8a-1f3004fd19b8, DA160024BEE8362F46BAC18ABAE7D936D1F8982C) smtp.auth=clg@kaod.org X-OVh-ClientIp: 82.64.250.170 Subject: Re: [PATCH] powerpc/xmon: Check cpu id in commands "c#", "dp#" and "dx#" To: Greg Kurz , References: <161531347060.252863.10490063933688958044.stgit@bahia.lan> From: =?UTF-8?Q?C=c3=a9dric_Le_Goater?= Message-ID: Date: Wed, 10 Mar 2021 12:18:49 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 MIME-Version: 1.0 In-Reply-To: <161531347060.252863.10490063933688958044.stgit@bahia.lan> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 8bit X-Originating-IP: [37.59.142.95] X-ClientProxiedBy: DAG5EX1.mxp5.local (172.16.2.41) To DAG4EX1.mxp5.local (172.16.2.31) X-Ovh-Tracer-GUID: a3310bfd-f24f-4ebf-ae6c-95a27d209d1d X-Ovh-Tracer-Id: 12329166930291624925 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: 0 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgeduledruddukedgvdekucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecuhedttdenucenucfjughrpefuvfhfhffkffgfgggjtgfgihesthekredttdefjeenucfhrhhomhepveorughrihgtpgfnvggpifhorghtvghruceotghlgheskhgrohgurdhorhhgqeenucggtffrrghtthgvrhhnpeejkeduueduveelgeduueegkeelffevledujeetffeivdelvdfgkeeufeduheehfeenucfkpheptddrtddrtddrtddpfeejrdehledrudegvddrleehnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmohguvgepshhmthhpqdhouhhtpdhhvghlohepmhigphhlrghnhedrmhgrihhlrdhovhhhrdhnvghtpdhinhgvtheptddrtddrtddrtddpmhgrihhlfhhrohhmpegtlhhgsehkrghougdrohhrghdprhgtphhtthhopehgrhhouhhgsehkrghougdrohhrgh X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" On 3/9/21 7:11 PM, Greg Kurz wrote: > All these commands end up peeking into the PACA using the user originated > cpu id as an index. Check the cpu id is valid in order to prevent xmon to > crash. Instead of printing an error, this follows the same behavior as the > "lp s #" command : ignore the buggy cpu id parameter and fall back to the > #-less version of the command. > > Signed-off-by: Greg Kurz Reviewed-by: Cédric Le Goater > --- > arch/powerpc/xmon/xmon.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/arch/powerpc/xmon/xmon.c b/arch/powerpc/xmon/xmon.c > index 80fbf8968f77..d3d6e044228e 100644 > --- a/arch/powerpc/xmon/xmon.c > +++ b/arch/powerpc/xmon/xmon.c > @@ -1248,7 +1248,7 @@ static int cpu_cmd(void) > unsigned long cpu, first_cpu, last_cpu; > int timeout; > > - if (!scanhex(&cpu)) { > + if (!scanhex(&cpu) || cpu >= num_possible_cpus()) { > /* print cpus waiting or in xmon */ > printf("cpus stopped:"); > last_cpu = first_cpu = NR_CPUS; > @@ -2678,7 +2678,7 @@ static void dump_pacas(void) > > termch = c; /* Put c back, it wasn't 'a' */ > > - if (scanhex(&num)) > + if (scanhex(&num) && num < num_possible_cpus()) > dump_one_paca(num); > else > dump_one_paca(xmon_owner); > @@ -2751,7 +2751,7 @@ static void dump_xives(void) > > termch = c; /* Put c back, it wasn't 'a' */ > > - if (scanhex(&num)) > + if (scanhex(&num) && num < num_possible_cpus()) > dump_one_xive(num); > else > dump_one_xive(xmon_owner); > >