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: <3DQ9AO4TGVHWM.3BGLGQY972JSD@homearch.localdomain>
Date:   Wed, 14 Sep 2022 21:33:56 +0200
From:   "Silvan Jegen" <me@...lymon.ch>
To:     Johnothan King <johnothanking@...tonmail.com>
Cc:     "Daniel J. Ogorchock" <djogorchock@...il.com>,
        Jiri Kosina <jikos@...nel.org>,
        Benjamin Tissoires <benjamin.tissoires@...hat.com>,
        "linux-input@...r.kernel.org" <linux-input@...r.kernel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] HID: nintendo: check analog user calibration for
 plausibility

Hi

Johnothan King <johnothanking@...tonmail.com> wrote:
> Arne Wendt writes:
>   Cheap clone controllers may (falsely) report as having a user
>   calibration for the analog sticks in place, but return
>   wrong/impossible values for the actual calibration data.
>   In the present case at mine, the controller reports having a
>   user calibration in place and successfully executes the read
>   commands. The reported user calibration however is
>   min = center = max = 0.
> 
>   This pull request addresses problems of this kind by checking the
>   provided user calibration-data for plausibility (min < center < max)
>   and falling back to the default values if implausible.
> 
> I'll note that I was experiencing a crash because of this bug when using
> the GuliKit KingKong 2 controller. The crash manifests as a divide by
> zero error in the kernel logs:
> kernel: divide error: 0000 [#1] PREEMPT SMP NOPTI
> 
> Link: https://github.com/nicman23/dkms-hid-nintendo/pull/25
> Link: https://github.com/DanielOgorchock/linux/issues/36
> Co-authored-by: Arne Wendt <arne.wendt@...h.de>
> Signed-off-by: Johnothan King <johnothanking@...tonmail.com>
> ---
>  drivers/hid/hid-nintendo.c | 24 ++++++++++++++++++++++--
>  1 file changed, 22 insertions(+), 2 deletions(-)

Reviewed-by: Silvan Jegen <s.jegen@...il.com>

I have actually hit this issue as well ...


Cheers,
Silvan

> 
> diff --git a/drivers/hid/hid-nintendo.c b/drivers/hid/hid-nintendo.c
> index 6028af3c3aae..7f287f6a75f5 100644
> --- a/drivers/hid/hid-nintendo.c
> +++ b/drivers/hid/hid-nintendo.c
> @@ -793,7 +793,17 @@ static int joycon_request_calibration(struct joycon_ctlr *ctlr)
>  					    &ctlr->left_stick_cal_x,
>  					    &ctlr->left_stick_cal_y,
>  					    true);
> -	if (ret) {
> +
> +	/*
> +	 * Check whether read succeeded and perform plausibility check
> +	 * for retrieved values.
> +	 */
> +	if (ret ||
> +		ctlr->left_stick_cal_x.min >= ctlr->left_stick_cal_x.center ||
> +		ctlr->left_stick_cal_x.center >= ctlr->left_stick_cal_x.max ||
> +		ctlr->left_stick_cal_y.min >= ctlr->left_stick_cal_y.center ||
> +		ctlr->left_stick_cal_y.center >= ctlr->left_stick_cal_y.max
> +	) {
>  		hid_warn(ctlr->hdev,
>  			 "Failed to read left stick cal, using dflts; e=%d\n",
>  			 ret);
> @@ -812,7 +822,17 @@ static int joycon_request_calibration(struct joycon_ctlr *ctlr)
>  					    &ctlr->right_stick_cal_x,
>  					    &ctlr->right_stick_cal_y,
>  					    false);
> -	if (ret) {
> +
> +	/*
> +	 * Check whether read succeeded and perform plausibility check
> +	 * for retrieved values.
> +	 */
> +	if (ret ||
> +		ctlr->right_stick_cal_x.min >= ctlr->right_stick_cal_x.center ||
> +		ctlr->right_stick_cal_x.center >= ctlr->right_stick_cal_x.max ||
> +		ctlr->right_stick_cal_y.min >= ctlr->right_stick_cal_y.center ||
> +		ctlr->right_stick_cal_y.center >= ctlr->right_stick_cal_y.max
> +	) {
>  		hid_warn(ctlr->hdev,
>  			 "Failed to read right stick cal, using dflts; e=%d\n",
>  			 ret);


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ