From: sashiko-bot@kernel.org
To: "Vicki Pfau" <vi@endrift.com>
Cc: linux-input@vger.kernel.org, dmitry.torokhov@gmail.com
Subject: Re: [PATCH v5 03/12] Input: xbox_gip - Add controllable LED support
Date: Wed, 02 Sep 2026 01:20:49 +0000 [thread overview]
Message-ID: <20260902012049.A657A1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260902010237.865772-4-vi@endrift.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] LED classdev remains registered after driver disconnect, leading to a Use-After-Free vulnerability.
--
commit c366b72f3332d21395d97672e39c1566b23f91d5
Author: Vicki Pfau <vi@endrift.com>
Input: xbox_gip - Add controllable LED support
This commit adds controllable LED support for Xbox One controllers. It supports
both monochrome white LEDs and RGBW addressable LEDs for Elite 2 controllers,
exposing them as LED class devices.
> diff --git a/drivers/input/joystick/gip/gip-core.c b/drivers/input/joystick/gip/gip-core.c
> index 11196afdce33f..23ab0768580f5 100644
> --- a/drivers/input/joystick/gip/gip-core.c
> +++ b/drivers/input/joystick/gip/gip-core.c
[ ... ]
> +static int gip_guide_led_probe(struct gip_attachment *attachment, struct device *dev)
> +{
> + int rc = 0;
> +
> + if (!gip_supports_system_message(attachment, GIP_CMD_LED, false))
> + return 0;
> +
> + if (attachment->features & GIP_FEATURE_GUIDE_COLOR) {
> + struct mc_subled *mc_led_info;
> + struct led_classdev_mc *mc_cdev = &attachment->guide_led.color;
> + struct led_classdev *cdev = &mc_cdev->led_cdev;
> +
> + mc_led_info = devm_kcalloc(dev, 4,
> + sizeof(*mc_led_info), GFP_KERNEL);
> + if (!mc_led_info)
> + return -ENOMEM;
> +
> + mc_led_info[0].color_index = LED_COLOR_ID_RED;
> + mc_led_info[0].intensity = 51;
> + mc_led_info[1].color_index = LED_COLOR_ID_GREEN;
> + mc_led_info[1].intensity = 51;
> + mc_led_info[2].color_index = LED_COLOR_ID_BLUE;
> + mc_led_info[2].intensity = 51;
> + mc_led_info[3].color_index = LED_COLOR_ID_WHITE;
> + mc_led_info[3].intensity = 51;
> +
> + mc_cdev->subled_info = mc_led_info;
> + mc_cdev->num_colors = 4;
> +
> + cdev->brightness = 51;
> + cdev->max_brightness = 255;
> + cdev->flags = LED_CORE_SUSPENDRESUME | LED_RETAIN_AT_SHUTDOWN;
> + cdev->brightness_set_blocking = gip_guide_color_led_set;
> + cdev->name = devm_kasprintf(dev, GFP_KERNEL,
> + "%s:rgb:power", dev_name(dev));
> + if (!cdev->name)
> + rc = -ENOMEM;
> +
> + if (!rc)
> + rc = devm_led_classdev_multicolor_register(dev,
> + mc_cdev);
[Severity: High]
Does binding this LED to the input device's lifecycle cause a use-after-free
if the controller is disconnected while an input event node is still open?
Since the devres action for unregistering the LED is bound to the input device
(&input->dev), the LED will remain registered as long as userspace holds an
evdev file descriptor open.
However, during driver unbind, gip_disconnect() calls:
devm_kfree(to_gip_device(attachment), attachment);
This immediately frees the attachment structure containing the registered
led_classdev and led_classdev_mc structures. Subsequent accesses to the LED's
sysfs attributes (such as changing brightness via gip_guide_color_led_set)
would then dereference this freed memory.
Should this register against the physical device instead, such as
to_gip_device(attachment), to ensure the LED is unregistered synchronously
during driver unbind?
[ ... ]
> + } else {
> + struct led_classdev *cdev = &attachment->guide_led.standard;
> +
> + cdev->max_brightness = GIP_LED_GUIDE_MAX_BRIGHTNESS;
> + cdev->brightness = GIP_LED_GUIDE_INIT_BRIGHTNESS;
> + cdev->flags = LED_CORE_SUSPENDRESUME | LED_RETAIN_AT_SHUTDOWN;
> + cdev->brightness_set_blocking = gip_guide_led_set;
> + cdev->name = devm_kasprintf(dev, GFP_KERNEL,
> + "%s:white:power", dev_name(dev));
> + if (!cdev->name)
> + return -ENOMEM;
> +
> + rc = devm_led_classdev_register(dev, cdev);
[Severity: High]
Can this similarly cause a use-after-free since the standard LED is also
registered using the input device as the devres parent?
[ ... ]
> @@ -1150,6 +1261,10 @@ static int gip_setup_input_device(struct gip_attachment *attachment)
> if (rc)
> goto err_free_device;
>
> + rc = gip_guide_led_probe(attachment, &input->dev);
[Severity: High]
By passing &input->dev instead of the physical device to gip_guide_led_probe(),
the LED lifecycle becomes tied to the input device.
Input devices only run their devres actions when the last userspace reference
is released. If the LED memory resides in attachment, shouldn't the LED be
tied to the attachment's device so that unregistration happens before the
attachment is freed?
> + if (rc)
> + gip_err(attachment, "Failed to register LEDs: %d\n", rc);
> +
> return 0;
>
> err_free_device:
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260902010237.865772-1-vi@endrift.com?part=3
next prev parent reply other threads:[~2026-09-02 1:20 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-02 1:02 [PATCH v5 00/12] Input: xbox_gip - Add new driver for Xbox GIP Vicki Pfau
2026-09-02 1:02 ` [PATCH v5 01/12] " Vicki Pfau
2026-09-02 1:28 ` sashiko-bot
2026-09-02 1:02 ` [PATCH v5 02/12] Input: xpad - Remove Xbox One support Vicki Pfau
2026-09-02 1:02 ` [PATCH v5 03/12] Input: xbox_gip - Add controllable LED support Vicki Pfau
2026-09-02 1:20 ` sashiko-bot [this message]
2026-09-02 1:02 ` [PATCH v5 04/12] Input: xbox_gip - Add HID relaying Vicki Pfau
2026-09-02 1:22 ` sashiko-bot
2026-09-02 1:02 ` [PATCH v5 05/12] Input: xbox_gip - Add battery support Vicki Pfau
2026-09-02 1:20 ` sashiko-bot
2026-09-02 1:02 ` [PATCH v5 06/12] Input: xbox_gip - Allow sending fragmented and ACME messages Vicki Pfau
2026-09-02 1:19 ` sashiko-bot
2026-09-02 1:02 ` [PATCH v5 07/12] Input: xbox_gip - Add security implementation from xone Vicki Pfau
2026-09-02 1:20 ` sashiko-bot
2026-09-02 1:02 ` [PATCH v5 08/12] Input: xbox_gip - Add arcade stick support Vicki Pfau
2026-09-02 1:24 ` sashiko-bot
2026-09-02 1:02 ` [PATCH v5 09/12] Input: xbox_gip - Add support for PDP guitar controllers Vicki Pfau
2026-09-02 1:02 ` [PATCH v5 10/12] Input: Add ABS_CLUTCH, HANDBRAKE, and SHIFTER Vicki Pfau
2026-09-02 1:23 ` sashiko-bot
2026-09-02 1:02 ` [PATCH v5 11/12] HID: Map more automobile simulation inputs Vicki Pfau
2026-09-02 1:02 ` [PATCH v5 12/12] Input: xbox_gip - Add wheel support Vicki Pfau
2026-09-02 1:33 ` sashiko-bot
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=20260902012049.A657A1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dmitry.torokhov@gmail.com \
--cc=linux-input@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=vi@endrift.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.