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]
Date:   Thu, 28 Apr 2022 16:04:41 +0200
From:   Paolo Abeni <pabeni@...hat.com>
To:     Pavel Begunkov <asml.silence@...il.com>, netdev@...r.kernel.org,
        "David S . Miller" <davem@...emloft.net>,
        Jakub Kicinski <kuba@...nel.org>
Cc:     David Ahern <dsahern@...nel.org>,
        Eric Dumazet <edumazet@...gle.com>,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH net-next 01/11] ipv6: optimise ipcm6 cookie init

On Thu, 2022-04-28 at 11:56 +0100, Pavel Begunkov wrote:
> Users of ipcm6_init() have a somewhat complex post initialisation
> of ->dontfrag and ->tclass. Not only it adds additional overhead,
> but also complicates the code.
> 
> First, replace ipcm6_init() with ipcm6_init_sk(). As it might be not an
> equivalent change, let's first look at ->dontfrag. The logic was to set
> it from cmsg if specified and otherwise fallback to np->dontfrag. Now
> it's initialising to np->dontfrag in the beginning and then potentially
> overriding with cmsg, which is absolutely the same behaviour.
> 
> It's a bit more complex with ->tclass as ip6_datagram_send_ctl() might
> set it to -1, which is a default and not valid value. The solution
> here is to skip -1's specified in cmsg, so it'll be left with the socket
> default value getting us to the old behaviour.
> 
> Signed-off-by: Pavel Begunkov <asml.silence@...il.com>
> ---
>  include/net/ipv6.h    | 9 ---------
>  net/ipv6/datagram.c   | 4 ++--
>  net/ipv6/ip6_output.c | 2 --
>  net/ipv6/raw.c        | 8 +-------
>  net/ipv6/udp.c        | 7 +------
>  net/l2tp/l2tp_ip6.c   | 8 +-------
>  6 files changed, 5 insertions(+), 33 deletions(-)
> 
> diff --git a/include/net/ipv6.h b/include/net/ipv6.h
> index 213612f1680c..30a3447e34b4 100644
> --- a/include/net/ipv6.h
> +++ b/include/net/ipv6.h
> @@ -352,15 +352,6 @@ struct ipcm6_cookie {
>  	struct ipv6_txoptions *opt;
>  };
>  
> -static inline void ipcm6_init(struct ipcm6_cookie *ipc6)
> -{
> -	*ipc6 = (struct ipcm6_cookie) {
> -		.hlimit = -1,
> -		.tclass = -1,
> -		.dontfrag = -1,
> -	};
> -}
> -
>  static inline void ipcm6_init_sk(struct ipcm6_cookie *ipc6,
>  				 const struct ipv6_pinfo *np)
>  {
> diff --git a/net/ipv6/datagram.c b/net/ipv6/datagram.c
> index 206f66310a88..1b334bc855ae 100644
> --- a/net/ipv6/datagram.c
> +++ b/net/ipv6/datagram.c
> @@ -1003,9 +1003,9 @@ int ip6_datagram_send_ctl(struct net *net, struct sock *sk,
>  			if (tc < -1 || tc > 0xff)
>  				goto exit_f;
>  
> +			if (tc != -1)
> +				ipc6->tclass = tc;
>  			err = 0;
> -			ipc6->tclass = tc;
> -
>  			break;
>  		    }

It looks like the above causes a behavioral change: before this patch
cmsg took precedence on socket status, after this patch looks like it's
the opposide.

Am I missing something?

Thanks

Paolo

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ