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: <20230319165432.5dj3stwgz4aoluf2@pali>
Date:   Sun, 19 Mar 2023 17:54:32 +0100
From:   Pali Rohár <pali@...nel.org>
To:     msizanoen <msizanoen@...labs.xyz>
Cc:     Dmitry Torokhov <dmitry.torokhov@...il.com>,
        Hans de Goede <hdegoede@...hat.com>, stable@...r.kernel.org,
        linux-input@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] input: alps: fix compatibility with -funsigned-char

On Sunday 19 March 2023 16:56:11 msizanoen wrote:
> Patch confirmed working as expected on real hardware.
> 
> Tested-by: msizanoen <msizanoen@...labs.xyz>

Thank you for testing. Patch looks good, you can add my:

Reviewed-by: Pali Rohár <pali@...nel.org>

Anyway, for future, what do you think about using of s8 and u8 types?
It could prevent this signdness char nightmare.

> On 3/18/23 21:42, msizanoen wrote:
> > The AlpsPS/2 code previously relied on the assumption that `char` is a
> > signed type, which was true on x86 platforms (the only place where this
> > driver is used) before kernel 6.2. However, on 6.2 and later, this
> > assumption is broken due to the introduction of -funsigned-char as a new
> > global compiler flag.
> > 
> > Fix this by explicitly specifying the signedness of `char` when sign
> > extending the values received from the device.
> > 
> > Fixes: f3f33c677699 ("Input: alps - Rushmore and v7 resolution support")
> > Cc: stable@...r.kernel.org
> > Signed-off-by: msizanoen <msizanoen@...labs.xyz>
> > ---
> >   drivers/input/mouse/alps.c | 8 ++++----
> >   1 file changed, 4 insertions(+), 4 deletions(-)
> > 
> > diff --git a/drivers/input/mouse/alps.c b/drivers/input/mouse/alps.c
> > index 989228b5a0a4..1c570d373b30 100644
> > --- a/drivers/input/mouse/alps.c
> > +++ b/drivers/input/mouse/alps.c
> > @@ -2294,20 +2294,20 @@ static int alps_get_v3_v7_resolution(struct psmouse *psmouse, int reg_pitch)
> >   	if (reg < 0)
> >   		return reg;
> > -	x_pitch = (char)(reg << 4) >> 4; /* sign extend lower 4 bits */
> > +	x_pitch = (signed char)(reg << 4) >> 4; /* sign extend lower 4 bits */
> >   	x_pitch = 50 + 2 * x_pitch; /* In 0.1 mm units */
> > -	y_pitch = (char)reg >> 4; /* sign extend upper 4 bits */
> > +	y_pitch = (signed char)reg >> 4; /* sign extend upper 4 bits */
> >   	y_pitch = 36 + 2 * y_pitch; /* In 0.1 mm units */
> >   	reg = alps_command_mode_read_reg(psmouse, reg_pitch + 1);
> >   	if (reg < 0)
> >   		return reg;
> > -	x_electrode = (char)(reg << 4) >> 4; /* sign extend lower 4 bits */
> > +	x_electrode = (signed char)(reg << 4) >> 4; /* sign extend lower 4 bits */
> >   	x_electrode = 17 + x_electrode;
> > -	y_electrode = (char)reg >> 4; /* sign extend upper 4 bits */
> > +	y_electrode = (signed char)reg >> 4; /* sign extend upper 4 bits */
> >   	y_electrode = 13 + y_electrode;
> >   	x_phys = x_pitch * (x_electrode - 1); /* In 0.1 mm units */

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ