mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Kees Cook <kees@kernel.org>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: linux-kernel@vger.kernel.org,
	Alexandre Ghiti <alexghiti@rivosinc.com>,
	Arnd Bergmann <arnd@arndb.de>,
	Bjorn Helgaas <bhelgaas@google.com>,
	Geert Uytterhoeven <geert@linux-m68k.org>,
	Heiko Carstens <hca@linux.ibm.com>, Helge Deller <deller@gmx.de>,
	Kees Cook <kees@kernel.org>,
	Linux Kernel Functional Testing <lkft@linaro.org>,
	Madhavan Srinivasan <maddy@linux.ibm.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Stafford Horne <shorne@gmail.com>
Subject: [GIT PULL] ffs-const update for v6.18-rc1
Date: Mon, 29 Sep 2025 12:02:45 -0700	[thread overview]
Message-ID: <202509291157.2B1EA74A21@keescook> (raw)

Hi Linus,

Please pull this ffs() attribute-const update for v6.18-rc1. While
working on various hardening refactoring a while back we encountered
inconsistencies in the application of __attribute_const__ on the ffs()
family of functions. This series fixes this across all archs and adds
KUnit tests. Notably, this found a theoretical underflow in PCI (also
fixed here) and uncovered an inefficiency in ARC (fixed in the ARC
arch PR). I kept the series separate from the general hardening PR since
it is a stand-alone "topic".

Thanks!

-Kees

The following changes since commit c17b750b3ad9f45f2b6f7e6f7f4679844244f0b9:

  Linux 6.17-rc2 (2025-08-17 15:22:10 -0700)

are available in the Git repository at:

  https://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git tags/ffs-const-v6.18-rc1

for you to fetch changes up to 95719dfa323709c06ec34cc96e73e0788e19934f:

  KUnit: ffs: Validate all the __attribute_const__ annotations (2025-09-08 14:58:52 -0700)

----------------------------------------------------------------
ffs-const update for v6.18-rc1

- PCI: Fix theoretical underflow in use of ffs().

- Universally apply __attribute_const__ to all architecture's ffs()-family
  of functions.

- Add KUnit tests for ffs() behavior and const-ness.

----------------------------------------------------------------
Kees Cook (18):
      PCI: Test for bit underflow in pcie_set_readrq()
      KUnit: Introduce ffs()-family tests
      bitops: Add __attribute_const__ to generic ffs()-family implementations
      csky: Add __attribute_const__ to ffs()-family implementations
      x86: Add __attribute_const__ to ffs()-family implementations
      powerpc: Add __attribute_const__ to ffs()-family implementations
      sh: Add __attribute_const__ to ffs()-family implementations
      alpha: Add __attribute_const__ to ffs()-family implementations
      hexagon: Add __attribute_const__ to ffs()-family implementations
      riscv: Add __attribute_const__ to ffs()-family implementations
      openrisc: Add __attribute_const__ to ffs()-family implementations
      m68k: Add __attribute_const__ to ffs()-family implementations
      mips: Add __attribute_const__ to ffs()-family implementations
      parisc: Add __attribute_const__ to ffs()-family implementations
      s390: Add __attribute_const__ to ffs()-family implementations
      xtensa: Add __attribute_const__ to ffs()-family implementations
      sparc: Add __attribute_const__ to ffs()-family implementations
      KUnit: ffs: Validate all the __attribute_const__ annotations

 lib/Kconfig.debug                          |  14 +
 lib/tests/Makefile                         |   1 +
 arch/alpha/include/asm/bitops.h            |  14 +-
 arch/csky/include/asm/bitops.h             |   8 +-
 arch/hexagon/include/asm/bitops.h          |  10 +-
 arch/m68k/include/asm/bitops.h             |  14 +-
 arch/mips/include/asm/bitops.h             |   8 +-
 arch/openrisc/include/asm/bitops/__ffs.h   |   2 +-
 arch/openrisc/include/asm/bitops/__fls.h   |   2 +-
 arch/openrisc/include/asm/bitops/ffs.h     |   2 +-
 arch/openrisc/include/asm/bitops/fls.h     |   2 +-
 arch/parisc/include/asm/bitops.h           |   6 +-
 arch/powerpc/include/asm/bitops.h          |   4 +-
 arch/riscv/include/asm/bitops.h            |   6 +-
 arch/s390/include/asm/bitops.h             |  10 +-
 arch/sh/include/asm/bitops.h               |   4 +-
 arch/sparc/include/asm/bitops_64.h         |   8 +-
 arch/x86/include/asm/bitops.h              |  12 +-
 arch/xtensa/include/asm/bitops.h           |  10 +-
 include/asm-generic/bitops/__ffs.h         |   2 +-
 include/asm-generic/bitops/__fls.h         |   2 +-
 include/asm-generic/bitops/builtin-__ffs.h |   2 +-
 include/asm-generic/bitops/builtin-__fls.h |   2 +-
 include/asm-generic/bitops/builtin-fls.h   |   2 +-
 include/asm-generic/bitops/ffs.h           |   2 +-
 include/asm-generic/bitops/fls.h           |   2 +-
 include/asm-generic/bitops/fls64.h         |   4 +-
 include/linux/bitops.h                     |   2 +-
 drivers/pci/pci.c                          |   6 +-
 lib/clz_ctz.c                              |   8 +-
 lib/tests/ffs_kunit.c                      | 566 +++++++++++++++++++++++++++++
 31 files changed, 661 insertions(+), 76 deletions(-)
 create mode 100644 lib/tests/ffs_kunit.c

-- 
Kees Cook

             reply	other threads:[~2025-09-29 19:02 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-29 19:02 Kees Cook [this message]
2025-09-30  1:13 ` pr-tracker-bot

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=202509291157.2B1EA74A21@keescook \
    --to=kees@kernel.org \
    --cc=alexghiti@rivosinc.com \
    --cc=arnd@arndb.de \
    --cc=bhelgaas@google.com \
    --cc=deller@gmx.de \
    --cc=geert@linux-m68k.org \
    --cc=hca@linux.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lkft@linaro.org \
    --cc=maddy@linux.ibm.com \
    --cc=peterz@infradead.org \
    --cc=shorne@gmail.com \
    --cc=torvalds@linux-foundation.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

all inboxes | Powered by JetHome®