Skip to content

Commit 880ca43

Browse files
committed
Merge tag 'hardening-v6.2-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux
Pull kernel hardening fixes from Kees Cook: - Fix CFI hash randomization with KASAN (Sami Tolvanen) - Check size of coreboot table entry and use flex-array * tag 'hardening-v6.2-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux: kbuild: Fix CFI hash randomization with KASAN firmware: coreboot: Check size of table entry and use flex-array
2 parents 8b7be52 + 42633ed commit 880ca43

File tree

4 files changed

+10
-2
lines changed

4 files changed

+10
-2
lines changed

drivers/firmware/google/coreboot_table.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,14 +93,19 @@ static int coreboot_table_populate(struct device *dev, void *ptr)
9393
for (i = 0; i < header->table_entries; i++) {
9494
entry = ptr_entry;
9595

96-
device = kzalloc(sizeof(struct device) + entry->size, GFP_KERNEL);
96+
if (entry->size < sizeof(*entry)) {
97+
dev_warn(dev, "coreboot table entry too small!\n");
98+
return -EINVAL;
99+
}
100+
101+
device = kzalloc(sizeof(device->dev) + entry->size, GFP_KERNEL);
97102
if (!device)
98103
return -ENOMEM;
99104

100105
device->dev.parent = dev;
101106
device->dev.bus = &coreboot_bus_type;
102107
device->dev.release = coreboot_device_release;
103-
memcpy(&device->entry, ptr_entry, entry->size);
108+
memcpy(device->raw, ptr_entry, entry->size);
104109

105110
switch (device->entry.tag) {
106111
case LB_TAG_CBMEM_ENTRY:

drivers/firmware/google/coreboot_table.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ struct coreboot_device {
7979
struct lb_cbmem_ref cbmem_ref;
8080
struct lb_cbmem_entry cbmem_entry;
8181
struct lb_framebuffer framebuffer;
82+
DECLARE_FLEX_ARRAY(u8, raw);
8283
};
8384
};
8485

init/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,4 @@ include/generated/utsversion.h: FORCE
5959

6060
$(obj)/version-timestamp.o: include/generated/utsversion.h
6161
CFLAGS_version-timestamp.o := -include include/generated/utsversion.h
62+
KASAN_SANITIZE_version-timestamp.o := n

scripts/Makefile.vmlinux

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ quiet_cmd_cc_o_c = CC $@
1818
$(call if_changed_dep,cc_o_c)
1919

2020
ifdef CONFIG_MODULES
21+
KASAN_SANITIZE_.vmlinux.export.o := n
2122
targets += .vmlinux.export.o
2223
vmlinux: .vmlinux.export.o
2324
endif

0 commit comments

Comments
 (0)