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] [day] [month] [year] [list]
Message-ID: <87zhtx17xg.fsf@miraculix.mork.no>
Date:   Sun, 25 Nov 2018 16:41:15 +0100
From:   Bjørn Mork <bjorn@...k.no>
To:     Eric Wong <e@...24.org>
Cc:     Henrique de Moraes Holschuh <ibm-acpi@....eng.br>,
        Shuduo Sang <shuduo.sang@...onical.com>,
        Darren Hart <dvhart@...radead.org>,
        Andy Shevchenko <andy@...radead.org>,
        linux-kernel@...r.kernel.org, ibm-acpi-devel@...ts.sourceforge.net,
        platform-driver-x86@...r.kernel.org
Subject: Re: [PATCH] platform/x86: thinkpad_acpi: add adaptive_kbd_modes parameter

Eric Wong <e@...24.org> writes:
> Bjørn Mork <bjorn@...k.no> wrote:
>
>> And then I believe you have a busy loop here:
>> 
>> > @@ -3815,20 +3838,20 @@ static int adaptive_keyboard_set_mode(int new_mode)
>> >  
>> >  static int adaptive_keyboard_get_next_mode(int mode)
>> >  {
>> > -	size_t i;
>> > -	size_t max_mode = ARRAY_SIZE(adaptive_keyboard_modes) - 1;
>> > -
>> > -	for (i = 0; i <= max_mode; i++) {
>> > -		if (adaptive_keyboard_modes[i] == mode)
>> > -			break;
>> > -	}
>> > +	int max_mode = fls(adaptive_kbd_modes);
>> > +	int new_mode = mode >= max_mode ? HOME_MODE : mode + 1;
>> >  
>> > -	if (i >= max_mode)
>> > -		i = 0;
>> > -	else
>> > -		i++;
>> > +	/* make sure the new mode is allowed by the user */
>> > +	while (!(adaptive_kbd_modes & (1 << new_mode))) {
>> > +		new_mode++;
>> > +		if (new_mode > max_mode)
>> > +			new_mode = HOME_MODE;
>> >  
>> > -	return adaptive_keyboard_modes[i];
>> > +		/* maybe the user disabled all other modes: */
>> > +		if (new_mode == mode)
>> > +			return mode;
>> > +	}
>> > +	return new_mode;
>> >  }
>
> Not a busy loop, since new_mode will reset at HOME_MODE (0)
> and then it'll hit "new_mode == mode" and remain locked in
> to the current mode.

Right.  I see it now.  Thanks for explaining.

I guess I was expecting a complete loop bypass ala

  if (!max_mode)
     return mode:

but your solution will of course work just as fine.



Bjørn

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ