From: David Laight <David.Laight@ACULAB.COM>
To: 'Zack Rusin' <zack.rusin@broadcom.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>,
Arnd Bergmann <arnd@arndb.de>,
Robert Jarzmik <robert.jarzmik@free.fr>,
Raul Rangel <rrangel@chromium.org>,
"linux-input@vger.kernel.org" <linux-input@vger.kernel.org>,
"stable@vger.kernel.org" <stable@vger.kernel.org>
Subject: RE: [PATCH v2] input/vmmouse: Fix device name copies
Date: Thu, 4 Jan 2024 22:57:10 +0000 [thread overview]
Message-ID: <645d8e19494d4a27b2ae775fee56e252@AcuMS.aculab.com> (raw)
In-Reply-To: <20240104050605.1773158-1-zack.rusin@broadcom.com>
From: Zack Rusin
> Sent: 04 January 2024 05:06
>
> 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@broadcom.com>
> Fixes: 8b8be51b4fd3 ("Input: add vmmouse driver")
> Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> Cc: Arnd Bergmann <arnd@arndb.de>
> Cc: Robert Jarzmik <robert.jarzmik@free.fr>
> Cc: Raul Rangel <rrangel@chromium.org>
> Cc: linux-input@vger.kernel.org
> Cc: <stable@vger.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);
Notwithstanding any error (fixed) or not from the gcc/build robert
or sparse that 'fix' is entirely horrible.
Related I'm guessing that dev_name[128] is either likely to
be truncated or massively far too long?
There are a few way to get gcc to STFU :-)
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
prev parent reply other threads:[~2024-01-04 22:57 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-27 20:42 [PATCH] input/vmmouse: Fix device name copies Zack Rusin
2023-12-03 18:41 ` Dmitry Torokhov
2023-12-03 20:50 ` Arnd Bergmann
2023-12-03 21:14 ` David Laight
2023-12-08 23:45 ` Dmitry Torokhov
2024-01-04 5:06 ` [PATCH v2] " Zack Rusin
2024-01-04 5:07 ` Zack Rusin
2024-01-04 16:03 ` kernel test robot
2024-01-04 21:29 ` Zack Rusin
2024-01-04 19:23 ` kernel test robot
2024-01-04 22:01 ` kernel test robot
2024-01-04 22:57 ` David Laight [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=645d8e19494d4a27b2ae775fee56e252@AcuMS.aculab.com \
--to=david.laight@aculab.com \
--cc=arnd@arndb.de \
--cc=dmitry.torokhov@gmail.com \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=robert.jarzmik@free.fr \
--cc=rrangel@chromium.org \
--cc=stable@vger.kernel.org \
--cc=zack.rusin@broadcom.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox