Re: [PATCH bpf RESEND v2 2/2] bpf: Require ARG_PTR_TO_MEM with memory flag

From: Eduard Zingerman

Date: Mon Jan 19 2026 - 15:25:14 EST


On Sun, 2026-01-18 at 16:16 +0800, Zesen Liu wrote:
> Add check to ensure that ARG_PTR_TO_MEM is used with either MEM_WRITE or
> MEM_RDONLY.
>
> Using ARG_PTR_TO_MEM alone without tags does not make sense because:
>
> - If the helper does not change the argument, missing MEM_RDONLY causes the
> verifier to incorrectly reject a read-only buffer.
> - If the helper does change the argument, missing MEM_WRITE causes the
> verifier to incorrectly assume the memory is unchanged, leading to errors
> in code optimization.
>
> Co-developed-by: Shuran Liu <electronlsr@xxxxxxxxx>
> Signed-off-by: Shuran Liu <electronlsr@xxxxxxxxx>
> Co-developed-by: Peili Gao <gplhust955@xxxxxxxxx>
> Signed-off-by: Peili Gao <gplhust955@xxxxxxxxx>
> Co-developed-by: Haoran Ni <haoran.ni.cs@xxxxxxxxx>
> Signed-off-by: Haoran Ni <haoran.ni.cs@xxxxxxxxx>
> Signed-off-by: Zesen Liu <ftyghome@xxxxxxxxx>
> ---

Note: this patch no longer applies properly because of the change in
the check_func_proto() signature.

[...]