]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - queue-5.1/tools-bpftool-move-set_max_rlimit-before-__bpf_objec.patch
move all the pending queues back to their "real" places
[thirdparty/kernel/stable-queue.git] / queue-5.1 / tools-bpftool-move-set_max_rlimit-before-__bpf_objec.patch
1 From b9f2becf900b7cf3e9e361263701af44c87ccd50 Mon Sep 17 00:00:00 2001
2 From: Yonghong Song <yhs@fb.com>
3 Date: Thu, 16 May 2019 10:17:31 -0700
4 Subject: tools/bpftool: move set_max_rlimit() before
5 __bpf_object__open_xattr()
6
7 [ Upstream commit ac4e0e055fee5751c78bba1fc9ce508a6874d916 ]
8
9 For a host which has a lower rlimit for max locked memory (e.g., 64KB),
10 the following error occurs in one of our production systems:
11 # /usr/sbin/bpftool prog load /paragon/pods/52877437/home/mark.o \
12 /sys/fs/bpf/paragon_mark_21 type cgroup/skb \
13 map idx 0 pinned /sys/fs/bpf/paragon_map_21
14 libbpf: Error in bpf_object__probe_name():Operation not permitted(1).
15 Couldn't load basic 'r0 = 0' BPF program.
16 Error: failed to open object file
17
18 The reason is due to low locked memory during bpf_object__probe_name()
19 which probes whether program name is supported in kernel or not
20 during __bpf_object__open_xattr().
21
22 bpftool program load already tries to relax mlock rlimit before
23 bpf_object__load(). Let us move set_max_rlimit() before
24 __bpf_object__open_xattr(), which fixed the issue here.
25
26 Fixes: 47eff61777c7 ("bpf, libbpf: introduce bpf_object__probe_caps to test BPF capabilities")
27 Signed-off-by: Yonghong Song <yhs@fb.com>
28 Signed-off-by: Alexei Starovoitov <ast@kernel.org>
29 Signed-off-by: Sasha Levin <sashal@kernel.org>
30 ---
31 tools/bpf/bpftool/prog.c | 4 ++--
32 1 file changed, 2 insertions(+), 2 deletions(-)
33
34 diff --git a/tools/bpf/bpftool/prog.c b/tools/bpf/bpftool/prog.c
35 index d2be5a06c339..ed8ef5c82256 100644
36 --- a/tools/bpf/bpftool/prog.c
37 +++ b/tools/bpf/bpftool/prog.c
38 @@ -873,6 +873,8 @@ static int load_with_options(int argc, char **argv, bool first_prog_only)
39 }
40 }
41
42 + set_max_rlimit();
43 +
44 obj = __bpf_object__open_xattr(&attr, bpf_flags);
45 if (IS_ERR_OR_NULL(obj)) {
46 p_err("failed to open object file");
47 @@ -952,8 +954,6 @@ static int load_with_options(int argc, char **argv, bool first_prog_only)
48 goto err_close_obj;
49 }
50
51 - set_max_rlimit();
52 -
53 err = bpf_object__load(obj);
54 if (err) {
55 p_err("failed to load object file");
56 --
57 2.20.1
58