public inbox for bpf@vger.kernel.org
 help / color / mirror / Atom feed
* test_kmod.sh fails with constant blinding
@ 2022-06-30 13:19 Yauheni Kaliuta
  2022-06-30 20:57 ` Daniel Borkmann
  0 siblings, 1 reply; 14+ messages in thread
From: Yauheni Kaliuta @ 2022-06-30 13:19 UTC (permalink / raw)
  To: bpf

Hi!

test_kmod.sh fails for hardened 2 check with

 test_bpf: #964 Staggered jumps: JMP_JA FAIL to select_runtime err=-524

(-ERANGE during constant blinding)

Did I miss something?

-- 
WBR, Yauheni


^ permalink raw reply	[flat|nested] 14+ messages in thread
* Re: test_kmod.sh fails with constant blinding
@ 2024-01-02 15:11 Bram Schuur
  2024-01-02 16:56 ` Yonghong Song
  0 siblings, 1 reply; 14+ messages in thread
From: Bram Schuur @ 2024-01-02 15:11 UTC (permalink / raw)
  To: ykaliuta@redhat.com; +Cc: bpf@vger.kernel.org, johan.almbladh@anyfinetworks.com

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


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2024-01-03  7:23 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-06-30 13:19 test_kmod.sh fails with constant blinding 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
  -- strict thread matches above, loose matches on Subject: below --
2024-01-02 15:11 Bram Schuur
2024-01-02 16:56 ` 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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox