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: <CACRpkdabTaVsqXOhy_QOdi3WNM3TPfEodt1miQkdcSrYWyYGxQ@mail.gmail.com>
Date: Mon, 10 Nov 2025 23:52:26 +0100
From: Linus Walleij <linus.walleij@...aro.org>
To: Jonas Jelonek <jelonek.jonas@...il.com>
Cc: Bartosz Golaszewski <brgl@...ev.pl>, Rob Herring <robh@...nel.org>, 
	Krzysztof Kozlowski <krzk+dt@...nel.org>, Conor Dooley <conor+dt@...nel.org>, Peter Rosin <peda@...ntia.se>, 
	Geert Uytterhoeven <geert+renesas@...der.be>, linux-gpio@...r.kernel.org, 
	devicetree@...r.kernel.org, linux-kernel@...r.kernel.org, 
	Thomas Richard <thomas.richard@...tlin.com>
Subject: Re: [PATCH v5 2/2] gpio: add gpio-line-mux driver

Hi Jonas,

overall I'm really happy of how this has turned out!
Sorry for not reviewing very intensely the last two weeks :(

One review comment left:

On Wed, Nov 5, 2025 at 5:36 PM Jonas Jelonek <jelonek.jonas@...il.com> wrote:

> +struct gpio_lmux {
> +       struct gpio_chip gc;
> +       struct mux_control *mux;
> +
> +       struct gpio_desc *muxed_gpio;
> +       /* dynamically sized, must be last */
> +       unsigned int gpio_mux_states[];
> +};

Dynamic arrays at the end of struct is a bit of a security pain
and we probably want to avoid them if we can.

The typical idiom should be:
...
    u32 num_gpio_mux_states;
    unsigned int gpio_mux_states[] __counted_by(num_gpio_mux_states);
};

> +static int gpio_lmux_probe(struct platform_device *pdev)
> +{
(...)
> +       ngpio = device_property_count_u32(dev, "gpio-line-mux-states");
> +       if (!ngpio)
> +               return -EINVAL;
> +
> +       size = struct_size(glm, gpio_mux_states, ngpio);
> +       glm = devm_kzalloc(dev, size, GFP_KERNEL);
> +       if (!glm)
> +               return -ENOMEM;

(...)

glm->num_gpio_mux_states = ngpio;

> +       ret = device_property_read_u32_array(dev, "gpio-line-mux-states",
> +                                            &glm->gpio_mux_states[0], ngpio);
> +       if (ret)
> +               return dev_err_probe(dev, ret, "could not get mux states\n");

We use this pattern in the core gpiolib for example.

With this addressed:
Reviewed-by: Linus Walleij <linus.walleij@...aro.org>

Yours,
Linus Walleij

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ