Skip to content

Commit f7f18e3

Browse files
chleroympe
authored andcommitted
powerpc/kprobes: Handle error returned by set_memory_rox()
set_memory_rox() can fail. In case it fails, free allocated memory and return NULL. Link: KSPP#7 Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Link: https://msgid.link/b4907cf4339bd086abc40430d91311436cb0c18e.1708078401.git.christophe.leroy@csgroup.eu
1 parent 09ca1b1 commit f7f18e3

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

arch/powerpc/kernel/kprobes.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,16 @@ void *alloc_insn_page(void)
134134
if (!page)
135135
return NULL;
136136

137-
if (strict_module_rwx_enabled())
138-
set_memory_rox((unsigned long)page, 1);
137+
if (strict_module_rwx_enabled()) {
138+
int err = set_memory_rox((unsigned long)page, 1);
139139

140+
if (err)
141+
goto error;
142+
}
140143
return page;
144+
error:
145+
module_memfree(page);
146+
return NULL;
141147
}
142148

143149
int arch_prepare_kprobe(struct kprobe *p)

0 commit comments

Comments
 (0)