Skip to content

Commit 9d9a9bf

Browse files
committed
Merge tag 's390-6.4-4' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux
Pull s390 updates from Alexander Gordeev: - Use correct type for size of memory allocated for ELF core header on kernel crash. - Fix insecure W+X mapping warning when KASAN shadow memory range is not aligned on page boundary. - Avoid allocation of short by one page KASAN shadow memory when the original memory range is less than (PAGE_SIZE << 3). - Fix virtual vs physical address confusion in physical memory enumerator. It is not a real issue, since virtual and physical addresses are currently the same. - Set CONFIG_NET_TC_SKB_EXT=y in s390 config files as it is required for offloading TC as well as bridges on switchdev capable ConnectX devices. * tag 's390-6.4-4' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux: s390/defconfigs: set CONFIG_NET_TC_SKB_EXT=y s390/boot: fix physmem_info virtual vs physical address confusion s390/kasan: avoid short by one page shadow memory s390/kasan: fix insecure W+X mapping warning s390/crash: use the correct type for memory allocation
2 parents be5b52d + ad3d770 commit 9d9a9bf

File tree

6 files changed

+27
-11
lines changed

6 files changed

+27
-11
lines changed

arch/s390/boot/vmem.c

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,13 @@ static void pgtable_populate(unsigned long addr, unsigned long end, enum populat
4545

4646
static pte_t pte_z;
4747

48+
static inline void kasan_populate(unsigned long start, unsigned long end, enum populate_mode mode)
49+
{
50+
start = PAGE_ALIGN_DOWN(__sha(start));
51+
end = PAGE_ALIGN(__sha(end));
52+
pgtable_populate(start, end, mode);
53+
}
54+
4855
static void kasan_populate_shadow(void)
4956
{
5057
pmd_t pmd_z = __pmd(__pa(kasan_early_shadow_pte) | _SEGMENT_ENTRY);
@@ -95,17 +102,17 @@ static void kasan_populate_shadow(void)
95102
*/
96103

97104
for_each_physmem_usable_range(i, &start, &end)
98-
pgtable_populate(__sha(start), __sha(end), POPULATE_KASAN_MAP_SHADOW);
105+
kasan_populate(start, end, POPULATE_KASAN_MAP_SHADOW);
99106
if (IS_ENABLED(CONFIG_KASAN_VMALLOC)) {
100107
untracked_end = VMALLOC_START;
101108
/* shallowly populate kasan shadow for vmalloc and modules */
102-
pgtable_populate(__sha(VMALLOC_START), __sha(MODULES_END), POPULATE_KASAN_SHALLOW);
109+
kasan_populate(VMALLOC_START, MODULES_END, POPULATE_KASAN_SHALLOW);
103110
} else {
104111
untracked_end = MODULES_VADDR;
105112
}
106113
/* populate kasan shadow for untracked memory */
107-
pgtable_populate(__sha(ident_map_size), __sha(untracked_end), POPULATE_KASAN_ZERO_SHADOW);
108-
pgtable_populate(__sha(MODULES_END), __sha(_REGION1_SIZE), POPULATE_KASAN_ZERO_SHADOW);
114+
kasan_populate(ident_map_size, untracked_end, POPULATE_KASAN_ZERO_SHADOW);
115+
kasan_populate(MODULES_END, _REGION1_SIZE, POPULATE_KASAN_ZERO_SHADOW);
109116
}
110117

111118
static bool kasan_pgd_populate_zero_shadow(pgd_t *pgd, unsigned long addr,

arch/s390/configs/debug_defconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ CONFIG_UNIX=y
116116
CONFIG_UNIX_DIAG=m
117117
CONFIG_XFRM_USER=m
118118
CONFIG_NET_KEY=m
119+
CONFIG_NET_TC_SKB_EXT=y
119120
CONFIG_SMC=m
120121
CONFIG_SMC_DIAG=m
121122
CONFIG_INET=y

arch/s390/configs/defconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ CONFIG_UNIX=y
107107
CONFIG_UNIX_DIAG=m
108108
CONFIG_XFRM_USER=m
109109
CONFIG_NET_KEY=m
110+
CONFIG_NET_TC_SKB_EXT=y
110111
CONFIG_SMC=m
111112
CONFIG_SMC_DIAG=m
112113
CONFIG_INET=y

arch/s390/include/asm/physmem_info.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#define _ASM_S390_MEM_DETECT_H
44

55
#include <linux/types.h>
6+
#include <asm/page.h>
67

78
enum physmem_info_source {
89
MEM_DETECT_NONE = 0,
@@ -133,7 +134,7 @@ static inline const char *get_rr_type_name(enum reserved_range_type t)
133134

134135
#define for_each_physmem_reserved_type_range(t, range, p_start, p_end) \
135136
for (range = &physmem_info.reserved[t], *p_start = range->start, *p_end = range->end; \
136-
range && range->end; range = range->chain, \
137+
range && range->end; range = range->chain ? __va(range->chain) : NULL, \
137138
*p_start = range ? range->start : 0, *p_end = range ? range->end : 0)
138139

139140
static inline struct reserved_range *__physmem_reserved_next(enum reserved_range_type *t,
@@ -145,7 +146,7 @@ static inline struct reserved_range *__physmem_reserved_next(enum reserved_range
145146
return range;
146147
}
147148
if (range->chain)
148-
return range->chain;
149+
return __va(range->chain);
149150
while (++*t < RR_MAX) {
150151
range = &physmem_info.reserved[*t];
151152
if (range->end)

arch/s390/kernel/crash_dump.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -568,9 +568,9 @@ static size_t get_elfcorehdr_size(int mem_chunk_cnt)
568568
int elfcorehdr_alloc(unsigned long long *addr, unsigned long long *size)
569569
{
570570
Elf64_Phdr *phdr_notes, *phdr_loads;
571+
size_t alloc_size;
571572
int mem_chunk_cnt;
572573
void *ptr, *hdr;
573-
u32 alloc_size;
574574
u64 hdr_off;
575575

576576
/* If we are not in kdump or zfcp/nvme dump mode return */

arch/s390/mm/vmem.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -667,7 +667,15 @@ static void __init memblock_region_swap(void *a, void *b, int size)
667667

668668
#ifdef CONFIG_KASAN
669669
#define __sha(x) ((unsigned long)kasan_mem_to_shadow((void *)x))
670+
671+
static inline int set_memory_kasan(unsigned long start, unsigned long end)
672+
{
673+
start = PAGE_ALIGN_DOWN(__sha(start));
674+
end = PAGE_ALIGN(__sha(end));
675+
return set_memory_rwnx(start, (end - start) >> PAGE_SHIFT);
676+
}
670677
#endif
678+
671679
/*
672680
* map whole physical memory to virtual memory (identity mapping)
673681
* we reserve enough space in the vmalloc area for vmemmap to hotplug
@@ -737,10 +745,8 @@ void __init vmem_map_init(void)
737745
}
738746

739747
#ifdef CONFIG_KASAN
740-
for_each_mem_range(i, &base, &end) {
741-
set_memory_rwnx(__sha(base),
742-
(__sha(end) - __sha(base)) >> PAGE_SHIFT);
743-
}
748+
for_each_mem_range(i, &base, &end)
749+
set_memory_kasan(base, end);
744750
#endif
745751
set_memory_rox((unsigned long)_stext,
746752
(unsigned long)(_etext - _stext) >> PAGE_SHIFT);

0 commit comments

Comments
 (0)