Skip to content

Commit 48ea09c

Browse files
committed
Merge tag 'hardening-v6.2-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux
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 ...
2 parents ad76bf1 + d272e01 commit 48ea09c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+1533
-463
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
What: /sys/kernel/oops_count
2+
Date: November 2022
3+
KernelVersion: 6.2.0
4+
Contact: Linux Kernel Hardening List <[email protected]>
5+
Description:
6+
Shows how many times the system has Oopsed since last boot.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
What: /sys/kernel/oops_count
2+
Date: November 2022
3+
KernelVersion: 6.2.0
4+
Contact: Linux Kernel Hardening List <[email protected]>
5+
Description:
6+
Shows how many times the system has Warned since last boot.

Documentation/admin-guide/sysctl/kernel.rst

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -670,6 +670,15 @@ This is the default behavior.
670670
an oops event is detected.
671671

672672

673+
oops_limit
674+
==========
675+
676+
Number of kernel oopses after which the kernel should panic when
677+
``panic_on_oops`` is not set. Setting this to 0 disables checking
678+
the count. Setting this to 1 has the same effect as setting
679+
``panic_on_oops=1``. The default value is 10000.
680+
681+
673682
osrelease, ostype & version
674683
===========================
675684

@@ -1526,6 +1535,16 @@ entry will default to 2 instead of 0.
15261535
2 Unprivileged calls to ``bpf()`` are disabled
15271536
= =============================================================
15281537

1538+
1539+
warn_limit
1540+
==========
1541+
1542+
Number of kernel warnings after which the kernel should panic when
1543+
``panic_on_warn`` is not set. Setting this to 0 disables checking
1544+
the warning count. Setting this to 1 has the same effect as setting
1545+
``panic_on_warn=1``. The default value is 0.
1546+
1547+
15291548
watchdog
15301549
========
15311550

Documentation/core-api/kernel-api.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ String Conversions
3636
String Manipulation
3737
-------------------
3838

39+
.. kernel-doc:: include/linux/fortify-string.h
40+
:internal:
41+
3942
.. kernel-doc:: lib/string.c
4043
:export:
4144

MAINTAINERS

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8105,6 +8105,8 @@ S: Supported
81058105
T: git git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git for-next/hardening
81068106
F: include/linux/fortify-string.h
81078107
F: lib/fortify_kunit.c
8108+
F: lib/memcpy_kunit.c
8109+
F: lib/strscpy_kunit.c
81088110
F: lib/test_fortify/*
81098111
F: scripts/test_fortify.sh
81108112
K: \b__NO_FORTIFY\b
@@ -11208,6 +11210,8 @@ M: Kees Cook <[email protected]>
1120811210
1120911211
S: Supported
1121011212
T: git git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git for-next/hardening
11213+
F: Documentation/ABI/testing/sysfs-kernel-oops_count
11214+
F: Documentation/ABI/testing/sysfs-kernel-warn_count
1121111215
F: include/linux/overflow.h
1121211216
F: include/linux/randomize_kstack.h
1121311217
F: mm/usercopy.c
@@ -19050,7 +19054,7 @@ M: Jason A. Donenfeld <[email protected]>
1905019054
S: Maintained
1905119055
F: include/linux/siphash.h
1905219056
F: lib/siphash.c
19053-
F: lib/test_siphash.c
19057+
F: lib/siphash_kunit.c
1905419058

1905519059
SIS 190 ETHERNET DRIVER
1905619060
M: Francois Romieu <[email protected]>

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1120,7 +1120,7 @@ endif
11201120
# We never want expected sections to be placed heuristically by the
11211121
# linker. All sections should be explicitly named in the linker script.
11221122
ifdef CONFIG_LD_ORPHAN_WARN
1123-
LDFLAGS_vmlinux += --orphan-handling=warn
1123+
LDFLAGS_vmlinux += --orphan-handling=$(CONFIG_LD_ORPHAN_WARN_LEVEL)
11241124
endif
11251125

11261126
# Align the bit size of userspace programs with the kernel

arch/arm/boot/compressed/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ LDFLAGS_vmlinux += --no-undefined
124124
LDFLAGS_vmlinux += -X
125125
# Report orphan sections
126126
ifdef CONFIG_LD_ORPHAN_WARN
127-
LDFLAGS_vmlinux += --orphan-handling=warn
127+
LDFLAGS_vmlinux += --orphan-handling=$(CONFIG_LD_ORPHAN_WARN_LEVEL)
128128
endif
129129
# Next argument is a linker script
130130
LDFLAGS_vmlinux += -T

arch/arm64/kernel/vdso/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ ldflags-y := -shared -soname=linux-vdso.so.1 --hash-style=sysv \
2727
-Bsymbolic --build-id=sha1 -n $(btildflags-y)
2828

2929
ifdef CONFIG_LD_ORPHAN_WARN
30-
ldflags-y += --orphan-handling=warn
30+
ldflags-y += --orphan-handling=$(CONFIG_LD_ORPHAN_WARN_LEVEL)
3131
endif
3232

3333
ldflags-y += -T

arch/arm64/kernel/vdso32/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ VDSO_AFLAGS += -D__ASSEMBLY__
104104
VDSO_LDFLAGS += -Bsymbolic --no-undefined -soname=linux-vdso.so.1
105105
VDSO_LDFLAGS += -z max-page-size=4096 -z common-page-size=4096
106106
VDSO_LDFLAGS += -shared --hash-style=sysv --build-id=sha1
107-
VDSO_LDFLAGS += --orphan-handling=warn
107+
VDSO_LDFLAGS += --orphan-handling=$(CONFIG_LD_ORPHAN_WARN_LEVEL)
108108

109109

110110
# Borrow vdsomunge.c from the arm vDSO

arch/um/drivers/virt-pci.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ static int um_pci_send_cmd(struct um_pci_device *dev,
9797
}
9898

9999
buf = get_cpu_var(um_pci_msg_bufs);
100-
memcpy(buf, cmd, cmd_size);
100+
if (buf)
101+
memcpy(buf, cmd, cmd_size);
101102

102103
if (posted) {
103104
u8 *ncmd = kmalloc(cmd_size + extra_size, GFP_ATOMIC);
@@ -182,14 +183,16 @@ static unsigned long um_pci_cfgspace_read(void *priv, unsigned int offset,
182183
struct um_pci_message_buffer *buf;
183184
u8 *data;
184185
unsigned long ret = ULONG_MAX;
186+
size_t bytes = sizeof(buf->data);
185187

186188
if (!dev)
187189
return ULONG_MAX;
188190

189191
buf = get_cpu_var(um_pci_msg_bufs);
190192
data = buf->data;
191193

192-
memset(buf->data, 0xff, sizeof(buf->data));
194+
if (buf)
195+
memset(data, 0xff, bytes);
193196

194197
switch (size) {
195198
case 1:
@@ -204,7 +207,7 @@ static unsigned long um_pci_cfgspace_read(void *priv, unsigned int offset,
204207
goto out;
205208
}
206209

207-
if (um_pci_send_cmd(dev, &hdr, sizeof(hdr), NULL, 0, data, 8))
210+
if (um_pci_send_cmd(dev, &hdr, sizeof(hdr), NULL, 0, data, bytes))
208211
goto out;
209212

210213
switch (size) {

0 commit comments

Comments
 (0)