All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Guanglei Zhu <zhugl3@xiaopeng.com>
Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
	 liuc63@xiaopeng.com
Subject: Re: [PATCH v2] Input: joydev - avoid an undefined shift in the legacy 0x read
Date: Mon, 9 Nov 2026 00:19:27 -0800	[thread overview]
Message-ID: <avGCAIRLN8QxPY2c@google.com> (raw)
In-Reply-To: <20261104030708.791730-1-zhugl3@xiaopeng.com>

On Wed, Nov 04, 2026 at 11:07:08AM +0800, Guanglei Zhu wrote:
> The legacy 0.x read path shifts the axis values by the calibration
> constants that JS_SET_CAL installs:
> 
>         data.x = (joydev->abs[0] / 256 + 128) >> joydev->glue.JS_CORR.x;
>         data.y = (joydev->abs[1] / 256 + 128) >> joydev->glue.JS_CORR.y;
> 
> JS_CORR is copied straight from userspace as three s32 values and
> never validated, so the shift count can be negative or wider than
> the type, which is undefined behavior: the shift compiles to
> whatever the architecture does with an out-of-range count, and the
> compiler is free to assume it cannot happen.
> 
> Clamp the shift count to the width of the shifted value.
> 
> Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
> Signed-off-by: Guanglei Zhu <zhugl3@xiaopeng.com>

Applied, thank you.

-- 
Dmitry

      reply	other threads:[~2026-11-09  8:19 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-03  8:41 [PATCH] Input: joydev - avoid an undefined shift in the legacy 0x read Guanglei Zhu
2026-11-03  8:41 ` [PATCH] Input: joydev - avoid signed overflow in the broken-axis correction Guanglei Zhu
2026-11-03  8:48   ` sashiko-bot
2026-11-03  8:55   ` [PATCH v2] " Guanglei Zhu
2026-11-04  3:38     ` Dmitry Torokhov
2026-11-04  5:50       ` [PATCH v3] " Guanglei Zhu
2026-11-04 23:45         ` Dmitry Torokhov
2026-11-04  6:02       ` Guanglei Zhu
2026-11-03  8:41 ` [PATCH] Input: adi - bound the two-stream packet merge Guanglei Zhu
2026-11-03  8:55   ` sashiko-bot
2026-11-03 11:17   ` [PATCH v2] " Guanglei Zhu
2026-11-04 22:17     ` Dmitry Torokhov
2026-11-03  8:41 ` [PATCH] Input: db9 - enlarge the Saturn multitap packet buffer Guanglei Zhu
2026-11-04 23:46   ` Dmitry Torokhov
2026-11-03  8:41 ` [PATCH] Input: lpc32xx-keys - reject matrices bigger than the hardware has Guanglei Zhu
2026-11-03 18:54   ` Dmitry Torokhov
2026-11-04  3:07     ` [PATCH v2] " Guanglei Zhu
2026-11-04  6:25       ` Dmitry Torokhov
2026-11-06  1:49         ` [PATCH v3] " Guanglei Zhu
2026-11-09  8:07           ` Dmitry Torokhov
2026-11-05 15:53       ` [PATCH v2] " sashiko-bot
2026-11-03  8:41 ` [PATCH] Input: mt6779-keypad - check the reported row and column Guanglei Zhu
2026-11-04 23:52   ` Dmitry Torokhov
2026-11-03  8:41 ` [PATCH] Input: tegra-kbc - check the pin numbers from the device tree Guanglei Zhu
2026-11-04 17:08   ` Dmitry Torokhov
2026-11-05  2:13   ` [PATCH v2] " Guanglei Zhu
2026-11-09  8:11     ` Dmitry Torokhov
2026-11-03  8:41 ` [PATCH] Input: cyapa_gen3 - clamp the reported finger count to the array Guanglei Zhu
2026-11-04 20:09   ` Dmitry Torokhov
2026-11-03 18:45 ` [PATCH] Input: joydev - avoid an undefined shift in the legacy 0x read Dmitry Torokhov
2026-11-04  3:07   ` [PATCH v2] " Guanglei Zhu
2026-11-09  8:19     ` Dmitry Torokhov [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=avGCAIRLN8QxPY2c@google.com \
    --to=dmitry.torokhov@gmail.com \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=liuc63@xiaopeng.com \
    --cc=zhugl3@xiaopeng.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.