Skip to content
  1. Nov 09, 2023
    • Arnd Bergmann's avatar
      stackleak: add declarations for global functions · 65120498
      Arnd Bergmann authored
      
      
      With -Wmissing-prototypes enabled, the stackleak code produces a couple of
      warnings that have no declarations because they are only called from assembler:
      
      stackleak.c:127:25: error: no previous prototype for 'stackleak_erase' [-Werror=missing-prototypes]
      stackleak.c:139:25: error: no previous prototype for 'stackleak_erase_on_task_stack' [-Werror=missing-prototypes]
      stackleak.c:151:25: error: no previous prototype for 'stackleak_erase_off_task_stack' [-Werror=missing-prototypes]
      stackleak.c:159:49: error: no previous prototype for 'stackleak_track_stack' [-Werror=missing-prototypes]
      
      Add declarations to the stackleak header to shut up the warnings.
      
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Link: https://lore.kernel.org/r/20231108125843.3806765-7-arnd@kernel.org
      
      
      Signed-off-by: default avatarKees Cook <keescook@chromium.org>
      65120498
  2. Oct 25, 2023
  3. Oct 21, 2023
  4. Oct 19, 2023
    • Kees Cook's avatar
      string: Adjust strtomem() logic to allow for smaller sources · 0e108725
      Kees Cook authored
      
      
      Arnd noticed we have a case where a shorter source string is being copied
      into a destination byte array, but this results in a strnlen() call that
      exceeds the size of the source. This is seen with -Wstringop-overread:
      
      In file included from ../include/linux/uuid.h:11,
                       from ../include/linux/mod_devicetable.h:14,
                       from ../include/linux/cpufeature.h:12,
                       from ../arch/x86/coco/tdx/tdx.c:7:
      ../arch/x86/coco/tdx/tdx.c: In function 'tdx_panic.constprop':
      ../include/linux/string.h:284:9: error: 'strnlen' specified bound 64 exceeds source size 60 [-Werror=stringop-overread]
        284 |         memcpy_and_pad(dest, _dest_len, src, strnlen(src, _dest_len), pad); \
            |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      ../arch/x86/coco/tdx/tdx.c:124:9: note: in expansion of macro 'strtomem_pad'
        124 |         strtomem_pad(message.str, msg, '\0');
            |         ^~~~~~~~~~~~
      
      Use the smaller of the two buffer sizes when calling strnlen(). When
      src length is unknown (SIZE_MAX), it is adjusted to use dest length,
      which is what the original code did.
      
      Reported-by: default avatarArnd Bergmann <arnd@arndb.de>
      Fixes: dfbafa70
      
       ("string: Introduce strtomem() and strtomem_pad()")
      Tested-by: default avatarArnd Bergmann <arnd@arndb.de>
      Cc: Andy Shevchenko <andy@kernel.org>
      Cc: linux-hardening@vger.kernel.org
      Signed-off-by: default avatarKees Cook <keescook@chromium.org>
      0e108725
  5. Oct 13, 2023
  6. Oct 09, 2023
  7. Oct 07, 2023
  8. Oct 03, 2023
  9. Sep 30, 2023