Received: by 2002:ab2:60d1:0:b0:1f7:5705:b850 with SMTP id i17csp393279lqm; Wed, 1 May 2024 04:11:36 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVpfw5rDNjc9hI4TAYD+TlN3Pi604NAd0z6c2e4oQG/z644fC7iAocivmlESxRM6onO2oJRgLvBrvLymfHrYBFHRPe6RrUI3FxuBrSu+w== X-Google-Smtp-Source: AGHT+IG83NqBWVzRSIFRkUDdX5rgrUzW/k+StLFuz26/zlcMqIgXKj3W8+mXrPdlx/AaH+5MqX8w X-Received: by 2002:a05:6a20:748d:b0:1ad:7be1:a4a9 with SMTP id p13-20020a056a20748d00b001ad7be1a4a9mr3099315pzd.34.1714561896671; Wed, 01 May 2024 04:11:36 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714561896; cv=pass; d=google.com; s=arc-20160816; b=oPCD+wdzJCalFlHvP8Zw2yi+nvIAHgJ/8hmGTt6Jh9iCij6x00vUSTrWLbkchP2fSF 5s+bDT4iPPmjU6rF6Aw5mfbVBvdJrYx92hg/l9ulE0404bnMEC8t2SuSmb/5RuTi63Dn PxyuL58XVSB0MpKYDeTqUwf5/uYJIkV2AfYdfDK7ohGhv7L+A7tJZf0/fRQDxjdnDqxo jFYkuuey649N5RSkzPgo3LFKcKYp9i5+/15XsU1vPXMgL7RYv+bv/yrRBQwZD0hTKf1G WdJHiIdL4/97rI6PO5uiISsNp82Lz5/AsqUVT3v88WOpMeZU8KWoszR092y/46UBVeHR BkDw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=/9EhiTpZ039qYHHJ6iv2nIzs+2XcBDCLGyTfEI94qWw=; fh=SFPdIYUpajDfAf3cpL6dY9OTpwpvXN+2z/lmQ5cySls=; b=J8ryM0pa3q3TogmuVqdvNjCSot3Hj18/KNVBu6efSTkxAKRPJdl7G2WEGM6Xh6b2NY Vek9Yx1mFnZpDPGWARsPdwuO6/A96LQK5vHT6QipsZI5Q8J40kyrdE9EoxBBQIXPEqIl nytuu21Fpe50dWfw69YiqO6+NwkK7rzYaMMrVnnJcO9MkhgFIBJ15YED+ld+CivkRpW1 7UzLPN4GvZtBgMd11PqJDyBo7t0bkbCPMBGiVlmAcuMhjmVQC5+we6dvyacIIYPZdqDp DOSYV9vGqirAVByZlcv8eCf0BqgONfRZqqGuKsD4AHY3L0Z+mjyXC4GGVaQm05G/04pV VvtQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=H0WpWxtn; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-165173-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-165173-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id pj8-20020a17090b4f4800b002b20efcfd10si1307417pjb.61.2024.05.01.04.11.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 May 2024 04:11:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-165173-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=H0WpWxtn; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-165173-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-165173-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 4286928241D for ; Wed, 1 May 2024 11:11:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1865360BBE; Wed, 1 May 2024 11:11:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="H0WpWxtn" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C378748CE0 for ; Wed, 1 May 2024 11:11:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714561885; cv=none; b=bPL8L7SfByRYrVTHGrjWO9SB/cO13mgoJFHH8MBVLrRRlIWToLe0D08KVqTVomBOnGYFASsKebriA8rnC3DCOJdZIP7ShZ8Q3ORBNBr4oaX4iQFx90EhmwljmKMCNO5hZxEKT7F5MZ6xeeauzfg86rXeujuLizMJTSREVwveN5M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714561885; c=relaxed/simple; bh=HjmQN/vLfXCeKes7nGzRxBen9HgLMO+9+ng5Ze3Bavk=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=VIGV62CRdJyH2i0WAana1xE9IWqIaahQffyOpf+SQD+SIZI1aueU/CWSCa5/0ZSPwLnTBfSvSOj2l5TT+wsKHdHXQ331eZWybKJQUFzNBMyUI6c+Cmd6E0s4Awb8HYl9ExOCPInppq/K33w4/bCzQ9vq1xs47tm+Ops855jw1as= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=H0WpWxtn; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1714561882; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/9EhiTpZ039qYHHJ6iv2nIzs+2XcBDCLGyTfEI94qWw=; b=H0WpWxtnat1Z9b6zzPoVhtz7huxz5QUERylQRVteNeAWYAnkviVJKNNQkJSB5f0xQYHRq0 TpFmVMrPV+8ae+JtszKNdm29LHV6o2e75eQF+cdhXXHkkDIj5e6dpy2EzFf8wsYT3UwtL5 pRt0jISXL7i6hRS3qPdYvCWcrH4oWrE= Received: from mail-pf1-f200.google.com (mail-pf1-f200.google.com [209.85.210.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-180-i4buSK1vM_ql7BdNxMA3Dw-1; Wed, 01 May 2024 07:11:06 -0400 X-MC-Unique: i4buSK1vM_ql7BdNxMA3Dw-1 Received: by mail-pf1-f200.google.com with SMTP id d2e1a72fcca58-6f3eb28c129so2556107b3a.1 for ; Wed, 01 May 2024 04:11:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714561865; x=1715166665; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=/9EhiTpZ039qYHHJ6iv2nIzs+2XcBDCLGyTfEI94qWw=; b=tu4g6u68c4l24KH1+m/PkeGQbD9neOHQHbLuBFANrxWBIwIe1QT+eR7piwhNCaDusY 3xtlCRjOsMblZA8oJFF+9rK7m+MbLAFBFJcz/eOOtmq+IXx3tmHxXNf8s4Ul78uHJ0dx E7zImM1mubwQx1MN67zHSN06IT39hkJUq93p3vXlhMsZp+91D14euxTvHGNmuNK0y5J6 VWn2K3DCYBq9qmI6hhD/PwdHxXJVgOgL0YH08i/8XxigjOHsnIsyNPlc1VhQWHP2f7iX QOeyAtRJKQs/AlRU2mHDXRU9kw8DfTrAs5wqXmgAyyc1W9PlsU0kwYc1kYUWBsa6RG9e QGjw== X-Forwarded-Encrypted: i=1; AJvYcCWlfz+d4LuE25gaElBo17dHGlwFvs1K8lp+J99CxwjT+CfX5s8vSCOKNzfQulHoyMMSfh4GMO8RhawxfFg/KJ9+wYv8C96juLz5yKWw X-Gm-Message-State: AOJu0YzSyLWTK+MEmGGOVp7emHEykftLwVeVey4jFLm9cgPmFOs/xufk edcT+uC08U89nUfqOiEz/x8u9ZHXec9M4YrULPtPcdf90ffNn6Hui8Z8r7JPN1TOtt0iZAz/JdA aGsLeESGgOw1NNQG8NJDqul2vWPxoHgYArolkKiJYSZqSTqUR0ByCD7+KPWRUOw== X-Received: by 2002:a05:6a20:f38a:b0:1af:59b9:e3ed with SMTP id qr10-20020a056a20f38a00b001af59b9e3edmr2412156pzb.5.1714561865246; Wed, 01 May 2024 04:11:05 -0700 (PDT) X-Received: by 2002:a05:6a20:f38a:b0:1af:59b9:e3ed with SMTP id qr10-20020a056a20f38a00b001af59b9e3edmr2412126pzb.5.1714561864872; Wed, 01 May 2024 04:11:04 -0700 (PDT) Received: from [192.168.68.50] ([43.252.112.88]) by smtp.gmail.com with ESMTPSA id r10-20020a6560ca000000b005fd74e632f0sm15597042pgv.38.2024.05.01.04.10.55 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 01 May 2024 04:11:04 -0700 (PDT) Message-ID: <47e1b241-9085-44e6-a3d0-4ded94a183ce@redhat.com> Date: Wed, 1 May 2024 21:10:53 +1000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v9 12/19] arm64: acpi: Harden get_cpu_for_acpi_id() against missing CPU entry Content-Language: en-US To: Jonathan Cameron , Thomas Gleixner , Peter Zijlstra , linux-pm@vger.kernel.org, loongarch@lists.linux.dev, linux-acpi@vger.kernel.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, x86@kernel.org, Russell King , "Rafael J . Wysocki" , Miguel Luis , James Morse , Salil Mehta , Jean-Philippe Brucker , Catalin Marinas , Will Deacon , Marc Zyngier , Hanjun Guo Cc: Ingo Molnar , Borislav Petkov , Dave Hansen , linuxarm@huawei.com, justin.he@arm.com, jianyong.wu@arm.com References: <20240430142434.10471-1-Jonathan.Cameron@huawei.com> <20240430142434.10471-13-Jonathan.Cameron@huawei.com> From: Gavin Shan In-Reply-To: <20240430142434.10471-13-Jonathan.Cameron@huawei.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 5/1/24 00:24, Jonathan Cameron wrote: > In a review discussion of the changes to support vCPU hotplug where > a check was added on the GICC being enabled if was was online, it was ^^^^^^^ typo > noted that there is need to map back to the cpu and use that to index > into a cpumask. As such, a valid ID is needed. > > If an MPIDR check fails in acpi_map_gic_cpu_interface() it is possible > for the entry in cpu_madt_gicc[cpu] == NULL. This function would > then cause a NULL pointer dereference. Whilst a path to trigger > this has not been established, harden this caller against the > possibility. > > Signed-off-by: Jonathan Cameron > --- > v9: New patch in response to a question from Marc Zyngier. > Taking the easy way out - harden against a possible condition rather > than establishing it never happens! > --- > arch/arm64/include/asm/acpi.h | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > With the typo corrected: Reviewed-by: Gavin Shan > diff --git a/arch/arm64/include/asm/acpi.h b/arch/arm64/include/asm/acpi.h > index bc9a6656fc0c..a407f9cd549e 100644 > --- a/arch/arm64/include/asm/acpi.h > +++ b/arch/arm64/include/asm/acpi.h > @@ -124,7 +124,8 @@ static inline int get_cpu_for_acpi_id(u32 uid) > int cpu; > > for (cpu = 0; cpu < nr_cpu_ids; cpu++) > - if (uid == get_acpi_id_for_cpu(cpu)) > + if (acpi_cpu_get_madt_gicc(cpu) && > + uid == get_acpi_id_for_cpu(cpu)) > return cpu; > > return -EINVAL;