kmalloc_obj fixes for v7.0-rc2

- Fix pointer-to-array allocation types for ubd and kcsan
 
 - Force size overflow helpers to __always_inline
 
 - Bump __builtin_counted_by_ref to Clang 22.1 from 22.0 (Nathan Chancellor)
 -----BEGIN PGP SIGNATURE-----
 
 iHUEABYKAB0WIQRSPkdeREjth1dHnSE2KwveOeQkuwUCaaCJawAKCRA2KwveOeQk
 u2LdAQD/wZYe1YCCrUR+jM6EvAoI2CzUEQUQMyzLtjIyeSR6VAD8CSdZu0htnwwy
 Ca76IzSF8Aj0D7Hytxkk8HDAD4WuxA0=
 =QucI
 -----END PGP SIGNATURE-----

Merge tag 'kmalloc_obj-v7.0-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux

Pull kmalloc_obj fixes from Kees Cook:

 - Fix pointer-to-array allocation types for ubd and kcsan

 - Force size overflow helpers to __always_inline

 - Bump __builtin_counted_by_ref to Clang 22.1 from 22.0 (Nathan Chancellor)

* tag 'kmalloc_obj-v7.0-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux:
  kcsan: test: Adjust "expect" allocation type for kmalloc_obj
  overflow: Make sure size helpers are always inlined
  init/Kconfig: Adjust fixed clang version for __builtin_counted_by_ref
  ubd: Use pointer-to-pointers for io_thread_req arrays
This commit is contained in:
Linus Torvalds 2026-02-26 10:05:15 -08:00
commit 3f4a08e644
4 changed files with 11 additions and 11 deletions

View file

@ -69,11 +69,11 @@ struct io_thread_req {
};
static struct io_thread_req * (*irq_req_buffer)[];
static struct io_thread_req **irq_req_buffer;
static struct io_thread_req *irq_remainder;
static int irq_remainder_size;
static struct io_thread_req * (*io_req_buffer)[];
static struct io_thread_req **io_req_buffer;
static struct io_thread_req *io_remainder;
static int io_remainder_size;
@ -398,7 +398,7 @@ static int thread_fd = -1;
static int bulk_req_safe_read(
int fd,
struct io_thread_req * (*request_buffer)[],
struct io_thread_req **request_buffer,
struct io_thread_req **remainder,
int *remainder_size,
int max_recs
@ -465,7 +465,7 @@ static irqreturn_t ubd_intr(int irq, void *dev)
&irq_remainder, &irq_remainder_size,
UBD_REQ_BUFFER_SIZE)) >= 0) {
for (i = 0; i < len / sizeof(struct io_thread_req *); i++)
ubd_end_request((*irq_req_buffer)[i]);
ubd_end_request(irq_req_buffer[i]);
}
if (len < 0 && len != -EAGAIN)
@ -1512,7 +1512,7 @@ void *io_thread(void *arg)
}
for (count = 0; count < n/sizeof(struct io_thread_req *); count++) {
struct io_thread_req *req = (*io_req_buffer)[count];
struct io_thread_req *req = io_req_buffer[count];
int i;
io_count++;

View file

@ -42,7 +42,7 @@
* both the type-agnostic benefits of the macros while also being able to
* enforce that the return value is, in fact, checked.
*/
static inline bool __must_check __must_check_overflow(bool overflow)
static __always_inline bool __must_check __must_check_overflow(bool overflow)
{
return unlikely(overflow);
}
@ -327,7 +327,7 @@ static inline bool __must_check __must_check_overflow(bool overflow)
* with any overflow causing the return value to be SIZE_MAX. The
* lvalue must be size_t to avoid implicit type conversion.
*/
static inline size_t __must_check size_mul(size_t factor1, size_t factor2)
static __always_inline size_t __must_check size_mul(size_t factor1, size_t factor2)
{
size_t bytes;
@ -346,7 +346,7 @@ static inline size_t __must_check size_mul(size_t factor1, size_t factor2)
* with any overflow causing the return value to be SIZE_MAX. The
* lvalue must be size_t to avoid implicit type conversion.
*/
static inline size_t __must_check size_add(size_t addend1, size_t addend2)
static __always_inline size_t __must_check size_add(size_t addend1, size_t addend2)
{
size_t bytes;
@ -367,7 +367,7 @@ static inline size_t __must_check size_add(size_t addend1, size_t addend2)
* argument may be SIZE_MAX (or the result with be forced to SIZE_MAX).
* The lvalue must be size_t to avoid implicit type conversion.
*/
static inline size_t __must_check size_sub(size_t minuend, size_t subtrahend)
static __always_inline size_t __must_check size_sub(size_t minuend, size_t subtrahend)
{
size_t bytes;

View file

@ -153,7 +153,7 @@ config CC_HAS_COUNTED_BY_PTR
config CC_HAS_BROKEN_COUNTED_BY_REF
bool
# https://github.com/llvm/llvm-project/issues/182575
default y if CC_IS_CLANG && CLANG_VERSION < 220000
default y if CC_IS_CLANG && CLANG_VERSION < 220100
config CC_HAS_MULTIDIMENSIONAL_NONSTRING
def_bool $(success,echo 'char tag[][4] __attribute__((__nonstring__)) = { };' | $(CC) $(CLANG_FLAGS) -x c - -c -o /dev/null -Werror)

View file

@ -168,7 +168,7 @@ static bool __report_matches(const struct expect_report *r)
if (!report_available())
return false;
expect = kmalloc_obj(observed.lines);
expect = (typeof(expect))kmalloc_obj(observed.lines);
if (WARN_ON(!expect))
return false;