Skip to content

Commit 3f4a08e

Browse files
committed
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
2 parents e3c81ba + 7954698 commit 3f4a08e

4 files changed

Lines changed: 11 additions & 11 deletions

File tree

arch/um/drivers/ubd_kern.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,11 @@ struct io_thread_req {
6969
};
7070

7171

72-
static struct io_thread_req * (*irq_req_buffer)[];
72+
static struct io_thread_req **irq_req_buffer;
7373
static struct io_thread_req *irq_remainder;
7474
static int irq_remainder_size;
7575

76-
static struct io_thread_req * (*io_req_buffer)[];
76+
static struct io_thread_req **io_req_buffer;
7777
static struct io_thread_req *io_remainder;
7878
static int io_remainder_size;
7979

@@ -398,7 +398,7 @@ static int thread_fd = -1;
398398

399399
static int bulk_req_safe_read(
400400
int fd,
401-
struct io_thread_req * (*request_buffer)[],
401+
struct io_thread_req **request_buffer,
402402
struct io_thread_req **remainder,
403403
int *remainder_size,
404404
int max_recs
@@ -465,7 +465,7 @@ static irqreturn_t ubd_intr(int irq, void *dev)
465465
&irq_remainder, &irq_remainder_size,
466466
UBD_REQ_BUFFER_SIZE)) >= 0) {
467467
for (i = 0; i < len / sizeof(struct io_thread_req *); i++)
468-
ubd_end_request((*irq_req_buffer)[i]);
468+
ubd_end_request(irq_req_buffer[i]);
469469
}
470470

471471
if (len < 0 && len != -EAGAIN)
@@ -1512,7 +1512,7 @@ void *io_thread(void *arg)
15121512
}
15131513

15141514
for (count = 0; count < n/sizeof(struct io_thread_req *); count++) {
1515-
struct io_thread_req *req = (*io_req_buffer)[count];
1515+
struct io_thread_req *req = io_req_buffer[count];
15161516
int i;
15171517

15181518
io_count++;

include/linux/overflow.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
* both the type-agnostic benefits of the macros while also being able to
4343
* enforce that the return value is, in fact, checked.
4444
*/
45-
static inline bool __must_check __must_check_overflow(bool overflow)
45+
static __always_inline bool __must_check __must_check_overflow(bool overflow)
4646
{
4747
return unlikely(overflow);
4848
}
@@ -327,7 +327,7 @@ static inline bool __must_check __must_check_overflow(bool overflow)
327327
* with any overflow causing the return value to be SIZE_MAX. The
328328
* lvalue must be size_t to avoid implicit type conversion.
329329
*/
330-
static inline size_t __must_check size_mul(size_t factor1, size_t factor2)
330+
static __always_inline size_t __must_check size_mul(size_t factor1, size_t factor2)
331331
{
332332
size_t bytes;
333333

@@ -346,7 +346,7 @@ static inline size_t __must_check size_mul(size_t factor1, size_t factor2)
346346
* with any overflow causing the return value to be SIZE_MAX. The
347347
* lvalue must be size_t to avoid implicit type conversion.
348348
*/
349-
static inline size_t __must_check size_add(size_t addend1, size_t addend2)
349+
static __always_inline size_t __must_check size_add(size_t addend1, size_t addend2)
350350
{
351351
size_t bytes;
352352

@@ -367,7 +367,7 @@ static inline size_t __must_check size_add(size_t addend1, size_t addend2)
367367
* argument may be SIZE_MAX (or the result with be forced to SIZE_MAX).
368368
* The lvalue must be size_t to avoid implicit type conversion.
369369
*/
370-
static inline size_t __must_check size_sub(size_t minuend, size_t subtrahend)
370+
static __always_inline size_t __must_check size_sub(size_t minuend, size_t subtrahend)
371371
{
372372
size_t bytes;
373373

init/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ config CC_HAS_COUNTED_BY_PTR
153153
config CC_HAS_BROKEN_COUNTED_BY_REF
154154
bool
155155
# https://github.com/llvm/llvm-project/issues/182575
156-
default y if CC_IS_CLANG && CLANG_VERSION < 220000
156+
default y if CC_IS_CLANG && CLANG_VERSION < 220100
157157

158158
config CC_HAS_MULTIDIMENSIONAL_NONSTRING
159159
def_bool $(success,echo 'char tag[][4] __attribute__((__nonstring__)) = { };' | $(CC) $(CLANG_FLAGS) -x c - -c -o /dev/null -Werror)

kernel/kcsan/kcsan_test.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ static bool __report_matches(const struct expect_report *r)
168168
if (!report_available())
169169
return false;
170170

171-
expect = kmalloc_obj(observed.lines);
171+
expect = (typeof(expect))kmalloc_obj(observed.lines);
172172
if (WARN_ON(!expect))
173173
return false;
174174

0 commit comments

Comments
 (0)