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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 05 Dec 2018 20:12:37 -0800 (PST)
From:   David Miller <davem@...emloft.net>
To:     idosch@...lanox.com
Cc:     netdev@...r.kernel.org, bridge@...ts.linux-foundation.org,
        jiri@...lanox.com, petrm@...lanox.com, roopa@...ulusnetworks.com,
        nikolay@...ulusnetworks.com, mlxsw@...lanox.com
Subject: Re: [PATCH net-next 01/12] vxlan: Add a function to init
 switchdev_notifier_vxlan_fdb_info

From: Ido Schimmel <idosch@...lanox.com>
Date: Wed, 5 Dec 2018 15:50:23 +0000

> +static struct switchdev_notifier_vxlan_fdb_info
> +vxlan_fdb_switchdev_notifier_info(const struct vxlan_dev *vxlan,
> +				  const struct vxlan_fdb *fdb,
> +				  const struct vxlan_rdst *rd)
> +{
> +	struct switchdev_notifier_vxlan_fdb_info fdb_info = {
> +		.info.dev = vxlan->dev,
> +		.remote_ip = rd->remote_ip,
> +		.remote_port = rd->remote_port,
> +		.remote_vni = rd->remote_vni,
> +		.remote_ifindex = rd->remote_ifindex,
> +		.vni = fdb->vni,
> +		.offloaded = rd->offloaded,
> +		.added_by_user = fdb->flags & NTF_VXLAN_ADDED_BY_USER,
> +	};
> +
> +	memcpy(fdb_info.eth_addr, fdb->eth_addr, ETH_ALEN);
> +	return fdb_info;
> +}

Never return a structure by value from a function.  Do you have any idea
how the compiler implement this?

In the one call site in vxlan.c after this patch is applied, _two_
switchdev_notifier_cxlan_fdb_info objects are allocated on the stack.

vxlan_fdb_swtich_dev_notifier_info() fills in the first one, and
then the caller copies that into the second one.

A huge waste.

Please just pass "&info" as an argument.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ