RE: [PATCH net-next 30/33] xdp: clear grow memory in bpf_xdp_adjust_tail()

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

 



Jesper Dangaard Brouer wrote:
> Clearing memory of tail when grow happens, because it is too easy
> to write a XDP_PASS program that extend the tail, which expose
> this memory to users that can run tcpdump.
> 
> Signed-off-by: Jesper Dangaard Brouer <brouer@xxxxxxxxxx>
> ---

Hi Jesper, Thanks for the series any idea what the cost of doing
this is? If you have some data I would be curious to know a
baseline measurment, a grow with memset, then a grow with memset.
I'm guess this can be relatively expensive?

>  net/core/filter.c |    4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/net/core/filter.c b/net/core/filter.c
> index 5e9c387f74eb..889d96a690c2 100644
> --- a/net/core/filter.c
> +++ b/net/core/filter.c
> @@ -3442,6 +3442,10 @@ BPF_CALL_2(bpf_xdp_adjust_tail, struct xdp_buff *, xdp, int, offset)
>  	if (unlikely(data_end < xdp->data + ETH_HLEN))
>  		return -EINVAL;
>  
> +	/* Clear memory area on grow, can contain uninit kernel memory */
> +	if (offset > 0)
> +		memset(xdp->data_end, 0, offset);
> +
>  	xdp->data_end = data_end;
>  
>  	return 0;
> 
> 





[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