From: Bram Schuur <bschuur@stackstate.com>
To: "ykaliuta@redhat.com" <ykaliuta@redhat.com>
Cc: "bpf@vger.kernel.org" <bpf@vger.kernel.org>,
"johan.almbladh@anyfinetworks.com"
<johan.almbladh@anyfinetworks.com>
Subject: Re: test_kmod.sh fails with constant blinding
Date: Tue, 2 Jan 2024 15:11:53 +0000 [thread overview]
Message-ID: <AM0PR0202MB3412F6D0F59E5EBA0CA74747C461A@AM0PR0202MB3412.eurprd02.prod.outlook.com> (raw)
Me and my colleague Jan-Gerd Tenberge encountered this issue in production on the 5.15, 6.1 and 6.2 kernel versions. We make a small reproducible case that might help find the root cause:
simple_repo.c:
#include <linux/bpf.h>
#include <bpf/bpf_helpers.h>
SEC("socket")
int socket__http_filter(struct __sk_buff* skb) {
volatile __u32 r = bpf_get_prandom_u32();
if (r == 0) {
goto done;
}
#pragma clang loop unroll(full)
for (int i = 0; i < 12000; i++) {
r += 1;
}
#pragma clang loop unroll(full)
for (int i = 0; i < 12000; i++) {
r += 1;
}
done:
return r;
}
Looking at kernel/bpf/core.c it seems that during constant blinding every instruction which has an constant operand gets 2 additional instructions. This increases the amount of instructions between the JMP and target of the JMP cause rewrite of the JMP to fail because the offset becomes bigger than S16_MAX.
Hope this helps,
Bram Schuur and Jan-Gerd Tenberge
next reply other threads:[~2024-01-02 15:11 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-02 15:11 Bram Schuur [this message]
2024-01-02 16:56 ` test_kmod.sh fails with constant blinding Yonghong Song
2024-01-02 17:47 ` Eduard Zingerman
2024-01-02 19:41 ` Yonghong Song
2024-01-02 22:39 ` Eduard Zingerman
2024-01-03 0:02 ` Jan-Gerd Tenberge
2024-01-03 7:23 ` Bram Schuur
-- strict thread matches above, loose matches on Subject: below --
2022-06-30 13:19 Yauheni Kaliuta
2022-06-30 20:57 ` Daniel Borkmann
2022-07-01 11:05 ` Yauheni Kaliuta
2022-07-04 8:21 ` Yauheni Kaliuta
2022-07-05 8:07 ` Johan Almbladh
2022-07-05 8:31 ` Yauheni Kaliuta
2022-09-01 10:01 ` Yauheni Kaliuta
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=AM0PR0202MB3412F6D0F59E5EBA0CA74747C461A@AM0PR0202MB3412.eurprd02.prod.outlook.com \
--to=bschuur@stackstate.com \
--cc=bpf@vger.kernel.org \
--cc=johan.almbladh@anyfinetworks.com \
--cc=ykaliuta@redhat.com \
/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).