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:   Mon, 25 Sep 2023 18:50:47 +0000
From:   "Lopez, Jorge A (Security)" <jorge.lopez2@...com>
To:     Armin Wolf <W_Armin@....de>,
        "markpearson@...ovo.com" <markpearson@...ovo.com>
CC:     "hdegoede@...hat.com" <hdegoede@...hat.com>,
        "markgross@...nel.org" <markgross@...nel.org>,
        "ilpo.jarvinen@...ux.intel.com" <ilpo.jarvinen@...ux.intel.com>,
        "platform-driver-x86@...r.kernel.org" 
        <platform-driver-x86@...r.kernel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: RE: [PATCH v4 2/2] platform/x86: hp-bioscfg: Fix reference leak

Reviewed-by: Jorge Lopez <jorge.lopez2@...com>


> -----Original Message-----
> From: Armin Wolf <W_Armin@....de>
> Sent: Monday, September 25, 2023 9:28 AM
> To: markpearson@...ovo.com; Lopez, Jorge A (Security)
> <jorge.lopez2@...com>
> Cc: hdegoede@...hat.com; markgross@...nel.org;
> ilpo.jarvinen@...ux.intel.com; platform-driver-x86@...r.kernel.org; linux-
> kernel@...r.kernel.org
> Subject: [PATCH v4 2/2] platform/x86: hp-bioscfg: Fix reference leak
> 
> CAUTION: External Email
> 
> If a duplicate attribute is found using kset_find_obj(), a reference to that
> attribute is returned which needs to be disposed accordingly using kobject_put().
> Use kobject_put() to dispose the duplicate attribute in such a case.
> As a side note, a very similar bug was fixed in commit 7295a996fdab
> ("platform/x86: dell-sysman: Fix reference leak"), so it seems that the bug was
> copied from that driver.
> 
> Compile-tested only.
> 
> Fixes: a34fc329b189 ("platform/x86: hp-bioscfg: bioscfg")
> Suggested-by: Ilpo Järvinen <ilpo.jarvinen@...ux.intel.com>
> Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@...ux.intel.com>
> Signed-off-by: Armin Wolf <W_Armin@....de>
> ---
> Chnages in v4:
> - fix missing whitespace
> - add Reviewed-by
> Changes in v3:
> - no changes
> Changes in v2:
> - add patch
> ---
>  drivers/platform/x86/hp/hp-bioscfg/bioscfg.c | 14 ++++++++++----
>  1 file changed, 10 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/platform/x86/hp/hp-bioscfg/bioscfg.c
> b/drivers/platform/x86/hp/hp-bioscfg/bioscfg.c
> index 8c4f9e12f018..5798b49ddaba 100644
> --- a/drivers/platform/x86/hp/hp-bioscfg/bioscfg.c
> +++ b/drivers/platform/x86/hp/hp-bioscfg/bioscfg.c
> @@ -659,7 +659,7 @@ static int hp_init_bios_package_attribute(enum
> hp_wmi_data_type attr_type,
>                                           const char *guid, int min_elements,
>                                           int instance_id)  {
> -       struct kobject *attr_name_kobj;
> +       struct kobject *attr_name_kobj, *duplicate;
>         union acpi_object *elements;
>         struct kset *temp_kset;
> 
> @@ -704,8 +704,11 @@ static int hp_init_bios_package_attribute(enum
> hp_wmi_data_type attr_type,
>         }
> 
>         /* All duplicate attributes found are ignored */
> -       if (kset_find_obj(temp_kset, str_value)) {
> +       duplicate = kset_find_obj(temp_kset, str_value);
> +       if (duplicate) {
>                 pr_debug("Duplicate attribute name found - %s\n", str_value);
> +               /* kset_find_obj() returns a reference */
> +               kobject_put(duplicate);
>                 goto pack_attr_exit;
>         }
> 
> @@ -768,7 +771,7 @@ static int hp_init_bios_buffer_attribute(enum
> hp_wmi_data_type attr_type,
>                                          const char *guid, int min_elements,
>                                          int instance_id)  {
> -       struct kobject *attr_name_kobj;
> +       struct kobject *attr_name_kobj, *duplicate;
>         struct kset *temp_kset;
>         char str[MAX_BUFF_SIZE];
> 
> @@ -794,8 +797,11 @@ static int hp_init_bios_buffer_attribute(enum
> hp_wmi_data_type attr_type,
>                 temp_kset = bioscfg_drv.main_dir_kset;
> 
>         /* All duplicate attributes found are ignored */
> -       if (kset_find_obj(temp_kset, str)) {
> +       duplicate = kset_find_obj(temp_kset, str);
> +       if (duplicate) {
>                 pr_debug("Duplicate attribute name found - %s\n", str);
> +               /* kset_find_obj() returns a reference */
> +               kobject_put(duplicate);
>                 goto buff_attr_exit;
>         }
> 
> --
> 2.39.2

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ