lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <16f0d900bff994c1e23fe3862c3953819bf6a63a.camel@gmail.com>
Date: Tue, 02 Jul 2024 08:52:01 -0700
From: Alexander H Duyck <alexander.duyck@...il.com>
To: Yunsheng Lin <linyunsheng@...wei.com>, davem@...emloft.net,
 kuba@...nel.org,  pabeni@...hat.com
Cc: netdev@...r.kernel.org, linux-kernel@...r.kernel.org, Eric Dumazet
	 <edumazet@...gle.com>
Subject: Re: [PATCH net-next v9 09/13] net: introduce the
 skb_copy_to_va_nocache() helper

On Tue, 2024-06-25 at 21:52 +0800, Yunsheng Lin wrote:
> introduce the skb_copy_to_va_nocache() helper to avoid
> calling virt_to_page() and skb_copy_to_page_nocache().
> 
> CC: Alexander Duyck <alexander.duyck@...il.com>
> Signed-off-by: Yunsheng Lin <linyunsheng@...wei.com>
> ---
>  include/net/sock.h | 15 +++++++++++++++
>  1 file changed, 15 insertions(+)
> 
> diff --git a/include/net/sock.h b/include/net/sock.h
> index cce23ac4d514..7ad235465485 100644
> --- a/include/net/sock.h
> +++ b/include/net/sock.h
> @@ -2201,6 +2201,21 @@ static inline int skb_copy_to_page_nocache(struct sock *sk, struct iov_iter *fro
>  	return 0;
>  }
>  
> +static inline int skb_copy_to_va_nocache(struct sock *sk, struct iov_iter *from,
> +					 struct sk_buff *skb, char *va, int copy)
> +{
> +	int err;
> +
> +	err = skb_do_copy_data_nocache(sk, skb, from, va, copy, skb->len);
> +	if (err)
> +		return err;
> +
> +	skb_len_add(skb, copy);
> +	sk_wmem_queued_add(sk, copy);
> +	sk_mem_charge(sk, copy);
> +	return 0;
> +}
> +
>  /**
>   * sk_wmem_alloc_get - returns write allocations
>   * @sk: socket

One minor nit. Rather than duplicate skb_copy_to_page_nocache you would
be better served to implement this one before it, and then just update
skb_copy_to_page_nocache to be:
	return skb_copy_to_va_nocache(sk, from, skb,
				      page_address(page) + off, copy);

We can save ourselves at least a few lines of code that way and it
creates one spot to do any changes.
				

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ