From: Sandipan Das Subject: [PATCH bpf] bpf: fix default unprivileged allocation limit Date: Thu, 6 Dec 2018 14:57:32 +0530 Message-ID: <20181206092732.4206-1-sandipan@linux.ibm.com> Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Cc: netdev@vger.kernel.org, linuxppc-dev@ozlabs.org, mpe@ellerman.id.au, naveen.n.rao@linux.ibm.com To: daniel@iogearbox.net, ast@kernel.org Return-path: Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:50286 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727806AbeLFJ1k (ORCPT ); Thu, 6 Dec 2018 04:27:40 -0500 Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id wB69Nnfl001864 for ; Thu, 6 Dec 2018 04:27:39 -0500 Received: from e06smtp04.uk.ibm.com (e06smtp04.uk.ibm.com [195.75.94.100]) by mx0b-001b2d01.pphosted.com with ESMTP id 2p6yd5w7gw-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 06 Dec 2018 04:27:39 -0500 Received: from localhost by e06smtp04.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 6 Dec 2018 09:27:37 -0000 Sender: netdev-owner@vger.kernel.org List-ID: When using a large page size, the default value of the bpf_jit_limit knob becomes invalid and users are not able to run unprivileged bpf programs. The bpf_jit_limit knob is represented internally as a 32-bit signed integer because of which the default value, i.e. PAGE_SIZE * 40000, overflows in case of an architecture like powerpc64 which uses 64K as the default page size (i.e. CONFIG_PPC_64K_PAGES is set). So, instead of depending on the page size, use a constant value. Fixes: ede95a63b5e8 ("bpf: add bpf_jit_limit knob to restrict unpriv allocations") Signed-off-by: Sandipan Das --- kernel/bpf/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c index b1a3545d0ec8..a81d097a17fb 100644 --- a/kernel/bpf/core.c +++ b/kernel/bpf/core.c @@ -365,7 +365,7 @@ void bpf_prog_kallsyms_del_all(struct bpf_prog *fp) } #ifdef CONFIG_BPF_JIT -# define BPF_JIT_LIMIT_DEFAULT (PAGE_SIZE * 40000) +# define BPF_JIT_LIMIT_DEFAULT (4096 * 40000) /* All BPF JIT sysctl knobs here. */ int bpf_jit_enable __read_mostly = IS_BUILTIN(CONFIG_BPF_JIT_ALWAYS_ON); -- 2.19.2