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: <3ab4081c-7d14-b39c-cc20-a76d414efff0@gmx.de>
Date:   Fri, 31 Mar 2023 23:20:53 +0200
From:   Armin Wolf <W_Armin@....de>
To:     Mark Pearson <mpearson-lenovo@...ebb.ca>,
        Mark Pearson <markpearson@...ovo.com>,
        Mirsad Goran Todorovac <mirsad.todorovac@....unizg.hr>
Cc:     Hans de Goede <hdegoede@...hat.com>,
        "markgross@...nel.org" <markgross@...nel.org>,
        Thomas Weißschuh <thomas@...ch.de>,
        Greg KH <gregkh@...uxfoundation.org>,
        "Rafael J. Wysocki" <rafael@...nel.org>,
        "platform-driver-x86@...r.kernel.org" 
        <platform-driver-x86@...r.kernel.org>, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2] platform/x86: think-lmi: Fix memory leak when showing
 current settings

Am 31.03.23 um 21:14 schrieb Mark Pearson:

> Hi Armin
>
> On Fri, Mar 31, 2023, at 2:09 PM, Armin Wolf wrote:
>> When retriving a item string with tlmi_setting(), the result has to be
>> freed using kfree(). In current_value_show() however, malformed
>> item strings are not freed, causing a memory leak.
>> Fix this by eliminating the early return responsible for this.
>>
>> Reported-by: Mirsad Goran Todorovac <mirsad.todorovac@....unizg.hr>
>> Link:
>> https://lore.kernel.org/platform-driver-x86/01e920bc-5882-ba0c-dd15-868bf0eca0b8@alu.unizg.hr/T/#t
>> Fixes: a40cd7ef22fb ("platform/x86: think-lmi: Add WMI interface
>> support on Lenovo platforms")
>> Signed-off-by: Armin Wolf <W_Armin@....de>
>> ---
>> Changes in v2:
>> - Add Reported-by: and Link: tags
>> ---
>>   drivers/platform/x86/think-lmi.c | 6 ++++--
>>   1 file changed, 4 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/platform/x86/think-lmi.c
>> b/drivers/platform/x86/think-lmi.c
>> index cc66f7cbccf2..8cafb9d4016c 100644
>> --- a/drivers/platform/x86/think-lmi.c
>> +++ b/drivers/platform/x86/think-lmi.c
>> @@ -930,10 +930,12 @@ static ssize_t current_value_show(struct kobject
>> *kobj, struct kobj_attribute *a
>>   	/* validate and split from `item,value` -> `value` */
>>   	value = strpbrk(item, ",");
>>   	if (!value || value == item || !strlen(value + 1))
>> -		return -EINVAL;
>> +		ret = -EINVAL;
>> +	else
>> +		ret = sysfs_emit(buf, "%s\n", value + 1);
>>
>> -	ret = sysfs_emit(buf, "%s\n", value + 1);
>>   	kfree(item);
>> +
>>   	return ret;
>>   }
>>
>> --
>> 2.30.2
> Thanks for doing this - it was on my todo list but you beat me to it.
>
> As a minor note - the Fixes tag should, I think, be
> Fixes: 0fdf10e5fc96 ("platform/x86: think-lmi: Split current_value to reflect only the value")
>
> As that's when I believe I introduced the issue.
>
> Mark

Hi,

you are correct, i will send a v3 soon.

Armin Wolf

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ