From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pegase2.c-s.fr (pegase2.c-s.fr [93.17.235.10]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CCAD7304BB8; Mon, 29 Sep 2025 17:20:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=93.17.235.10 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759166438; cv=none; b=CCJlEqtORc02SYJ+WK8n8x0ylXSZZ36abUMq/GO+maelrgbEWtJ4NOCEIcFCAqTK/HHldyPPFdHL+1EWGgtq4gGGh9XoPzFylpx1vnJNxyQflu1qRzeSYrPh/uteKGFhaAa2MxIzvxNvccX0+rkuj9ijPDwq1xO61RVC1NfgXpE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759166438; c=relaxed/simple; bh=LucnvV2vMc9inXFj/pxYEy58mJflY9oqWuavF2W1VoE=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=U0/oCFlxdJDe8W6Ch6XyfaGll2IS3slMdFtAHrlpG57dpg272BPpqTEzCoOjgnEqCuF8HyzojTB5eSTXLJI7JIQ/KLBWbgE8qRntDRAmqpLs1MJGFhr610xXvZ7QzY1M1TrlbQwnSuVPYmKJ9nEo+Rfc989b3f7IR/EVjV0SWds= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=csgroup.eu; spf=pass smtp.mailfrom=csgroup.eu; arc=none smtp.client-ip=93.17.235.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=csgroup.eu Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=csgroup.eu Received: from localhost (mailhub4.si.c-s.fr [172.26.127.67]) by localhost (Postfix) with ESMTP id 4cb6t02VLnz9sS8; Mon, 29 Sep 2025 19:01:44 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from pegase2.c-s.fr ([172.26.127.65]) by localhost (pegase2.c-s.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id PjXqacDyzuvU; Mon, 29 Sep 2025 19:01:44 +0200 (CEST) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase2.c-s.fr (Postfix) with ESMTP id 4cb6t01lRmz9sRs; Mon, 29 Sep 2025 19:01:44 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 28E228B786; Mon, 29 Sep 2025 19:01:44 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id LLWkJrEfX4ME; Mon, 29 Sep 2025 19:01:44 +0200 (CEST) Received: from [192.168.235.99] (unknown [192.168.235.99]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 96C498B783; Mon, 29 Sep 2025 19:01:43 +0200 (CEST) Message-ID: Date: Mon, 29 Sep 2025 19:01:43 +0200 Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH RESEND] PCI/AER: Check for NULL aer_info before ratelimiting in pci_print_aer() To: Breno Leitao , Mahesh J Salgaonkar , Oliver O'Halloran , Bjorn Helgaas , Kuppuswamy Sathyanarayanan , Jon Pan-Doh Cc: linuxppc-dev@lists.ozlabs.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-team@meta.com, stable@vger.kernel.org References: <20250929-aer_crash_2-v1-1-68ec4f81c356@debian.org> From: Christophe Leroy Content-Language: fr-FR In-Reply-To: <20250929-aer_crash_2-v1-1-68ec4f81c356@debian.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Le 29/09/2025 à 11:15, Breno Leitao a écrit : > Similarly to pci_dev_aer_stats_incr(), pci_print_aer() may be called > when dev->aer_info is NULL. Add a NULL check before proceeding to avoid > calling aer_ratelimit() with a NULL aer_info pointer, returning 1, which > does not rate limit, given this is fatal. > > This prevents a kernel crash triggered by dereferencing a NULL pointer > in aer_ratelimit(), ensuring safer handling of PCI devices that lack > AER info. This change aligns pci_print_aer() with pci_dev_aer_stats_incr() > which already performs this NULL check. > > Cc: stable@vger.kernel.org > Fixes: a57f2bfb4a5863 ("PCI/AER: Ratelimit correctable and non-fatal error logging") > Signed-off-by: Breno Leitao > --- > - This problem is still happening in upstream, and unfortunately no action > was done in the previous discussion. > - Link to previous post: > https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flore.kernel.org%2Fr%2F20250804-aer_crash_2-v1-1-fd06562c18a4%40debian.org&data=05%7C02%7Cchristophe.leroy2%40cs-soprasteria.com%7Cf48f0ae03ec542e13e5408ddff38d9d9%7C8b87af7d86474dc78df45f69a2011bb5%7C0%7C0%7C638947341818450358%7CUnknown%7CTWFpbGZsb3d8eyJFbXB0eU1hcGkiOnRydWUsIlYiOiIwLjAuMDAwMCIsIlAiOiJXaW4zMiIsIkFOIjoiTWFpbCIsIldUIjoyfQ%3D%3D%7C0%7C%7C%7C&sdata=ZzJDmrmyDpWh4JZQQzKFZVf%2BeYucLdNOr5L6tgytNPE%3D&reserved=0 > --- > drivers/pci/pcie/aer.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/drivers/pci/pcie/aer.c b/drivers/pci/pcie/aer.c > index e286c197d7167..55abc5e17b8b1 100644 > --- a/drivers/pci/pcie/aer.c > +++ b/drivers/pci/pcie/aer.c > @@ -786,6 +786,9 @@ static void pci_rootport_aer_stats_incr(struct pci_dev *pdev, > > static int aer_ratelimit(struct pci_dev *dev, unsigned int severity) > { > + if (!dev->aer_info) > + return 1; > + This is a static function, it cannot be called from outside aer.c . Why do you need such a check ? I a check was to be made it should be in pci_aer_init() and in fact if kmalloc fails then all the probe should be made to fail. > switch (severity) { > case AER_NONFATAL: > return __ratelimit(&dev->aer_info->nonfatal_ratelimit); > > --- > base-commit: e5f0a698b34ed76002dc5cff3804a61c80233a7a > change-id: 20250801-aer_crash_2-b21cc2ef0d00 > > Best regards, > -- > Breno Leitao > >