Merge tag 'hardening-v6.5-rc1-fixes' of git://git.kernel.org/pub/scm/linux/kernel...
authorLinus Torvalds <torvalds@linux-foundation.org>
Sat, 8 Jul 2023 19:08:39 +0000 (12:08 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Sat, 8 Jul 2023 19:08:39 +0000 (12:08 -0700)
Pull hardening fixes from Kees Cook:

 - Check for NULL bdev in LoadPin (Matthias Kaehlcke)

 - Revert unwanted KUnit FORTIFY build default

 - Fix 1-element array causing boot warnings with xhci-hub

* tag 'hardening-v6.5-rc1-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux:
  usb: ch9: Replace bmSublinkSpeedAttr 1-element array with flexible array
  Revert "fortify: Allow KUnit test to build without FORTIFY"
  dm: verity-loadpin: Add NULL pointer check for 'bdev' parameter

drivers/md/dm-verity-loadpin.c
include/uapi/linux/usb/ch9.h
lib/Kconfig.debug
lib/fortify_kunit.c

index 4f78cc55c2514e6329d9780939d320e53faa743d..0666699b6858166227131e17a0da99e5ae22a4c2 100644 (file)
@@ -58,6 +58,9 @@ bool dm_verity_loadpin_is_bdev_trusted(struct block_device *bdev)
        int srcu_idx;
        bool trusted = false;
 
+       if (bdev == NULL)
+               return false;
+
        if (list_empty(&dm_verity_loadpin_trusted_root_digests))
                return false;
 
index 82ec6af71a1d11c89fea07fceff5f4e49d2911f0..62d318377379e1b03869db1256781cf33ff28c4a 100644 (file)
@@ -984,7 +984,11 @@ struct usb_ssp_cap_descriptor {
 #define USB_SSP_MIN_RX_LANE_COUNT              (0xf << 8)
 #define USB_SSP_MIN_TX_LANE_COUNT              (0xf << 12)
        __le16 wReserved;
-       __le32 bmSublinkSpeedAttr[1]; /* list of sublink speed attrib entries */
+       union {
+               __le32 legacy_padding;
+               /* list of sublink speed attrib entries */
+               __DECLARE_FLEX_ARRAY(__le32, bmSublinkSpeedAttr);
+       };
 #define USB_SSP_SUBLINK_SPEED_SSID     (0xf)           /* sublink speed ID */
 #define USB_SSP_SUBLINK_SPEED_LSE      (0x3 << 4)      /* Lanespeed exponent */
 #define USB_SSP_SUBLINK_SPEED_LSE_BPS          0
index 781f061ec0fa72ec053e6b2a2b77d09564e10a94..fbc89baf7de645c12f137ba488acf16963e9f249 100644 (file)
@@ -2739,7 +2739,7 @@ config STACKINIT_KUNIT_TEST
 
 config FORTIFY_KUNIT_TEST
        tristate "Test fortified str*() and mem*() function internals at runtime" if !KUNIT_ALL_TESTS
-       depends on KUNIT
+       depends on KUNIT && FORTIFY_SOURCE
        default KUNIT_ALL_TESTS
        help
          Builds unit tests for checking internals of FORTIFY_SOURCE as used
index 524132f33cf0ae58ff9508c83ca356db9a9fdb43..c8c33cbaae9ec9d17bf5f7aef590be20943ce0b1 100644 (file)
@@ -25,11 +25,6 @@ static const char array_of_10[] = "this is 10";
 static const char *ptr_of_11 = "this is 11!";
 static char array_unknown[] = "compiler thinks I might change";
 
-/* Handle being built without CONFIG_FORTIFY_SOURCE */
-#ifndef __compiletime_strlen
-# define __compiletime_strlen __builtin_strlen
-#endif
-
 static void known_sizes_test(struct kunit *test)
 {
        KUNIT_EXPECT_EQ(test, __compiletime_strlen("88888888"), 8);
@@ -312,14 +307,6 @@ DEFINE_ALLOC_SIZE_TEST_PAIR(kvmalloc)
 } while (0)
 DEFINE_ALLOC_SIZE_TEST_PAIR(devm_kmalloc)
 
-static int fortify_test_init(struct kunit *test)
-{
-       if (!IS_ENABLED(CONFIG_FORTIFY_SOURCE))
-               kunit_skip(test, "Not built with CONFIG_FORTIFY_SOURCE=y");
-
-       return 0;
-}
-
 static struct kunit_case fortify_test_cases[] = {
        KUNIT_CASE(known_sizes_test),
        KUNIT_CASE(control_flow_split_test),
@@ -336,7 +323,6 @@ static struct kunit_case fortify_test_cases[] = {
 
 static struct kunit_suite fortify_test_suite = {
        .name = "fortify",
-       .init = fortify_test_init,
        .test_cases = fortify_test_cases,
 };