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: <20210526170556.31336a06@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com>
Date:   Wed, 26 May 2021 17:05:56 -0700
From:   Jakub Kicinski <kuba@...nel.org>
To:     Jiri Pirko <jiri@...nulli.us>
Cc:     netdev@...r.kernel.org, davem@...emloft.net, mlxsw@...dia.com
Subject: Re: [patch net-next] devlink: append split port number to the port
 name

On Wed, 26 May 2021 12:35:08 +0200 Jiri Pirko wrote:
> From: Jiri Pirko <jiri@...dia.com>
> 
> Instead of doing sprintf twice in case the port is split or not, append
> the split port suffix in case the port is split.
> 
> Signed-off-by: Jiri Pirko <jiri@...dia.com>

> diff --git a/net/core/devlink.c b/net/core/devlink.c
> index 06b2b1941dce..c7754c293010 100644
> --- a/net/core/devlink.c
> +++ b/net/core/devlink.c
> @@ -8632,12 +8632,10 @@ static int __devlink_port_phys_port_name_get(struct devlink_port *devlink_port,
>  	switch (attrs->flavour) {
>  	case DEVLINK_PORT_FLAVOUR_PHYSICAL:
>  	case DEVLINK_PORT_FLAVOUR_VIRTUAL:
> -		if (!attrs->split)
> -			n = snprintf(name, len, "p%u", attrs->phys.port_number);
> -		else
> -			n = snprintf(name, len, "p%us%u",
> -				     attrs->phys.port_number,
> -				     attrs->phys.split_subport_number);
> +		n = snprintf(name, len, "p%u", attrs->phys.port_number);

snprintf() can return n > len, you need to check for this before
passing len - n as an unsigned argument below.

> +		if (attrs->split)
> +			n += snprintf(name + n, len - n, "s%u",
> +				      attrs->phys.split_subport_number);
>  		break;
>  	case DEVLINK_PORT_FLAVOUR_CPU:
>  	case DEVLINK_PORT_FLAVOUR_DSA:

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ