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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 8 Jun 2022 09:44:12 +0200
From:   Jiri Slaby <jirislaby@...nel.org>
To:     Ilpo Järvinen <ilpo.jarvinen@...ux.intel.com>
Cc:     Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        linux-serial <linux-serial@...r.kernel.org>,
        LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 33/36] tty/vt: consolemap: change refcount only if needed
 in con_do_clear_unimap()

On 07. 06. 22, 17:31, Ilpo Järvinen wrote:
> On Tue, 7 Jun 2022, Jiri Slaby wrote:
> 
>> con_do_clear_unimap() currently decreases and increases refcount of old
>> dictionary in a back and forth fashion. This makes the code really hard
>> to follow. Decrease the refcount only if everything went well and we
>> really allocated a new one and decoupled from the old dictionary.
>>
>> I sincerelly hope I did not make a mistake in this (ill) logic.
>>
>> Signed-off-by: Jiri Slaby <jslaby@...e.cz>
> 
> It seems fine:
> 
> Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@...ux.intel.com>
> 
> One unrelated comment below for additional cleanup opportunity.
> 
>> ---
>>   drivers/tty/vt/consolemap.c | 13 +++++++------
>>   1 file changed, 7 insertions(+), 6 deletions(-)
>>
>> diff --git a/drivers/tty/vt/consolemap.c b/drivers/tty/vt/consolemap.c
>> index 01b7e49f1f91..4d8efe74315c 100644
>> --- a/drivers/tty/vt/consolemap.c
>> +++ b/drivers/tty/vt/consolemap.c
>> @@ -535,22 +535,23 @@ static int con_do_clear_unimap(struct vc_data *vc)
>>   {
>>   	struct uni_pagedict *old = *vc->vc_uni_pagedir_loc;
>>   
>> -	if (!old || --old->refcount) {
>> +	if (!old || old->refcount > 1) {
>>   		struct uni_pagedict *new = kzalloc(sizeof(*new), GFP_KERNEL);
>> -		if (!new) {
>> -			if (old)
>> -				old->refcount++;
>> +		if (!new)
>>   			return -ENOMEM;
>> -		}
>> +
>>   		new->refcount = 1;
>>   		*vc->vc_uni_pagedir_loc = new;
>> +
>> +		if (old)
>> +			old->refcount--;
>>   	} else {
>>   		if (old == dflt)
>>   			dflt = NULL;
> 
> This seems unnecessary as con_release_unimap() already does it.

Good point -- the code is real mess... Now, the mess is more apparent, 
at least ;).

I will create a separate patch for this.

thanks,
-- 
js
suse labs

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ