On Mon, Sep 08, 2025 at 04:51:42PM -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") > > Reported-by: Linux Kernel Functional Testing <l...@linaro.org> > > Closes: > > https://lore.kernel.org/linux-pci/CA+G9fYuysVr6qT8bjF6f08WLyCJRG7aXAeSd2F7=ztahhd7...@mail.gmail.com/ > > Signed-off-by: Kees Cook <k...@kernel.org> > > Acked-by: Bjorn Helgaas <bhelg...@google.com> > > Would be great if you included this as part of your series, thanks!
Okay, thanks! :) -Kees -- Kees Cook