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: <86152a35-6d56-ebeb-e436-97426ef08e32@intel.com>
Date:   Fri, 27 Jan 2023 16:08:13 -0800
From:   Jacob Keller <jacob.e.keller@...el.com>
To:     Jiri Pirko <jiri@...nulli.us>, <netdev@...r.kernel.org>
CC:     <davem@...emloft.net>, <kuba@...nel.org>, <pabeni@...hat.com>,
        <edumazet@...gle.com>, <michael.chan@...adcom.com>,
        <yisen.zhuang@...wei.com>, <salil.mehta@...wei.com>,
        <jesse.brandeburg@...el.com>, <anthony.l.nguyen@...el.com>,
        <tariqt@...dia.com>, <saeedm@...dia.com>, <leon@...nel.org>,
        <idosch@...dia.com>, <petrm@...dia.com>, <gal@...dia.com>,
        <mailhol.vincent@...adoo.fr>
Subject: Re: [patch net-next 1/3] devlink: move devlink reload notifications
 back in between _down() and _up() calls



On 1/27/2023 7:50 AM, Jiri Pirko wrote:
> From: Jiri Pirko <jiri@...dia.com>
> 
> This effectively reverts commit 05a7f4a8dff1 ("devlink: Break parameter
> notification sequence to be before/after unload/load driver").
> 
> Cited commit resolved a problem in mlx5 params implementation,
> when param notification code accessed memory previously freed
> during reload.
> 
> Now, when the params can be registered and unregistered when devlink
> instance is registered, mlx5 code unregisters the problematic param
> during devlink reload. The fix is therefore no longer needed.
> 
> Current behavior is a it problematic, as it sends DEL notifications even
> in potential case when reload_down() call fails which might confuse
> userspace notifications listener.
> 
> So move the reload notifications back where they were originally in
> between reload_down() and reload_up() calls.
> 
> Signed-off-by: Jiri Pirko <jiri@...dia.com>
> ---

Reviewed-by: Jacob Keller <jacob.e.keller@...el.com>

>  net/devlink/leftover.c | 37 ++++++++++++++++---------------------
>  1 file changed, 16 insertions(+), 21 deletions(-)
> 
> diff --git a/net/devlink/leftover.c b/net/devlink/leftover.c
> index bd4c5d2dd612..24e20861a28b 100644
> --- a/net/devlink/leftover.c
> +++ b/net/devlink/leftover.c
> @@ -4235,12 +4235,11 @@ static void devlink_param_notify(struct devlink *devlink,
>  				 struct devlink_param_item *param_item,
>  				 enum devlink_command cmd);
>  
> -static void devlink_ns_change_notify(struct devlink *devlink,
> -				     struct net *dest_net, struct net *curr_net,
> -				     bool new)
> +static void devlink_reload_netns_change(struct devlink *devlink,
> +					struct net *curr_net,
> +					struct net *dest_net)
>  {
>  	struct devlink_param_item *param_item;
> -	enum devlink_command cmd;
>  
>  	/* Userspace needs to be notified about devlink objects
>  	 * removed from original and entering new network namespace.
> @@ -4248,18 +4247,19 @@ static void devlink_ns_change_notify(struct devlink *devlink,
>  	 * reload process so the notifications are generated separatelly.
>  	 */
>  
> -	if (!dest_net || net_eq(dest_net, curr_net))
> -		return;
> +	list_for_each_entry(param_item, &devlink->param_list, list)
> +		devlink_param_notify(devlink, 0, param_item,
> +				     DEVLINK_CMD_PARAM_DEL);
> +	devlink_notify(devlink, DEVLINK_CMD_DEL);
>  
> -	if (new)
> -		devlink_notify(devlink, DEVLINK_CMD_NEW);
> +	move_netdevice_notifier_net(curr_net, dest_net,
> +				    &devlink->netdevice_nb);
> +	write_pnet(&devlink->_net, dest_net);
>  
> -	cmd = new ? DEVLINK_CMD_PARAM_NEW : DEVLINK_CMD_PARAM_DEL;
> +	devlink_notify(devlink, DEVLINK_CMD_NEW);
>  	list_for_each_entry(param_item, &devlink->param_list, list)
> -		devlink_param_notify(devlink, 0, param_item, cmd);
> -
> -	if (!new)
> -		devlink_notify(devlink, DEVLINK_CMD_DEL);
> +		devlink_param_notify(devlink, 0, param_item,
> +				     DEVLINK_CMD_PARAM_NEW);
>  }
>  
>  static void devlink_reload_failed_set(struct devlink *devlink,
> @@ -4341,24 +4341,19 @@ int devlink_reload(struct devlink *devlink, struct net *dest_net,
>  	memcpy(remote_reload_stats, devlink->stats.remote_reload_stats,
>  	       sizeof(remote_reload_stats));
>  
> -	curr_net = devlink_net(devlink);
> -	devlink_ns_change_notify(devlink, dest_net, curr_net, false);
>  	err = devlink->ops->reload_down(devlink, !!dest_net, action, limit, extack);
>  	if (err)
>  		return err;
>  
> -	if (dest_net && !net_eq(dest_net, curr_net)) {
> -		move_netdevice_notifier_net(curr_net, dest_net,
> -					    &devlink->netdevice_nb);
> -		write_pnet(&devlink->_net, dest_net);
> -	}
> +	curr_net = devlink_net(devlink);
> +	if (dest_net && !net_eq(dest_net, curr_net))
> +		devlink_reload_netns_change(devlink, curr_net, dest_net);
>  
>  	err = devlink->ops->reload_up(devlink, action, limit, actions_performed, extack);
>  	devlink_reload_failed_set(devlink, !!err);
>  	if (err)
>  		return err;
>  
> -	devlink_ns_change_notify(devlink, dest_net, curr_net, true);
>  	WARN_ON(!(*actions_performed & BIT(action)));
>  	/* Catch driver on updating the remote action within devlink reload */
>  	WARN_ON(memcmp(remote_reload_stats, devlink->stats.remote_reload_stats,

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ