[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CABQX2QNjc7-wVZX1hZVbOjNmz+ow0xUOtn-XjpK-5p28-onpTQ@mail.gmail.com>
Date: Thu, 4 Jan 2024 00:07:45 -0500
From: Zack Rusin <zack.rusin@...adcom.com>
To: linux-kernel@...r.kernel.org
Cc: Dmitry Torokhov <dmitry.torokhov@...il.com>, Arnd Bergmann <arnd@...db.de>,
Robert Jarzmik <robert.jarzmik@...e.fr>, Raul Rangel <rrangel@...omium.org>,
linux-input@...r.kernel.org, stable@...r.kernel.org
Subject: Re: [PATCH v2] input/vmmouse: Fix device name copies
On Thu, Jan 4, 2024 at 12:06 AM Zack Rusin <zack.rusin@...adcom.com> wrote:
>
> Make sure vmmouse_data::phys can hold serio::phys (which is 32 bytes)
> plus an extra string, extend it to 64.
>
> Fixes gcc13 warnings:
> drivers/input/mouse/vmmouse.c: In function ‘vmmouse_init’:
> drivers/input/mouse/vmmouse.c:455:53: warning: ‘/input1’ directive output may be truncated writing 7 bytes into a region of size between 1 and 32 [-Wformat-truncation=]
> 455 | snprintf(priv->phys, sizeof(priv->phys), "%s/input1",
> | ^~~~~~~
> drivers/input/mouse/vmmouse.c:455:9: note: ‘snprintf’ output between 8 and 39 bytes into a destination of size 32
> 455 | snprintf(priv->phys, sizeof(priv->phys), "%s/input1",
> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 456 | psmouse->ps2dev.serio->phys);
> | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> v2: Use the exact size for the vmmouse_data::phys
>
> Signed-off-by: Zack Rusin <zack.rusin@...adcom.com>
> Fixes: 8b8be51b4fd3 ("Input: add vmmouse driver")
> Cc: Dmitry Torokhov <dmitry.torokhov@...il.com>
> Cc: Arnd Bergmann <arnd@...db.de>
> Cc: Robert Jarzmik <robert.jarzmik@...e.fr>
> Cc: Raul Rangel <rrangel@...omium.org>
> Cc: linux-input@...r.kernel.org
> Cc: <stable@...r.kernel.org> # v4.1+
> ---
> drivers/input/mouse/vmmouse.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/input/mouse/vmmouse.c b/drivers/input/mouse/vmmouse.c
> index ea9eff7c8099..74131673e2f3 100644
> --- a/drivers/input/mouse/vmmouse.c
> +++ b/drivers/input/mouse/vmmouse.c
> @@ -63,6 +63,8 @@
> #define VMMOUSE_VENDOR "VMware"
> #define VMMOUSE_NAME "VMMouse"
>
> +#define VMMOUSE_PHYS_NAME_POSTFIX_STR "/input1"
> +
> /**
> * struct vmmouse_data - private data structure for the vmmouse driver
> *
> @@ -72,7 +74,8 @@
> */
> struct vmmouse_data {
> struct input_dev *abs_dev;
> - char phys[32];
> + char phys[sizeof_field(struct serio, phys) +
> + strlen(VMMOUSE_PHYS_NAME_POSTFIX_STR)];
> char dev_name[128];
> };
>
> @@ -452,7 +455,8 @@ int vmmouse_init(struct psmouse *psmouse)
> psmouse->private = priv;
>
> /* Set up and register absolute device */
> - snprintf(priv->phys, sizeof(priv->phys), "%s/input1",
> + snprintf(priv->phys, sizeof(priv->phys),
> + "%s" VMMOUSE_PHYS_NAME_POSTFIX_STR,
> psmouse->ps2dev.serio->phys);
>
> /* Mimic name setup for relative device in psmouse-base.c */
Sorry, I missed the original discussion of this during the
VMware->Broadcom email transition. How about we just use the exact
sizing then like in the v2?
z
Powered by blists - more mailing lists