linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stephen Rothwell <sfr@canb.auug.org.au>
To: Daniel Borkmann <daniel@iogearbox.net>,
	Alexei Starovoitov <ast@kernel.org>,
	Andrii Nakryiko <andrii@kernel.org>
Cc: bpf <bpf@vger.kernel.org>, Networking <netdev@vger.kernel.org>,
	Eduard Zingerman <eddyz87@gmail.com>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Linux Next Mailing List <linux-next@vger.kernel.org>
Subject: linux-next: manual merge of the bpf-next tree with the bpf tree
Date: Thu, 7 Mar 2024 12:40:40 +1100	[thread overview]
Message-ID: <20240307124040.1a177b71@canb.auug.org.au> (raw)

[-- Attachment #1: Type: text/plain, Size: 4464 bytes --]

Hi all,

Today's linux-next merge of the bpf-next tree got a conflict in:

  tools/testing/selftests/bpf/progs/verifier_iterating_callbacks.c

between commit:

  5c2bc5e2f81d ("selftests/bpf: test case for callback_depth states pruning logic")

from the bpf tree and commit:

  0c8bbf990bdd ("selftests/bpf: Test may_goto")

from the bpf-next tree.

I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging.  You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.

-- 
Cheers,
Stephen Rothwell

diff --cc tools/testing/selftests/bpf/progs/verifier_iterating_callbacks.c
index a955a6358206,04cdbce4652f..000000000000
--- a/tools/testing/selftests/bpf/progs/verifier_iterating_callbacks.c
+++ b/tools/testing/selftests/bpf/progs/verifier_iterating_callbacks.c
@@@ -239,74 -237,103 +237,173 @@@ int bpf_loop_iter_limit_nested(void *un
  	return 1000 * a + b + c;
  }
  
 +struct iter_limit_bug_ctx {
 +	__u64 a;
 +	__u64 b;
 +	__u64 c;
 +};
 +
 +static __naked void iter_limit_bug_cb(void)
 +{
 +	/* This is the same as C code below, but written
 +	 * in assembly to control which branches are fall-through.
 +	 *
 +	 *   switch (bpf_get_prandom_u32()) {
 +	 *   case 1:  ctx->a = 42; break;
 +	 *   case 2:  ctx->b = 42; break;
 +	 *   default: ctx->c = 42; break;
 +	 *   }
 +	 */
 +	asm volatile (
 +	"r9 = r2;"
 +	"call %[bpf_get_prandom_u32];"
 +	"r1 = r0;"
 +	"r2 = 42;"
 +	"r0 = 0;"
 +	"if r1 == 0x1 goto 1f;"
 +	"if r1 == 0x2 goto 2f;"
 +	"*(u64 *)(r9 + 16) = r2;"
 +	"exit;"
 +	"1: *(u64 *)(r9 + 0) = r2;"
 +	"exit;"
 +	"2: *(u64 *)(r9 + 8) = r2;"
 +	"exit;"
 +	:
 +	: __imm(bpf_get_prandom_u32)
 +	: __clobber_all
 +	);
 +}
 +
 +SEC("tc")
 +__failure
 +__flag(BPF_F_TEST_STATE_FREQ)
 +int iter_limit_bug(struct __sk_buff *skb)
 +{
 +	struct iter_limit_bug_ctx ctx = { 7, 7, 7 };
 +
 +	bpf_loop(2, iter_limit_bug_cb, &ctx, 0);
 +
 +	/* This is the same as C code below,
 +	 * written in assembly to guarantee checks order.
 +	 *
 +	 *   if (ctx.a == 42 && ctx.b == 42 && ctx.c == 7)
 +	 *     asm volatile("r1 /= 0;":::"r1");
 +	 */
 +	asm volatile (
 +	"r1 = *(u64 *)%[ctx_a];"
 +	"if r1 != 42 goto 1f;"
 +	"r1 = *(u64 *)%[ctx_b];"
 +	"if r1 != 42 goto 1f;"
 +	"r1 = *(u64 *)%[ctx_c];"
 +	"if r1 != 7 goto 1f;"
 +	"r1 /= 0;"
 +	"1:"
 +	:
 +	: [ctx_a]"m"(ctx.a),
 +	  [ctx_b]"m"(ctx.b),
 +	  [ctx_c]"m"(ctx.c)
 +	: "r1"
 +	);
 +	return 0;
 +}
 +
+ #define ARR_SZ 1000000
+ int zero;
+ char arr[ARR_SZ];
+ 
+ SEC("socket")
+ __success __retval(0xd495cdc0)
+ int cond_break1(const void *ctx)
+ {
+ 	unsigned long i;
+ 	unsigned int sum = 0;
+ 
+ 	for (i = zero; i < ARR_SZ; cond_break, i++)
+ 		sum += i;
+ 	for (i = zero; i < ARR_SZ; i++) {
+ 		barrier_var(i);
+ 		sum += i + arr[i];
+ 		cond_break;
+ 	}
+ 
+ 	return sum;
+ }
+ 
+ SEC("socket")
+ __success __retval(999000000)
+ int cond_break2(const void *ctx)
+ {
+ 	int i, j;
+ 	int sum = 0;
+ 
+ 	for (i = zero; i < 1000; cond_break, i++)
+ 		for (j = zero; j < 1000; j++) {
+ 			sum += i + j;
+ 			cond_break;
+ 		}
+ 
+ 	return sum;
+ }
+ 
+ static __noinline int loop(void)
+ {
+ 	int i, sum = 0;
+ 
+ 	for (i = zero; i <= 1000000; i++, cond_break)
+ 		sum += i;
+ 
+ 	return sum;
+ }
+ 
+ SEC("socket")
+ __success __retval(0x6a5a2920)
+ int cond_break3(const void *ctx)
+ {
+ 	return loop();
+ }
+ 
+ SEC("socket")
+ __success __retval(1)
+ int cond_break4(const void *ctx)
+ {
+ 	int cnt = zero;
+ 
+ 	for (;;) {
+ 		/* should eventually break out of the loop */
+ 		cond_break;
+ 		cnt++;
+ 	}
+ 	/* if we looped a bit, it's a success */
+ 	return cnt > 1 ? 1 : 0;
+ }
+ 
+ static __noinline int static_subprog(void)
+ {
+ 	int cnt = zero;
+ 
+ 	for (;;) {
+ 		cond_break;
+ 		cnt++;
+ 	}
+ 
+ 	return cnt;
+ }
+ 
+ SEC("socket")
+ __success __retval(1)
+ int cond_break5(const void *ctx)
+ {
+ 	int cnt1 = zero, cnt2;
+ 
+ 	for (;;) {
+ 		cond_break;
+ 		cnt1++;
+ 	}
+ 
+ 	cnt2 = static_subprog();
+ 
+ 	/* main and subprog have to loop a bit */
+ 	return cnt1 > 1 && cnt2 > 1 ? 1 : 0;
+ }
+ 
  char _license[] SEC("license") = "GPL";

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

             reply	other threads:[~2024-03-07  1:40 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-07  1:40 Stephen Rothwell [this message]
  -- strict thread matches above, loose matches on Subject: below --
2023-03-06 22:58 linux-next: manual merge of the bpf-next tree with the bpf tree Stephen Rothwell
2023-03-10  0:38 ` Stephen Rothwell
2023-03-10  3:18 ` Bagas Sanjaya
2022-11-21  1:27 Stephen Rothwell
2022-08-26  1:46 Stephen Rothwell
2022-08-25  0:50 Stephen Rothwell
2022-08-22  1:01 Stephen Rothwell
2021-12-05 23:39 Stephen Rothwell
2020-09-30  4:07 Stephen Rothwell
2020-10-02  3:59 ` Stephen Rothwell
2020-06-26  0:05 Stephen Rothwell
2020-07-06  1:43 ` Stephen Rothwell
2020-05-15  3:18 Stephen Rothwell
2019-10-08 22:47 Stephen Rothwell
2019-10-15 23:29 ` Stephen Rothwell
2019-10-07 22:48 Stephen Rothwell
2019-10-15 23:27 ` Stephen Rothwell
2019-04-17  1:08 Stephen Rothwell
2019-04-24  3:12 ` Stephen Rothwell
2018-12-04  1:09 Stephen Rothwell
2018-12-04  1:05 Stephen Rothwell
2018-11-12  0:54 Stephen Rothwell
2018-05-14  1:57 Stephen Rothwell
2018-05-14 20:41 ` Jakub Kicinski
2018-05-14 21:57   ` Stephen Rothwell
2018-05-02  2:09 Stephen Rothwell
2018-05-02  4:40 ` Song Liu
2018-05-02  5:50   ` Stephen Rothwell
2018-05-02  6:05     ` Song Liu
2018-04-26  0:53 Stephen Rothwell
2018-04-26  7:57 ` Daniel Borkmann
2018-02-26  0:41 Stephen Rothwell
2018-02-26  9:03 ` Daniel Borkmann
2018-02-26 23:28 ` Stephen Rothwell

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=20240307124040.1a177b71@canb.auug.org.au \
    --to=sfr@canb.auug.org.au \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=eddyz87@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-next@vger.kernel.org \
    --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).