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: <b9dc2c7a-2688-4a7b-8482-1e762c39449c@intel.com>
Date: Thu, 21 Mar 2024 15:27:47 -0700
From: Jesse Brandeburg <jesse.brandeburg@...el.com>
To: Julia Lawall <Julia.Lawall@...ia.fr>, Jakub Kicinski <kuba@...nel.org>
CC: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>, Dan Carpenter
	<dan.carpenter@...aro.org>, <kernel-janitors@...r.kernel.org>,
	<netdev@...r.kernel.org>, <intel-wired-lan@...ts.osuosl.org>, "Maciej
 Fijalkowski" <maciej.fijalkowski@...el.com>, Przemek Kitszel
	<przemyslaw.kitszel@...el.com>, Tony Nguyen <anthony.l.nguyen@...el.com>,
	LKML <linux-kernel@...r.kernel.org>, Alexander Lobakin
	<aleksander.lobakin@...el.com>, David Laight <David.Laight@...lab.com>,
	"David S. Miller" <davem@...emloft.net>, Eric Dumazet <edumazet@...gle.com>,
	Jakub Kicinski <kuba@...nel.org>, Jiri Pirko <jiri@...nulli.us>, "Jonathan
 Cameron" <jic23@...nel.org>, Kees Cook <keescook@...omium.org>, Lukasz
 Czapnik <lukasz.czapnik@...el.com>, Paolo Abeni <pabeni@...hat.com>, "Pucha
 Himasekhar Reddy" <himasekharx.reddy.pucha@...el.com>, Markus Elfring
	<Markus.Elfring@....de>, Dan Williams <dan.j.williams@...el.com>
Subject: Re: [PATCH net] ice: Fix freeing uninitialized pointers

On 3/21/2024 1:20 PM, Julia Lawall wrote:
> Does one prefer an initialization of null at the top of the function
> or an initialization to a meaningful value in the middle of the
> function ?

I think the latter.

There was a related patch explaining the direction, from Dan posted here:
https://lore.kernel.org/all/171097196970.1011049.9726486429680041876.stgit@dwillia2-xfh.jf.intel.com/

We had been having some internal discussions about use of __free(kfree) 
in the ice driver.

The gist of it is that we should instead be using inline declarations, 
which I also agree is a reasonable style for this. It more clearly shows 
the __free(kfree) and the allocation (kzalloc, kcalloc, etc) on the same 
(or virtually the same) line of code.

I'm curious if Jakub would dislike this less? Accept?

as an example:
diff --git a/drivers/net/ethernet/intel/ice/ice_common.c 
b/drivers/net/ethernet/intel/ice/ice_common.c
index 88c86de82e09..822628d25b2f 100644
--- a/drivers/net/ethernet/intel/ice/ice_common.c
+++ b/drivers/net/ethernet/intel/ice/ice_common.c
@@ -1003,8 +1003,6 @@ static void ice_get_itr_intrl_gran(struct ice_hw *hw)
   */
  int ice_init_hw(struct ice_hw *hw)
  {
-       struct ice_aqc_get_phy_caps_data *pcaps __free(kfree) = NULL;
         void *mac_buf __free(kfree) = NULL;
         u16 mac_buf_len;
         int status;

@@ -1083,7 +1081,8 @@ int ice_init_hw(struct ice_hw *hw)
         if (status)
                 goto err_unroll_sched;

-       pcaps = kzalloc(sizeof(*pcaps), GFP_KERNEL);
+       struct ice_aqc_get_phy_caps_data *pcaps __free(kfree) =
+               kzalloc(sizeof(*pcaps), GFP_KERNEL);
         if (!pcaps) {
                 status = -ENOMEM;
                 goto err_unroll_sched;

Any thoughts?

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ