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: <20190430064033.GA20104@splinter>
Date:   Tue, 30 Apr 2019 06:40:35 +0000
From:   Ido Schimmel <idosch@...lanox.com>
To:     David Ahern <dsahern@...nel.org>
CC:     "davem@...emloft.net" <davem@...emloft.net>,
        "netdev@...r.kernel.org" <netdev@...r.kernel.org>,
        David Ahern <dsahern@...il.com>
Subject: Re: [PATCH v3 net-next 1/3] ipv4: Move cached routes to fib_nh_common

On Mon, Apr 29, 2019 at 09:16:17AM -0700, David Ahern wrote:
>  /* Release a nexthop info record */
> @@ -491,9 +491,15 @@ int fib_nh_common_init(struct fib_nh_common *nhc, struct nlattr *encap,
>  		       u16 encap_type, void *cfg, gfp_t gfp_flags,
>  		       struct netlink_ext_ack *extack)
>  {
> +	int err;
> +
> +	nhc->nhc_pcpu_rth_output = alloc_percpu_gfp(struct rtable __rcu *,
> +						    gfp_flags);
> +	if (!nhc->nhc_pcpu_rth_output)
> +		return -ENOMEM;
> +
>  	if (encap) {
>  		struct lwtunnel_state *lwtstate;
> -		int err;
>  
>  		if (encap_type == LWTUNNEL_ENCAP_NONE) {
>  			NL_SET_ERR_MSG(extack, "LWT encap type not specified");

Failure here will leak 'nhc->nhc_pcpu_rth_output'

> @@ -502,12 +508,17 @@ int fib_nh_common_init(struct fib_nh_common *nhc, struct nlattr *encap,
>  		err = lwtunnel_build_state(encap_type, encap, nhc->nhc_family,
>  					   cfg, &lwtstate, extack);
>  		if (err)
> -			return err;
> +			goto lwt_failure;
>  
>  		nhc->nhc_lwtstate = lwtstate_get(lwtstate);
>  	}
>  
>  	return 0;
> +
> +lwt_failure:
> +	rt_fibinfo_free_cpus(nhc->nhc_pcpu_rth_output);
> +	nhc->nhc_pcpu_rth_output = NULL;
> +	return err;
>  }
>  EXPORT_SYMBOL_GPL(fib_nh_common_init);
>  
> @@ -515,18 +526,14 @@ int fib_nh_init(struct net *net, struct fib_nh *nh,
>  		struct fib_config *cfg, int nh_weight,
>  		struct netlink_ext_ack *extack)
>  {
> -	int err = -ENOMEM;
> +	int err;
>  
>  	nh->fib_nh_family = AF_INET;
>  
> -	nh->nh_pcpu_rth_output = alloc_percpu(struct rtable __rcu *);
> -	if (!nh->nh_pcpu_rth_output)
> -		goto err_out;
> -
>  	err = fib_nh_common_init(&nh->nh_common, cfg->fc_encap,
>  				 cfg->fc_encap_type, cfg, GFP_KERNEL, extack);
>  	if (err)
> -		goto init_failure;
> +		return err;
>  
>  	nh->fib_nh_oif = cfg->fc_oif;
>  	nh->fib_nh_gw_family = cfg->fc_gw_family;
> @@ -546,12 +553,6 @@ int fib_nh_init(struct net *net, struct fib_nh *nh,
>  	nh->fib_nh_weight = nh_weight;
>  #endif
>  	return 0;
> -
> -init_failure:
> -	rt_fibinfo_free_cpus(nh->nh_pcpu_rth_output);
> -	nh->nh_pcpu_rth_output = NULL;
> -err_out:
> -	return err;
>  }

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ