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]
Date: Tue, 18 Jun 2024 16:45:56 -0700
From: David Wei <dw@...idwei.uk>
To: Jakub Kicinski <kuba@...nel.org>
Cc: edward.cree@....com, linux-net-drivers@....com, davem@...emloft.com,
 edumazet@...gle.com, pabeni@...hat.com, Edward Cree
 <ecree.xilinx@...il.com>, netdev@...r.kernel.org, habetsm.xilinx@...il.com,
 sudheer.mogilappagari@...el.com, jdamato@...tly.com, mw@...ihalf.com,
 linux@...linux.org.uk, sgoutham@...vell.com, gakula@...vell.com,
 sbhatta@...vell.com, hkelam@...vell.com, saeedm@...dia.com, leon@...nel.org,
 jacob.e.keller@...el.com, andrew@...n.ch, ahmed.zaki@...el.com
Subject: Re: [PATCH v5 net-next 1/7] net: move ethtool-related netdev state
 into its own struct

On 2024-06-18 16:43, Jakub Kicinski wrote:
> On Tue, 18 Jun 2024 16:05:13 -0700 David Wei wrote:
>>> @@ -11065,6 +11065,9 @@ struct net_device *alloc_netdev_mqs(int sizeof_priv, const char *name,
>>>  	dev->real_num_rx_queues = rxqs;
>>>  	if (netif_alloc_rx_queues(dev))
>>>  		goto free_all;
>>> +	dev->ethtool = kzalloc(sizeof(*dev->ethtool), GFP_KERNEL_ACCOUNT);  
>>
>> Why GFP_KERNEL_ACCOUNT instead of just GFP_KERNEL?
> 
> netdevs can be created by a user, think veth getting created in 
> a container. So we need to account the allocated memory towards 
> the memory limit of the current user.

(Y)

> 
>>> +	if (!dev->ethtool)
>>> +		goto free_all;
>>>  
>>>  	strcpy(dev->name, name);
>>>  	dev->name_assign_type = name_assign_type;
>>> @@ -11115,6 +11118,7 @@ void free_netdev(struct net_device *dev)
>>>  		return;
>>>  	}
>>>  
>>> +	kfree(dev->ethtool);  
>>
>> dev->ethtool = NULL?
> 
> defensive programming is sometimes permitted by not encouraged :)

I've been here enough to know this bit!

But, kfree(foo) followed by foo = NULL is a common pattern I see in
kernel code. free_netdev() does it a bit further down. Is this pattern
deprecated, then?

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ