Skip to content

Commit cd2093c

Browse files
committed
Michael writes: "powerpc fixes for 4.19 #4 Four regression fixes. A fix for a change to lib/xz which broke our zImage loader when building with XZ compression. OK'ed by Herbert who merged the original patch. The recent fix we did to avoid patching __init text broke some 32-bit machines, fix that. Our show_user_instructions() could be tricked into printing kernel memory, add a check to avoid that. And a fix for a change to our NUMA initialisation logic, which causes crashes in some kdump configurations. Thanks to: Christophe Leroy, Hari Bathini, Jann Horn, Joel Stanley, Meelis Roos, Murilo Opsfelder Araujo, Srikar Dronamraju." * tag 'powerpc-4.19-4' of https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux: powerpc/numa: Skip onlining a offline node in kdump path powerpc: Don't print kernel instructions in show_user_instructions() powerpc/lib: fix book3s/32 boot failure due to code patching lib/xz: Put CRC32_POLY_LE in xz_private.h
2 parents c1d84a1 + ac1788c commit cd2093c

File tree

5 files changed

+29
-11
lines changed

5 files changed

+29
-11
lines changed

arch/powerpc/kernel/process.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1306,6 +1306,16 @@ void show_user_instructions(struct pt_regs *regs)
13061306

13071307
pc = regs->nip - (instructions_to_print * 3 / 4 * sizeof(int));
13081308

1309+
/*
1310+
* Make sure the NIP points at userspace, not kernel text/data or
1311+
* elsewhere.
1312+
*/
1313+
if (!__access_ok(pc, instructions_to_print * sizeof(int), USER_DS)) {
1314+
pr_info("%s[%d]: Bad NIP, not dumping instructions.\n",
1315+
current->comm, current->pid);
1316+
return;
1317+
}
1318+
13091319
pr_info("%s[%d]: code: ", current->comm, current->pid);
13101320

13111321
for (i = 0; i < instructions_to_print; i++) {

arch/powerpc/lib/code-patching.c

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,6 @@ static int __patch_instruction(unsigned int *exec_addr, unsigned int instr,
2828
{
2929
int err;
3030

31-
/* Make sure we aren't patching a freed init section */
32-
if (init_mem_is_free && init_section_contains(exec_addr, 4)) {
33-
pr_debug("Skipping init section patching addr: 0x%px\n", exec_addr);
34-
return 0;
35-
}
36-
3731
__put_user_size(instr, patch_addr, 4, err);
3832
if (err)
3933
return err;
@@ -148,7 +142,7 @@ static inline int unmap_patch_area(unsigned long addr)
148142
return 0;
149143
}
150144

151-
int patch_instruction(unsigned int *addr, unsigned int instr)
145+
static int do_patch_instruction(unsigned int *addr, unsigned int instr)
152146
{
153147
int err;
154148
unsigned int *patch_addr = NULL;
@@ -188,12 +182,22 @@ int patch_instruction(unsigned int *addr, unsigned int instr)
188182
}
189183
#else /* !CONFIG_STRICT_KERNEL_RWX */
190184

191-
int patch_instruction(unsigned int *addr, unsigned int instr)
185+
static int do_patch_instruction(unsigned int *addr, unsigned int instr)
192186
{
193187
return raw_patch_instruction(addr, instr);
194188
}
195189

196190
#endif /* CONFIG_STRICT_KERNEL_RWX */
191+
192+
int patch_instruction(unsigned int *addr, unsigned int instr)
193+
{
194+
/* Make sure we aren't patching a freed init section */
195+
if (init_mem_is_free && init_section_contains(addr, 4)) {
196+
pr_debug("Skipping init section patching addr: 0x%px\n", addr);
197+
return 0;
198+
}
199+
return do_patch_instruction(addr, instr);
200+
}
197201
NOKPROBE_SYMBOL(patch_instruction);
198202

199203
int patch_branch(unsigned int *addr, unsigned long target, int flags)

arch/powerpc/mm/numa.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1217,9 +1217,10 @@ int find_and_online_cpu_nid(int cpu)
12171217
* Need to ensure that NODE_DATA is initialized for a node from
12181218
* available memory (see memblock_alloc_try_nid). If unable to
12191219
* init the node, then default to nearest node that has memory
1220-
* installed.
1220+
* installed. Skip onlining a node if the subsystems are not
1221+
* yet initialized.
12211222
*/
1222-
if (try_online_node(new_nid))
1223+
if (!topology_inited || try_online_node(new_nid))
12231224
new_nid = first_online_node;
12241225
#else
12251226
/*

lib/xz/xz_crc32.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
* but they are bigger and use more memory for the lookup table.
1616
*/
1717

18-
#include <linux/crc32poly.h>
1918
#include "xz_private.h"
2019

2120
/*

lib/xz/xz_private.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,10 @@
102102
# endif
103103
#endif
104104

105+
#ifndef CRC32_POLY_LE
106+
#define CRC32_POLY_LE 0xedb88320
107+
#endif
108+
105109
/*
106110
* Allocate memory for LZMA2 decoder. xz_dec_lzma2_reset() must be used
107111
* before calling xz_dec_lzma2_run().

0 commit comments

Comments
 (0)