From: Sandipan Das <sandipan@linux.ibm.com>
To: daniel@iogearbox.net, ast@kernel.org
Cc: naveen.n.rao@linux.ibm.com, netdev@vger.kernel.org,
linuxppc-dev@ozlabs.org
Subject: [PATCH bpf] bpf: fix default unprivileged allocation limit
Date: Thu, 6 Dec 2018 14:57:32 +0530 [thread overview]
Message-ID: <20181206092732.4206-1-sandipan@linux.ibm.com> (raw)
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 <sandipan@linux.ibm.com>
---
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
next reply other threads:[~2018-12-06 9:31 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-06 9:27 Sandipan Das [this message]
2018-12-06 16:58 ` [PATCH bpf] bpf: fix default unprivileged allocation limit Michael Roth
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20181206092732.4206-1-sandipan@linux.ibm.com \
--to=sandipan@linux.ibm.com \
--cc=ast@kernel.org \
--cc=daniel@iogearbox.net \
--cc=linuxppc-dev@ozlabs.org \
--cc=naveen.n.rao@linux.ibm.com \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).