bpf: Take return from set_memory_rox() into account with bpf_jit_binary_lock_ro()
authorChristophe Leroy <christophe.leroy@csgroup.eu>
Fri, 8 Mar 2024 05:38:08 +0000 (06:38 +0100)
committerAlexei Starovoitov <ast@kernel.org>
Fri, 15 Mar 2024 02:28:52 +0000 (19:28 -0700)
commite60adf513275c3a38e5cb67f7fd12387e43a3ff5
treef154a2a436cb986c45b30f5090aca12218d43a2c
parent7d2cc63eca0c993c99d18893214abf8f85d566d8
bpf: Take return from set_memory_rox() into account with bpf_jit_binary_lock_ro()

set_memory_rox() can fail, leaving memory unprotected.

Check return and bail out when bpf_jit_binary_lock_ro() returns
an error.

Link: https://github.com/KSPP/linux/issues/7
Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Cc: linux-hardening@vger.kernel.org <linux-hardening@vger.kernel.org>
Reviewed-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Puranjay Mohan <puranjay12@gmail.com>
Reviewed-by: Ilya Leoshkevich <iii@linux.ibm.com> # s390x
Acked-by: Tiezhu Yang <yangtiezhu@loongson.cn> # LoongArch
Reviewed-by: Johan Almbladh <johan.almbladh@anyfinetworks.com> # MIPS Part
Message-ID: <036b6393f23a2032ce75a1c92220b2afcb798d5d.1709850515.git.christophe.leroy@csgroup.eu>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
arch/arm/net/bpf_jit_32.c
arch/loongarch/net/bpf_jit.c
arch/mips/net/bpf_jit_comp.c
arch/parisc/net/bpf_jit_core.c
arch/s390/net/bpf_jit_comp.c
arch/sparc/net/bpf_jit_comp_64.c
arch/x86/net/bpf_jit_comp32.c
include/linux/filter.h