Merge tag 'hardening-v6.2-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/kees...
authorLinus Torvalds <torvalds@linux-foundation.org>
Wed, 14 Dec 2022 20:20:00 +0000 (12:20 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Wed, 14 Dec 2022 20:20:00 +0000 (12:20 -0800)
Pull kernel hardening updates from Kees Cook:

 - Convert flexible array members, fix -Wstringop-overflow warnings, and
   fix KCFI function type mismatches that went ignored by maintainers
   (Gustavo A. R. Silva, Nathan Chancellor, Kees Cook)

 - Remove the remaining side-effect users of ksize() by converting
   dma-buf, btrfs, and coredump to using kmalloc_size_roundup(), add
   more __alloc_size attributes, and introduce full testing of all
   allocator functions. Finally remove the ksize() side-effect so that
   each allocation-aware checker can finally behave without exceptions

 - Introduce oops_limit (default 10,000) and warn_limit (default off) to
   provide greater granularity of control for panic_on_oops and
   panic_on_warn (Jann Horn, Kees Cook)

 - Introduce overflows_type() and castable_to_type() helpers for cleaner
   overflow checking

 - Improve code generation for strscpy() and update str*() kern-doc

 - Convert strscpy and sigphash tests to KUnit, and expand memcpy tests

 - Always use a non-NULL argument for prepare_kernel_cred()

 - Disable structleak plugin in FORTIFY KUnit test (Anders Roxell)

 - Adjust orphan linker section checking to respect CONFIG_WERROR (Xin
   Li)

 - Make sure siginfo is cleared for forced SIGKILL (haifeng.xu)

 - Fix um vs FORTIFY warnings for always-NULL arguments

* tag 'hardening-v6.2-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux: (31 commits)
  ksmbd: replace one-element arrays with flexible-array members
  hpet: Replace one-element array with flexible-array member
  um: virt-pci: Avoid GCC non-NULL warning
  signal: Initialize the info in ksignal
  lib: fortify_kunit: build without structleak plugin
  panic: Expose "warn_count" to sysfs
  panic: Introduce warn_limit
  panic: Consolidate open-coded panic_on_warn checks
  exit: Allow oops_limit to be disabled
  exit: Expose "oops_count" to sysfs
  exit: Put an upper limit on how often we can oops
  panic: Separate sysctl logic from CONFIG_SMP
  mm/pgtable: Fix multiple -Wstringop-overflow warnings
  mm: Make ksize() a reporting-only function
  kunit/fortify: Validate __alloc_size attribute results
  drm/sti: Fix return type of sti_{dvo,hda,hdmi}_connector_mode_valid()
  drm/fsl-dcu: Fix return type of fsl_dcu_drm_connector_mode_valid()
  driver core: Add __alloc_size hint to devm allocators
  overflow: Introduce overflows_type() and castable_to_type()
  coredump: Proactively round up to kmalloc bucket size
  ...

28 files changed:
1  2 
Documentation/admin-guide/sysctl/kernel.rst
Documentation/core-api/kernel-api.rst
MAINTAINERS
Makefile
arch/arm/boot/compressed/Makefile
arch/x86/boot/compressed/Makefile
drivers/gpu/drm/sti/sti_dvo.c
drivers/gpu/drm/sti/sti_hda.c
drivers/gpu/drm/sti/sti_hdmi.c
fs/btrfs/send.c
fs/cifs/cifsacl.c
fs/coredump.c
fs/ksmbd/smb2pdu.c
fs/nfsd/nfs4callback.c
include/linux/device.h
include/linux/fortify-string.h
init/Kconfig
kernel/panic.c
kernel/sched/core.c
kernel/signal.c
lib/Kconfig.debug
lib/Makefile
lib/memcpy_kunit.c
mm/kasan/kasan_test.c
mm/kasan/report.c
mm/kfence/report.c
mm/slab_common.c
scripts/kernel-doc

Simple merge
diff --cc MAINTAINERS
Simple merge
diff --cc Makefile
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
diff --cc fs/btrfs/send.c
Simple merge
Simple merge
diff --cc fs/coredump.c
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
diff --cc init/Kconfig
Simple merge
diff --cc kernel/panic.c
Simple merge
Simple merge
diff --cc kernel/signal.c
Simple merge
Simple merge
diff --cc lib/Makefile
index 59bd7c2f793a7e937c815019181a2105f1cf5f2f,83c650bb4459f6a7336739ac5910494341841fce..4d9461bfea42c6792f06e2e9dc2fabe0787f02df
@@@ -82,10 -81,8 +81,9 @@@ obj-$(CONFIG_TEST_DYNAMIC_DEBUG) += tes
  obj-$(CONFIG_TEST_PRINTF) += test_printf.o
  obj-$(CONFIG_TEST_SCANF) += test_scanf.o
  obj-$(CONFIG_TEST_BITMAP) += test_bitmap.o
- obj-$(CONFIG_TEST_STRSCPY) += test_strscpy.o
  obj-$(CONFIG_TEST_UUID) += test_uuid.o
  obj-$(CONFIG_TEST_XARRAY) += test_xarray.o
 +obj-$(CONFIG_TEST_MAPLE_TREE) += test_maple_tree.o
  obj-$(CONFIG_TEST_PARMAN) += test_parman.o
  obj-$(CONFIG_TEST_KMOD) += test_kmod.o
  obj-$(CONFIG_TEST_DEBUG_VIRTUAL) += test_debug_virtual.o
Simple merge
Simple merge
Simple merge
Simple merge
index 3e49bb8300609278dbd1402d1f3f5d9b418d372b,7e96abf1bd7d18192a3b0a73d6ec83ea731d59c6..1cba98acc486251705096ae84238156355a4d374
@@@ -1426,15 -1413,27 +1428,13 @@@ void kfree_sensitive(const void *p
  }
  EXPORT_SYMBOL(kfree_sensitive);
  
 -/**
 - * ksize - get the actual amount of memory allocated for a given object
 - * @objp: Pointer to the object
 - *
 - * kmalloc may internally round up allocations and return more memory
 - * than requested. ksize() can be used to determine the actual amount of
 - * memory allocated. The caller may use this additional memory, even though
 - * a smaller amount of memory was initially specified with the kmalloc call.
 - * The caller must guarantee that objp points to a valid object previously
 - * allocated with either kmalloc() or kmem_cache_alloc(). The object
 - * must not be freed during the duration of the call.
 - *
 - * Return: size of the actual memory used by @objp in bytes
 - */
  size_t ksize(const void *objp)
  {
-       size_t size;
        /*
-        * We need to first check that the pointer to the object is valid, and
-        * only then unpoison the memory. The report printed from ksize() is
-        * more useful, then when it's printed later when the behaviour could
-        * be undefined due to a potential use-after-free or double-free.
+        * We need to first check that the pointer to the object is valid.
+        * The KASAN report printed from ksize() is more useful, then when
+        * it's printed later when the behaviour could be undefined due to
+        * a potential use-after-free or double-free.
         *
         * We use kasan_check_byte(), which is supported for the hardware
         * tag-based KASAN mode, unlike kasan_check_read/write().
Simple merge