From: Kees Cook <kees@kernel.org>
To: Bjorn Helgaas <helgaas@kernel.org>
Cc: Bjorn Helgaas <bhelgaas@google.com>,
Linux Kernel Functional Testing <lkft@linaro.org>,
Anders Roxell <anders.roxell@linaro.org>,
Naresh Kamboju <naresh.kamboju@linaro.org>,
lkft-triage@lists.linaro.org,
Linux Regressions <regressions@lists.linux.dev>,
Arnd Bergmann <arnd@arndb.de>,
Dan Carpenter <dan.carpenter@linaro.org>,
Ben Copeland <benjamin.copeland@linaro.org>,
linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org,
"Peter Zijlstra (Intel)" <peterz@infradead.org>,
linux-hardening@vger.kernel.org
Subject: Re: [PATCH] PCI: Test for bit underflow in pcie_set_readrq()
Date: Mon, 8 Sep 2025 14:39:50 -0700 [thread overview]
Message-ID: <202509081437.1F92F56@keescook> (raw)
In-Reply-To: <20250908205349.GA1463686@bhelgaas>
On Mon, Sep 08, 2025 at 03:53:49PM -0500, Bjorn Helgaas wrote:
> On Thu, Sep 04, 2025 at 10:28:41PM -0700, Kees Cook wrote:
> > After commit cbc654d18d37 ("bitops: Add __attribute_const__ to generic
> > ffs()-family implementations"), which allows GCC's value range tracker
> > to see past ffs(), GCC 8 on ARM thinks that it might be possible that
> > "ffs(rq) - 8" used here:
> >
> > v = FIELD_PREP(PCI_EXP_DEVCTL_READRQ, ffs(rq) - 8);
> >
> > could wrap below 0, leading to a very large value, which would be out of
> > range for the FIELD_PREP() usage:
> >
> > drivers/pci/pci.c: In function 'pcie_set_readrq':
> > include/linux/compiler_types.h:572:38: error: call to '__compiletime_assert_471' declared with attribute error: FIELD_PREP: value too large for the field
> > ...
> > drivers/pci/pci.c:5896:6: note: in expansion of macro 'FIELD_PREP'
> > v = FIELD_PREP(PCI_EXP_DEVCTL_READRQ, ffs(rq) - 8);
> > ^~~~~~~~~~
> >
> > If the result of the ffs() is bounds checked before being used in
> > FIELD_PREP(), the value tracker seems happy again. :)
> >
> > Fixes: cbc654d18d37 ("bitops: Add __attribute_const__ to generic ffs()-family implementations")
>
> What's your plan for merging cbc654d18d37? I suppose it's intended
> for v6.18? If it will appear in v6.17, let me know so I can merge
> this for it as well.
I had it planned for v6.18.
> Maybe this should go in v6.17 regardless, to avoid a warning
> regression between this patch and cbc654d18d37?
Sure, or I could take it as part of the ffs series?
-Kees
--
Kees Cook
next prev parent reply other threads:[~2025-09-08 21:39 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
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 [this message]
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=202509081437.1F92F56@keescook \
--to=kees@kernel.org \
--cc=anders.roxell@linaro.org \
--cc=arnd@arndb.de \
--cc=benjamin.copeland@linaro.org \
--cc=bhelgaas@google.com \
--cc=dan.carpenter@linaro.org \
--cc=helgaas@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 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.