Re: [PATCH bpf-next v3 02/10] bpf: Enable read access to skb metadata with bpf_dynptr_read

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

 



On Tue, Jul 22, 2025 at 11:49 AM -07, Eduard Zingerman wrote:
> On Mon, 2025-07-21 at 12:52 +0200, Jakub Sitnicki wrote:
>
> [...]
>
>> diff --git a/net/core/filter.c b/net/core/filter.c
>> index c17b628c08f5..4b787c56b220 100644
>> --- a/net/core/filter.c
>> +++ b/net/core/filter.c
>> @@ -11978,6 +11978,18 @@ bpf_sk_base_func_proto(enum bpf_func_id func_id, const struct bpf_prog *prog)
>>  	return func;
>>  }
>>  
>> +int bpf_skb_meta_load_bytes(const struct sk_buff *skb, u32 offset,
>> +			    void *dst, u32 len)
>> +{
>> +	u32 meta_len = skb_metadata_len(skb);
>> +
>> +	if (len > meta_len || offset > meta_len - len)
>> +		return -E2BIG; /* out of bounds */
>> +
>> +	memmove(dst, skb_metadata_end(skb) - meta_len + offset, len);
>> +	return 0;
>> +}
>> +
>
> Nit: is it possible to use bpf_skb_meta_pointer() here to avoid
>      duplicating range check in both bpf_skb_meta_load_bytes()
>      and bpf_skb_meta_store_bytes()?

This will be a nice refactor. Thanks!




[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