From: Dan Carpenter <dan.carpenter@linaro.org>
To: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
Cc: linux-pci@vger.kernel.org
Subject: [bug report] PCI: Add pci_rebar_size_supported() helper
Date: Fri, 21 Nov 2025 12:48:10 +0300 [thread overview]
Message-ID: <aSA1WiRG3RuhqZMY@stanley.mountain> (raw)
Hello Ilpo Järvinen,
Commit bb1fabd0d94e ("PCI: Add pci_rebar_size_supported() helper")
from Nov 13, 2025 (linux-next), leads to the following Smatch static
checker warning:
drivers/pci/rebar.c:142 pci_rebar_size_supported()
error: undefined (user controlled) shift '(((1))) << size'
The problem is this call tree:
__resource_resize_store() <- takes an unsigned long from the user
-> pci_resize_resource() <- truncates it to int
-> pci_rebar_size_supported()
drivers/pci/rebar.c
138 bool pci_rebar_size_supported(struct pci_dev *pdev, int bar, int size)
139 {
140 u64 sizes = pci_rebar_get_possible_sizes(pdev, bar);
141
--> 142 return BIT(size) & sizes;
143 }
So here size could be negative or >= BITS_PER_LONG which leads to
shift wrapping. But also truncating the ulong to int in
__resource_resize_store() is not beautiful.
regards,
dan carpenter
next reply other threads:[~2025-11-21 9:48 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-21 9:48 Dan Carpenter [this message]
2025-11-21 11:38 ` [bug report] PCI: Add pci_rebar_size_supported() helper Ilpo Järvinen
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=aSA1WiRG3RuhqZMY@stanley.mountain \
--to=dan.carpenter@linaro.org \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=linux-pci@vger.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.