diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2024-03-07 09:23:33 -0800 | 
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2024-03-07 09:23:33 -0800 | 
| commit | df4793505abd5df399bc6d9a4d8fe81761f557cd (patch) | |
| tree | 71bcf8836d374b96b163ae50d7dbd7976189acc1 /tools/testing/selftests/bpf/progs/verifier_iterating_callbacks.c | |
| parent | 67be068d31d423b857ffd8c34dbcc093f8dfff76 (diff) | |
| parent | ba18deddd6d502da71fd6b6143c53042271b82bd (diff) | |
Merge tag 'net-6.8-rc8' of git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net
Pull networking fixes from Paolo Abeni:
 "Including fixes from bpf, ipsec and netfilter.
  No solution yet for the stmmac issue mentioned in the last PR, but it
  proved to be a lockdep false positive, not a blocker.
  Current release - regressions:
   - dpll: move all dpll<>netdev helpers to dpll code, fix build
     regression with old compilers
  Current release - new code bugs:
   - page_pool: fix netlink dump stop/resume
  Previous releases - regressions:
   - bpf: fix verifier to check bpf_func_state->callback_depth when
     pruning states as otherwise unsafe programs could get accepted
   - ipv6: avoid possible UAF in ip6_route_mpath_notify()
   - ice: reconfig host after changing MSI-X on VF
   - mlx5:
       - e-switch, change flow rule destination checking
       - add a memory barrier to prevent a possible null-ptr-deref
       - switch to using _bh variant of of spinlock where needed
  Previous releases - always broken:
   - netfilter: nf_conntrack_h323: add protection for bmp length out of
     range
   - bpf: fix to zero-initialise xdp_rxq_info struct before running XDP
     program in CPU map which led to random xdp_md fields
   - xfrm: fix UDP encapsulation in TX packet offload
   - netrom: fix data-races around sysctls
   - ice:
       - fix potential NULL pointer dereference in ice_bridge_setlink()
       - fix uninitialized dplls mutex usage
   - igc: avoid returning frame twice in XDP_REDIRECT
   - i40e: disable NAPI right after disabling irqs when handling
     xsk_pool
   - geneve: make sure to pull inner header in geneve_rx()
   - sparx5: fix use after free inside sparx5_del_mact_entry
   - dsa: microchip: fix register write order in ksz8_ind_write8()
  Misc:
   - selftests: mptcp: fixes for diag.sh"
* tag 'net-6.8-rc8' of git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net: (63 commits)
  net: pds_core: Fix possible double free in error handling path
  netrom: Fix data-races around sysctl_net_busy_read
  netrom: Fix a data-race around sysctl_netrom_link_fails_count
  netrom: Fix a data-race around sysctl_netrom_routing_control
  netrom: Fix a data-race around sysctl_netrom_transport_no_activity_timeout
  netrom: Fix a data-race around sysctl_netrom_transport_requested_window_size
  netrom: Fix a data-race around sysctl_netrom_transport_busy_delay
  netrom: Fix a data-race around sysctl_netrom_transport_acknowledge_delay
  netrom: Fix a data-race around sysctl_netrom_transport_maximum_tries
  netrom: Fix a data-race around sysctl_netrom_transport_timeout
  netrom: Fix data-races around sysctl_netrom_network_ttl_initialiser
  netrom: Fix a data-race around sysctl_netrom_obsolescence_count_initialiser
  netrom: Fix a data-race around sysctl_netrom_default_path_quality
  netfilter: nf_conntrack_h323: Add protection for bmp length out of range
  netfilter: nf_tables: mark set as dead when unbinding anonymous set with timeout
  netfilter: nft_ct: fix l3num expectations with inet pseudo family
  netfilter: nf_tables: reject constant set with timeout
  netfilter: nf_tables: disallow anonymous set with timeout flag
  net/rds: fix WARNING in rds_conn_connect_if_down
  net: dsa: microchip: fix register write order in ksz8_ind_write8()
  ...
Diffstat (limited to 'tools/testing/selftests/bpf/progs/verifier_iterating_callbacks.c')
| -rw-r--r-- | tools/testing/selftests/bpf/progs/verifier_iterating_callbacks.c | 70 | 
1 files changed, 70 insertions, 0 deletions
diff --git a/tools/testing/selftests/bpf/progs/verifier_iterating_callbacks.c b/tools/testing/selftests/bpf/progs/verifier_iterating_callbacks.c index 5905e036e0ea..a955a6358206 100644 --- a/tools/testing/selftests/bpf/progs/verifier_iterating_callbacks.c +++ b/tools/testing/selftests/bpf/progs/verifier_iterating_callbacks.c @@ -239,4 +239,74 @@ int bpf_loop_iter_limit_nested(void *unused)  	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; +} +  char _license[] SEC("license") = "GPL";  | 
