Skip to content

Commit

Permalink
Merge tag 'hardening-v6.10-rc5' of git://git.kernel.org/pub/scm/linux…
Browse files Browse the repository at this point in the history
…/kernel/git/kees/linux

Pull hardening fixes from Kees Cook:

 - yama: document function parameter (Christian Göttsche)

 - mm/util: Swap kmemdup_array() arguments (Jean-Philippe Brucker)

 - kunit/overflow: Adjust for __counted_by with DEFINE_RAW_FLEX()

 - MAINTAINERS: Update entries for Kees Cook

* tag 'hardening-v6.10-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux:
  MAINTAINERS: Update entries for Kees Cook
  kunit/overflow: Adjust for __counted_by with DEFINE_RAW_FLEX()
  yama: document function parameter
  mm/util: Swap kmemdup_array() arguments
  • Loading branch information
torvalds committed Jun 17, 2024
2 parents 6226e74 + 1ab1a42 commit 5cf81d7
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 23 deletions.
28 changes: 14 additions & 14 deletions MAINTAINERS
Original file line number Diff line number Diff line change
Expand Up @@ -5295,7 +5295,7 @@ F: drivers/infiniband/hw/usnic/

CLANG CONTROL FLOW INTEGRITY SUPPORT
M: Sami Tolvanen <[email protected]>
M: Kees Cook <keescook@chromium.org>
M: Kees Cook <kees@kernel.org>
R: Nathan Chancellor <[email protected]>
L: [email protected]
S: Supported
Expand Down Expand Up @@ -8211,7 +8211,7 @@ F: rust/kernel/net/phy.rs

EXEC & BINFMT API, ELF
R: Eric Biederman <[email protected]>
R: Kees Cook <keescook@chromium.org>
R: Kees Cook <kees@kernel.org>
L: [email protected]
S: Supported
T: git git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git for-next/execve
Expand Down Expand Up @@ -8612,7 +8612,7 @@ S: Maintained
F: drivers/net/ethernet/nvidia/*

FORTIFY_SOURCE
M: Kees Cook <keescook@chromium.org>
M: Kees Cook <kees@kernel.org>
L: [email protected]
S: Supported
T: git git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git for-next/hardening
Expand Down Expand Up @@ -9102,7 +9102,7 @@ F: include/linux/mfd/gsc.h
F: include/linux/platform_data/gsc_hwmon.h

GCC PLUGINS
M: Kees Cook <keescook@chromium.org>
M: Kees Cook <kees@kernel.org>
L: [email protected]
S: Maintained
T: git git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git for-next/hardening
Expand Down Expand Up @@ -9236,7 +9236,7 @@ S: Maintained
F: drivers/input/touchscreen/resistive-adc-touch.c

GENERIC STRING LIBRARY
M: Kees Cook <keescook@chromium.org>
M: Kees Cook <kees@kernel.org>
R: Andy Shevchenko <[email protected]>
L: [email protected]
S: Supported
Expand Down Expand Up @@ -11950,7 +11950,7 @@ F: scripts/package/
F: usr/

KERNEL HARDENING (not covered by other areas)
M: Kees Cook <keescook@chromium.org>
M: Kees Cook <kees@kernel.org>
R: Gustavo A. R. Silva <[email protected]>
L: [email protected]
S: Supported
Expand Down Expand Up @@ -12478,7 +12478,7 @@ F: drivers/scsi/53c700*

LEAKING_ADDRESSES
M: Tycho Andersen <[email protected]>
R: Kees Cook <keescook@chromium.org>
R: Kees Cook <kees@kernel.org>
L: [email protected]
S: Maintained
T: git git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git for-next/hardening
Expand Down Expand Up @@ -12774,7 +12774,7 @@ F: arch/powerpc/platforms/8xx/
F: arch/powerpc/platforms/83xx/

LINUX KERNEL DUMP TEST MODULE (LKDTM)
M: Kees Cook <keescook@chromium.org>
M: Kees Cook <kees@kernel.org>
S: Maintained
F: drivers/misc/lkdtm/*
F: tools/testing/selftests/lkdtm/*
Expand Down Expand Up @@ -12904,7 +12904,7 @@ Q: http://patchwork.linuxtv.org/project/linux-media/list/
F: drivers/media/usb/dvb-usb-v2/lmedm04*

LOADPIN SECURITY MODULE
M: Kees Cook <keescook@chromium.org>
M: Kees Cook <kees@kernel.org>
S: Supported
T: git git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git for-next/hardening
F: Documentation/admin-guide/LSM/LoadPin.rst
Expand Down Expand Up @@ -17996,7 +17996,7 @@ F: tools/testing/selftests/proc/

PROC SYSCTL
M: Luis Chamberlain <[email protected]>
M: Kees Cook <keescook@chromium.org>
M: Kees Cook <kees@kernel.org>
M: Joel Granados <[email protected]>
L: [email protected]
L: [email protected]
Expand Down Expand Up @@ -18052,7 +18052,7 @@ F: Documentation/devicetree/bindings/net/pse-pd/
F: drivers/net/pse-pd/

PSTORE FILESYSTEM
M: Kees Cook <keescook@chromium.org>
M: Kees Cook <kees@kernel.org>
R: Tony Luck <[email protected]>
R: Guilherme G. Piccoli <[email protected]>
L: [email protected]
Expand Down Expand Up @@ -20058,7 +20058,7 @@ F: drivers/media/cec/platform/seco/seco-cec.c
F: drivers/media/cec/platform/seco/seco-cec.h

SECURE COMPUTING
M: Kees Cook <keescook@chromium.org>
M: Kees Cook <kees@kernel.org>
R: Andy Lutomirski <[email protected]>
R: Will Drewry <[email protected]>
S: Supported
Expand Down Expand Up @@ -22972,7 +22972,7 @@ F: drivers/block/ublk_drv.c
F: include/uapi/linux/ublk_cmd.h

UBSAN
M: Kees Cook <keescook@chromium.org>
M: Kees Cook <kees@kernel.org>
R: Marco Elver <[email protected]>
R: Andrey Konovalov <[email protected]>
R: Andrey Ryabinin <[email protected]>
Expand Down Expand Up @@ -24810,7 +24810,7 @@ F: drivers/net/hamradio/yam*
F: include/linux/yam.h

YAMA SECURITY MODULE
M: Kees Cook <keescook@chromium.org>
M: Kees Cook <kees@kernel.org>
S: Supported
T: git git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git for-next/hardening
F: Documentation/admin-guide/LSM/Yama.rst
Expand Down
4 changes: 2 additions & 2 deletions drivers/soc/tegra/fuse/fuse-tegra.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ static void tegra_fuse_print_sku_info(struct tegra_sku_info *tegra_sku_info)

static int tegra_fuse_add_lookups(struct tegra_fuse *fuse)
{
fuse->lookups = kmemdup_array(fuse->soc->lookups, sizeof(*fuse->lookups),
fuse->soc->num_lookups, GFP_KERNEL);
fuse->lookups = kmemdup_array(fuse->soc->lookups, fuse->soc->num_lookups,
sizeof(*fuse->lookups), GFP_KERNEL);
if (!fuse->lookups)
return -ENOMEM;

Expand Down
2 changes: 1 addition & 1 deletion include/linux/string.h
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ extern void *kmemdup_noprof(const void *src, size_t len, gfp_t gfp) __realloc_si

extern void *kvmemdup(const void *src, size_t len, gfp_t gfp) __realloc_size(2);
extern char *kmemdup_nul(const char *s, size_t len, gfp_t gfp);
extern void *kmemdup_array(const void *src, size_t element_size, size_t count, gfp_t gfp)
extern void *kmemdup_array(const void *src, size_t count, size_t element_size, gfp_t gfp)
__realloc_size(2, 3);

/* lib/argv_split.c */
Expand Down
2 changes: 1 addition & 1 deletion lib/fortify_kunit.c
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ static const char * const test_strs[] = {
for (i = 0; i < ARRAY_SIZE(test_strs); i++) { \
len = strlen(test_strs[i]); \
KUNIT_EXPECT_EQ(test, __builtin_constant_p(len), 0); \
checker(len, kmemdup_array(test_strs[i], len, 1, gfp), \
checker(len, kmemdup_array(test_strs[i], 1, len, gfp), \
kfree(p)); \
checker(len, kmemdup(test_strs[i], len, gfp), \
kfree(p)); \
Expand Down
20 changes: 17 additions & 3 deletions lib/overflow_kunit.c
Original file line number Diff line number Diff line change
Expand Up @@ -1178,14 +1178,28 @@ struct foo {
s16 array[] __counted_by(counter);
};

struct bar {
int a;
u32 counter;
s16 array[];
};

static void DEFINE_FLEX_test(struct kunit *test)
{
DEFINE_RAW_FLEX(struct foo, two, array, 2);
/* Using _RAW_ on a __counted_by struct will initialize "counter" to zero */
DEFINE_RAW_FLEX(struct foo, two_but_zero, array, 2);
#if __has_attribute(__counted_by__)
int expected_raw_size = sizeof(struct foo);
#else
int expected_raw_size = sizeof(struct foo) + 2 * sizeof(s16);
#endif
/* Without annotation, it will always be on-stack size. */
DEFINE_RAW_FLEX(struct bar, two, array, 2);
DEFINE_FLEX(struct foo, eight, array, counter, 8);
DEFINE_FLEX(struct foo, empty, array, counter, 0);

KUNIT_EXPECT_EQ(test, __struct_size(two),
sizeof(struct foo) + sizeof(s16) + sizeof(s16));
KUNIT_EXPECT_EQ(test, __struct_size(two_but_zero), expected_raw_size);
KUNIT_EXPECT_EQ(test, __struct_size(two), sizeof(struct bar) + 2 * sizeof(s16));
KUNIT_EXPECT_EQ(test, __struct_size(eight), 24);
KUNIT_EXPECT_EQ(test, __struct_size(empty), sizeof(struct foo));
}
Expand Down
4 changes: 2 additions & 2 deletions mm/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,14 +139,14 @@ EXPORT_SYMBOL(kmemdup_noprof);
* kmemdup_array - duplicate a given array.
*
* @src: array to duplicate.
* @element_size: size of each element of array.
* @count: number of elements to duplicate from array.
* @element_size: size of each element of array.
* @gfp: GFP mask to use.
*
* Return: duplicated array of @src or %NULL in case of error,
* result is physically contiguous. Use kfree() to free.
*/
void *kmemdup_array(const void *src, size_t element_size, size_t count, gfp_t gfp)
void *kmemdup_array(const void *src, size_t count, size_t element_size, gfp_t gfp)
{
return kmemdup(src, size_mul(element_size, count), gfp);
}
Expand Down
1 change: 1 addition & 0 deletions security/yama/yama_lsm.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ static void report_access(const char *access, struct task_struct *target,

/**
* yama_relation_cleanup - remove invalid entries from the relation list
* @work: unused
*
*/
static void yama_relation_cleanup(struct work_struct *work)
Expand Down

0 comments on commit 5cf81d7

Please sign in to comment.