Linux PCI subsystem development
 help / color / mirror / Atom feed
From: Niklas Cassel <cassel@kernel.org>
To: sashiko-reviews@lists.linux.dev
Cc: linux-pci@vger.kernel.org
Subject: Re: [PATCH 2/2] misc: pci_endpoint_test: Improve logic to check status for doorbell test case
Date: Thu, 30 Jul 2026 14:45:32 +0200	[thread overview]
Message-ID: <amtHbHP0_2bBBa4C@ryzen> (raw)
In-Reply-To: <20260730123357.D349F1F000E9@smtp.kernel.org>

On Thu, Jul 30, 2026 at 12:33:57PM +0000, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
> 
> New issues:
> - [Medium] PCIe surprise removals masked by incorrectly evaluating an all-1s read as success.
> 
> Pre-existing issues:
> - [High] Unvalidated endpoint input leads to NULL pointer dereference and out-of-bounds MMIO write.
> - [High] Race condition between module teardown and active ioctls leading to double-free or UAF of IRQ vectors.
> - [High] Unbounded, uninterruptible waits on endpoint interrupts create unkillable tasks and a global ioctl deadlock.
> --
> 
> --- Patch [2]: [PATCH 2/2] misc: pci_endpoint_test: Improve logic to check status for doorbell test case ---
> commit e34bb71884c618c46be8a57cc0405805a9d2c585
> Author: Niklas Cassel <cassel@kernel.org>
> 
> misc: pci_endpoint_test: Improve logic to check status for doorbell test case
> 
> This patch modifies the doorbell test case to verify if the SUCCESS bit was
> set rather than checking if the FAIL bit was set. This handles cases where
> an IRQ timeout occurs or buggy EPC drivers send multiple IRQs.
> 
> > diff --git a/drivers/misc/pci_endpoint_test.c b/drivers/misc/pci_endpoint_test.c
> > --- a/drivers/misc/pci_endpoint_test.c
> > +++ b/drivers/misc/pci_endpoint_test.c
> > @@ -1094,7 +1094,7 @@ static int pci_endpoint_test_doorbell(struct pci_endpoint_test *test)
> >  	left = wait_for_completion_timeout(&test->irq_raised, msecs_to_jiffies(1000));
> >  
> >  	status = pci_endpoint_test_readl(test, PCI_ENDPOINT_TEST_STATUS);
> > -	if (!left || (status & STATUS_DOORBELL_ENABLE_FAIL)) {
> > +	if (!left || !(status & STATUS_DOORBELL_ENABLE_SUCCESS)) {
> 
> [Severity: Medium]
> If the PCIe endpoint surprise-disconnects or the link goes down, MMIO reads
> like pci_endpoint_test_readl() will return all-1s (0xFFFFFFFF). By checking
> !(status & STATUS_DOORBELL_ENABLE_SUCCESS), an all-1s read evaluates as true
> for the bitwise AND, making the logical NOT false.
> 
> Does this inadvertently bypass the error handler during a hardware failure?

With this logic, every readl() in drivers/misc/pci_endpoint_test.c should check
if the return value is 0xFFFFFFFF.


Which they do not:

reg = pci_endpoint_test_readl(test, PCI_ENDPOINT_TEST_STATUS);          
        if (!(reg & STATUS_READ_SUCCESS))                                       
                ret = -EIO;                                   


This brings pci_endpoint_test_doorbell() in line with pci_endpoint_test_read().

I still think this patch makes sense.


Kind regards,
Niklas

      reply	other threads:[~2026-07-30 12:45 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-30 12:20 [PATCH 0/2] misc: pci_endpoint_test: Doorbell fix and improvement Niklas Cassel
2026-07-30 12:20 ` [PATCH 1/2] misc: pci_endpoint_test: Fix doorbell success logic Niklas Cassel
2026-07-30 12:30   ` sashiko-bot
2026-07-30 12:20 ` [PATCH 2/2] misc: pci_endpoint_test: Improve logic to check status for doorbell test case Niklas Cassel
2026-07-30 12:33   ` sashiko-bot
2026-07-30 12:45     ` Niklas Cassel [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=amtHbHP0_2bBBa4C@ryzen \
    --to=cassel@kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox