From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.linuxfoundation.org ([140.211.169.12]:47494 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728303AbeICVxb (ORCPT ); Mon, 3 Sep 2018 17:53:31 -0400 From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Peter Robinson , Marc Haber , Stefan Wahren , Russell King , Alexei Starovoitov , Daniel Borkmann Subject: [PATCH 4.18 022/123] bpf, arm32: fix stack var offset in jit Date: Mon, 3 Sep 2018 18:56:06 +0200 Message-Id: <20180903165720.438298034@linuxfoundation.org> In-Reply-To: <20180903165719.499675257@linuxfoundation.org> References: <20180903165719.499675257@linuxfoundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: stable-owner@vger.kernel.org List-ID: 4.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Daniel Borkmann Commit 38ca93060163 ("bpf, arm32: save 4 bytes of unneeded stack space") messed up STACK_VAR() by 4 bytes presuming it was related to skb scratch buffer space, but it clearly isn't as this refers to the top word in stack, therefore restore it. This fixes a NULL pointer dereference seen during bootup when JIT is enabled and BPF program run in sk_filter_trim_cap() triggered by systemd-udevd. JIT rework in 1c35ba122d4a ("ARM: net: bpf: use negative numbers for stacked registers") and 96cced4e774a ("ARM: net: bpf: access eBPF scratch space using ARM FP register") removed the affected parts, so only needed in 4.18 stable. Fixes: 38ca93060163 ("bpf, arm32: save 4 bytes of unneeded stack space") Reported-by: Peter Robinson Reported-by: Marc Haber Tested-by: Stefan Wahren Tested-by: Peter Robinson Cc: Russell King Cc: Alexei Starovoitov Signed-off-by: Daniel Borkmann Acked-by: Alexei Starovoitov --- arch/arm/net/bpf_jit_32.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/arch/arm/net/bpf_jit_32.c +++ b/arch/arm/net/bpf_jit_32.c @@ -238,7 +238,7 @@ static void jit_fill_hole(void *area, un #define STACK_SIZE ALIGN(_STACK_SIZE, STACK_ALIGNMENT) /* Get the offset of eBPF REGISTERs stored on scratch space. */ -#define STACK_VAR(off) (STACK_SIZE - off) +#define STACK_VAR(off) (STACK_SIZE - off - 4) #if __LINUX_ARM_ARCH__ < 7