Re: [PATCH bpf-next v1 2/2] bpf: use realloc in bpf_patch_insn_data

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 2025-08-06 at 13:09 -0700, Eduard Zingerman wrote:

[...]

> @@ -20712,22 +20711,19 @@ static void adjust_insn_aux_data(struct bpf_verifier_env *env,
>  	 * (cnt == 1) is taken or not. There is no guarantee INSN at OFF is the
>  	 * original insn at old prog.
>  	 */
> -	old_data[off].zext_dst = insn_has_def32(insn + off + cnt - 1);
> +	data[off].zext_dst = insn_has_def32(insn + off + cnt - 1);
>  
>  	if (cnt == 1)
>  		return;
>  	prog_len = new_prog->len;
>  
> -	memcpy(new_data, old_data, sizeof(struct bpf_insn_aux_data) * off);
> -	memcpy(new_data + off + cnt - 1, old_data + off,
> -	       sizeof(struct bpf_insn_aux_data) * (prog_len - off - cnt + 1));
> +	memmove(data + off + cnt - 1, data + off,
> +		sizeof(struct bpf_insn_aux_data) * (prog_len - off - cnt + 1));
>  	for (i = off; i < off + cnt - 1; i++) {
>  		/* Expand insni[off]'s seen count to the patched range. */
> -		new_data[i].seen = old_seen;
> -		new_data[i].zext_dst = insn_has_def32(insn + i);
> +		data[i].seen = old_seen;
> +		data[i].zext_dst = insn_has_def32(insn + i);
>  	}
> -	env->insn_aux_data = new_data;
> -	vfree(old_data);
>  }

veristat-meta job failed on the CI [1] because the following piece is missing:

  @@ -20719,6 +20719,7 @@ static void adjust_insn_aux_data(struct bpf_verifier_env *env,
   
          memmove(data + off + cnt - 1, data + off,
                  sizeof(struct bpf_insn_aux_data) * (prog_len - off - cnt + 1));
  +       memset(data + off, 0, sizeof(struct bpf_insn_aux_data) * (cnt - 1));
          for (i = off; i < off + cnt - 1; i++) {
                  /* Expand insni[off]'s seen count to the patched range. */
                  data[i].seen = old_seen;

I'm trying to figure out if I can add a selftest for this.

[1] https://github.com/kernel-patches/bpf/actions/runs/16787563163/job/47542309875

[...]





[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux