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: <f94409d7-4864-43cc-35f7-90ae319f54da@blackwall.org>
Date:   Tue, 14 Mar 2023 17:37:35 +0200
From:   Nikolay Aleksandrov <razor@...ckwall.org>
To:     Jay Vosburgh <jay.vosburgh@...onical.com>
Cc:     netdev@...r.kernel.org, monis@...taire.com, syoshida@...hat.com,
        andy@...yhouse.net, kuba@...nel.org, davem@...emloft.net,
        pabeni@...hat.com, edumazet@...gle.com,
        syzbot+9dfc3f3348729cc82277@...kaller.appspotmail.com
Subject: Re: [PATCH net v2 1/4] bonding: add bond_ether_setup helper

On 14/03/2023 17:34, Jay Vosburgh wrote:
> Nikolay Aleksandrov <razor@...ckwall.org> wrote:
> 
>> Add bond_ether_setup helper which will be used in the following patches
>> to fix all ether_setup() calls in the bonding driver. It takes care of both
>> IFF_MASTER and IFF_SLAVE flags, the former is always restored and the
>> latter only if it was set.
>>
>> Fixes: e36b9d16c6a6d ("bonding: clean muticast addresses when device changes type")
>> Fixes: 7d5cd2ce5292 ("bonding: correctly handle bonding type change on enslave failure")
>> Signed-off-by: Nikolay Aleksandrov <razor@...ckwall.org>
>> ---
>> drivers/net/bonding/bond_main.c | 12 ++++++++++++
>> 1 file changed, 12 insertions(+)
>>
>> diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
>> index 00646aa315c3..d41024ad2c18 100644
>> --- a/drivers/net/bonding/bond_main.c
>> +++ b/drivers/net/bonding/bond_main.c
>> @@ -1775,6 +1775,18 @@ void bond_lower_state_changed(struct slave *slave)
>> 		slave_err(bond_dev, slave_dev, "Error: %s\n", errmsg);	\
>> } while (0)
>>
>> +/* ether_setup() resets bond_dev's flags so we always have to restore
>> + * IFF_MASTER, and only restore IFF_SLAVE if it was set
>> + */
>> +static void bond_ether_setup(struct net_device *bond_dev)
>> +{
>> +	unsigned int slave_flag = bond_dev->flags & IFF_SLAVE;
>> +
>> +	ether_setup(bond_dev);
>> +	bond_dev->flags |= IFF_MASTER | slave_flag;
>> +	bond_dev->priv_flags &= ~IFF_TX_SKB_SHARING;
>> +}
> 
> 	Is setting IFF_MASTER always correct here?  I note that patch #2
> is replacing code that does not set IFF_MASTER, whereas patch #3 is
> replacing code that does set IFF_MASTER.
> 
> 	Presuming that this is the desired behavior, perhaps mention
> explicitly in the commentary that bond_ether_setup() is only for use on
> a bond master device.  The nomenclature "bond_dev" does imply that, but
> it's not explicit.
> 

Setting IFF_MASTER is always correct because we're talking about a bond master device.
I.e. we're restoring the flags to a bond device itself. The bugs are different because
previously I had fixed the error path (partly, missed the IFF_SLAVE), but I just noticed
the normal enslave path while fixing the IFF_SLAVE one now. :)
So yes, both paths need the same treatment for both flags.

> 	Also, why is the call to ether_setup() from bond_setup() not
> also being converted to bond_ether_setup()?

That is more of a cleanup, the one there is correct because flags are set after that.
In that case only IFF_MASTER is needed, IFF_SLAVE cannot be set. Once these are
merged in net-next I'll send a followup to use it there, too.

> 
> 	-J
> 

Thanks,
 Nik

>> +
>> /* enslave device <slave> to bond device <master> */
>> int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev,
>> 		 struct netlink_ext_ack *extack)
>> -- 
>> 2.39.2
>>
> 
> ---
> 	-Jay Vosburgh, jay.vosburgh@...onical.com

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ