From: "Arnd Bergmann" <arnd@arndb.de>
To: "Anders Roxell" <anders.roxell@linaro.org>,
"Kees Cook" <kees@kernel.org>
Cc: "Bjorn Helgaas" <bhelgaas@google.com>,
"Linaro Kernel Functional Testing" <lkft@linaro.org>,
"Naresh Kamboju" <naresh.kamboju@linaro.org>,
lkft-triage@lists.linaro.org,
"Linux Regressions" <regressions@lists.linux.dev>,
"Dan Carpenter" <dan.carpenter@linaro.org>,
"Benjamin Copeland" <benjamin.copeland@linaro.org>,
linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org,
"Peter Zijlstra" <peterz@infradead.org>,
linux-hardening@vger.kernel.org
Subject: Re: [PATCH] PCI: Test for bit underflow in pcie_set_readrq()
Date: Fri, 05 Sep 2025 12:52:44 +0200 [thread overview]
Message-ID: <f5db760e-c143-4f6c-9389-309a362f0baf@app.fastmail.com> (raw)
In-Reply-To: <CADYN=9Kd9w0pAMJJD1jq4RSum5+Xzk04yPZiQxi9tmEBtHPEMA@mail.gmail.com>
On Fri, Sep 5, 2025, at 10:16, Anders Roxell wrote:
> On Fri, 5 Sept 2025 at 07:28, Kees Cook <kees@kernel.org> wrote:
>> @@ -5949,7 +5950,10 @@ int pcie_set_readrq(struct pci_dev *dev, int rq)
>> rq = mps;
>> }
>>
>> - v = FIELD_PREP(PCI_EXP_DEVCTL_READRQ, ffs(rq) - 8);
>> + firstbit = ffs(rq);
>> + if (firstbit < 8)
>> + return -EINVAL;
>> + v = FIELD_PREP(PCI_EXP_DEVCTL_READRQ, firstbit - 8);
>
> Hi Kees,
>
> Thank you for looking into this.
>
> These warnings are not a one time thing. the later versions of gcc
> can figure it
> out that firstbit is at least 8 based on the "rq < 128" (i guess), so
> we're adding
> bogus code. maybe we should just disable the check for gcc-8.
Out of the three failures I saw, two also happened with gcc-9, but
gcc-10 looks clean so far.
> \
> + (0 + (_val)) : 0,
> \
> _pfx "value too large for the field"); \
> BUILD_BUG_ON_MSG(__bf_cast_unsigned(_mask, _mask) > \
> __bf_cast_unsigned(_reg, ~0ull), \
>
> I found similar patterns with ffs and FIELD_PREP here
> drivers/dma/uniphier-xdmac.c row 156 and 165
> drivers/gpu/drm/i915/display/intel_cursor_regs.h row 17
I did not come across build failures for these.
Arnd
next prev parent reply other threads:[~2025-09-05 10:53 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-05 5:28 [PATCH] PCI: Test for bit underflow in pcie_set_readrq() Kees Cook
2025-09-05 8:16 ` Anders Roxell
2025-09-05 10:52 ` Arnd Bergmann [this message]
2025-09-08 21:43 ` Kees Cook
2025-09-05 8:25 ` Arnd Bergmann
2025-09-08 21:46 ` Kees Cook
2025-09-08 20:53 ` Bjorn Helgaas
2025-09-08 21:39 ` Kees Cook
2025-09-08 21:51 ` Bjorn Helgaas
2025-09-08 21:57 ` Kees Cook
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=f5db760e-c143-4f6c-9389-309a362f0baf@app.fastmail.com \
--to=arnd@arndb.de \
--cc=anders.roxell@linaro.org \
--cc=benjamin.copeland@linaro.org \
--cc=bhelgaas@google.com \
--cc=dan.carpenter@linaro.org \
--cc=kees@kernel.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=lkft-triage@lists.linaro.org \
--cc=lkft@linaro.org \
--cc=naresh.kamboju@linaro.org \
--cc=peterz@infradead.org \
--cc=regressions@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