Linux PCI subsystem development
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@linaro.org>
To: phasta@kernel.org
Cc: Bjorn Helgaas <helgaas@kernel.org>, linux-pci@vger.kernel.org
Subject: Re: [bug report] PCI: Check BAR index for validity
Date: Mon, 10 Mar 2025 12:18:59 +0300	[thread overview]
Message-ID: <0eda35f7-51dc-4479-9d1d-65b930ed49f4@stanley.mountain> (raw)
In-Reply-To: <809eab4e8563d12d2d1f26195cff32bde05c299d.camel@mailbox.org>

On Mon, Mar 10, 2025 at 08:54:54AM +0100, Philipp Stanner wrote:
> > > 
> > >     626                 return;
> > >     627 
> > >     628         legacy_iomap_table = (void __iomem
> > > **)pcim_iomap_table(pdev);
> > >     629         if (!legacy_iomap_table)
> > >     630                 return;
> > >     631 
> > > --> 632         legacy_iomap_table[bar] = NULL;
> > >                 ^^^^^^^^^^^^^^^^^^^^^^^
> > > Leading to a buffer overflow.
> 
> Leading to a *potential* buffer overflow.
> 

Smatch is doing cross function analysis in this case.  Smatch knows
that pcim_iounmap_regions() is fine but the bug is when this is
called from pcim_iomap_regions().

drivers/pci/devres.c | pcim_iounmap_regions | pcim_remove_bar_from_legacy_table | PARAM_VALUE | 1 | bar | 0-5
drivers/pci/devres.c |   pcim_iomap_regions | pcim_remove_bar_from_legacy_table | PARAM_VALUE | 1 | bar | 0-15

But, that raises a different question because you would expect
the map and unmap functions to loop over the same bars.

regards,
dan carpenter


  parent reply	other threads:[~2025-03-10  9:19 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-08 10:23 [bug report] PCI: Check BAR index for validity Dan Carpenter
2025-03-08 21:07 ` Bjorn Helgaas
2025-03-10  7:54   ` Philipp Stanner
2025-03-10  8:57     ` Philipp Stanner
2025-03-10  9:18     ` Dan Carpenter [this message]
2025-03-10 19:53     ` Bjorn Helgaas

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=0eda35f7-51dc-4479-9d1d-65b930ed49f4@stanley.mountain \
    --to=dan.carpenter@linaro.org \
    --cc=helgaas@kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=phasta@kernel.org \
    /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