* [PATCH] input/vmmouse: Fix device name copies
@ 2023-11-27 20:42 Zack Rusin
2023-12-03 18:41 ` Dmitry Torokhov
2024-01-04 5:06 ` [PATCH v2] " Zack Rusin
0 siblings, 2 replies; 12+ messages in thread
From: Zack Rusin @ 2023-11-27 20:42 UTC (permalink / raw)
To: linux-kernel
Cc: Zack Rusin, Dmitry Torokhov, VMware Graphics Reviewers,
Arnd Bergmann, Robert Jarzmik, Raul Rangel, linux-input, stable
From: Zack Rusin <zackr@vmware.com>
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);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Signed-off-by: Zack Rusin <zackr@vmware.com>
Fixes: 8b8be51b4fd3 ("Input: add vmmouse driver")
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: VMware Graphics Reviewers <linux-graphics-maintainer@vmware.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 | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/input/mouse/vmmouse.c b/drivers/input/mouse/vmmouse.c
index ea9eff7c8099..7248cada4c8c 100644
--- a/drivers/input/mouse/vmmouse.c
+++ b/drivers/input/mouse/vmmouse.c
@@ -72,7 +72,7 @@
*/
struct vmmouse_data {
struct input_dev *abs_dev;
- char phys[32];
+ char phys[64];
char dev_name[128];
};
--
2.39.2
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH] input/vmmouse: Fix device name copies
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
2024-01-04 5:06 ` [PATCH v2] " Zack Rusin
1 sibling, 1 reply; 12+ messages in thread
From: Dmitry Torokhov @ 2023-12-03 18:41 UTC (permalink / raw)
To: Zack Rusin
Cc: linux-kernel, VMware Graphics Reviewers, Arnd Bergmann,
Robert Jarzmik, Raul Rangel, linux-input, stable
Zack,
On Mon, Nov 27, 2023 at 03:42:06PM -0500, Zack Rusin wrote:
> From: Zack Rusin <zackr@vmware.com>
>
> 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);
> | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> Signed-off-by: Zack Rusin <zackr@vmware.com>
> Fixes: 8b8be51b4fd3 ("Input: add vmmouse driver")
> Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> Cc: VMware Graphics Reviewers <linux-graphics-maintainer@vmware.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 | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/input/mouse/vmmouse.c b/drivers/input/mouse/vmmouse.c
> index ea9eff7c8099..7248cada4c8c 100644
> --- a/drivers/input/mouse/vmmouse.c
> +++ b/drivers/input/mouse/vmmouse.c
> @@ -72,7 +72,7 @@
> */
> struct vmmouse_data {
> struct input_dev *abs_dev;
> - char phys[32];
> + char phys[64];
This simply wastes 32 bytes. It is perfectly fine to truncate phys
(which does not happen in real life).
-Wformat-truncation is disabled in normal builds, folks should stop
using it with W=1 as well.
Thanks.
--
Dmitry
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] input/vmmouse: Fix device name copies
2023-12-03 18:41 ` Dmitry Torokhov
@ 2023-12-03 20:50 ` Arnd Bergmann
2023-12-03 21:14 ` David Laight
0 siblings, 1 reply; 12+ messages in thread
From: Arnd Bergmann @ 2023-12-03 20:50 UTC (permalink / raw)
To: Dmitry Torokhov, Zack Rusin
Cc: linux-kernel, VMware Graphics Reviewers, Robert Jarzmik,
Raul Rangel, linux-input, stable
On Sun, Dec 3, 2023, at 19:41, Dmitry Torokhov wrote:
> On Mon, Nov 27, 2023 at 03:42:06PM -0500, Zack Rusin wrote:
>> From: Zack Rusin <zackr@vmware.com>
>>
>> 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);
>> | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> This simply wastes 32 bytes. It is perfectly fine to truncate phys
> (which does not happen in real life).
>
> -Wformat-truncation is disabled in normal builds, folks should stop
> using it with W=1 as well.
It does find real bugs, and we are fairly close to being able
to enable it by default once the remaining warnings are all
fixed.
It also doesn't waste any memory in this specific case since
vmmouse_data is currently at 168 bytes, which gets rounded
up to either 192 or 256 bytes anyway. I'd suggest using
the minimum size that is large enough though, in this case
39 bytes for the string I guess.
Arnd
^ permalink raw reply [flat|nested] 12+ messages in thread
* RE: [PATCH] input/vmmouse: Fix device name copies
2023-12-03 20:50 ` Arnd Bergmann
@ 2023-12-03 21:14 ` David Laight
2023-12-08 23:45 ` Dmitry Torokhov
0 siblings, 1 reply; 12+ messages in thread
From: David Laight @ 2023-12-03 21:14 UTC (permalink / raw)
To: 'Arnd Bergmann', Dmitry Torokhov, Zack Rusin
Cc: linux-kernel@vger.kernel.org, VMware Graphics Reviewers,
Robert Jarzmik, Raul Rangel, linux-input@vger.kernel.org,
stable@vger.kernel.org
From: Arnd Bergmann
> Sent: 03 December 2023 20:51
> On Sun, Dec 3, 2023, at 19:41, Dmitry Torokhov wrote:
> > On Mon, Nov 27, 2023 at 03:42:06PM -0500, Zack Rusin wrote:
> >> From: Zack Rusin <zackr@vmware.com>
> >>
> >> 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);
> >> | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> >
> > This simply wastes 32 bytes. It is perfectly fine to truncate phys
> > (which does not happen in real life).
> >
> > -Wformat-truncation is disabled in normal builds, folks should stop
> > using it with W=1 as well.
>
> It does find real bugs, and we are fairly close to being able
> to enable it by default once the remaining warnings are all
> fixed.
>
> It also doesn't waste any memory in this specific case since
> vmmouse_data is currently at 168 bytes, which gets rounded
> up to either 192 or 256 bytes anyway. I'd suggest using
> the minimum size that is large enough though, in this case
> 39 bytes for the string I guess.
That rather depends on whether any of the earlier char[] lengths
have been rounded up to a 'nice' value.
I'd also have thought that dangerous overflows would come from
unbounded %s formats, not fixed size strings or integers that are
always small.
There really ought to be a sane method of telling gcc not to bleat
about snprintf() potentially overflowing the target.
I've tried a few thing but none of them work.
IIRC using the result (in some ways) is enough, but neither
(void)snprintf(...); or if (snprintf(...)); is enough
(but they 'fix' 'warn unused result').
David
>
> Arnd
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] input/vmmouse: Fix device name copies
2023-12-03 21:14 ` David Laight
@ 2023-12-08 23:45 ` Dmitry Torokhov
0 siblings, 0 replies; 12+ messages in thread
From: Dmitry Torokhov @ 2023-12-08 23:45 UTC (permalink / raw)
To: David Laight
Cc: 'Arnd Bergmann', Zack Rusin, linux-kernel@vger.kernel.org,
VMware Graphics Reviewers, Robert Jarzmik, Raul Rangel,
linux-input@vger.kernel.org, stable@vger.kernel.org
On Sun, Dec 03, 2023 at 09:14:49PM +0000, David Laight wrote:
> From: Arnd Bergmann
> > Sent: 03 December 2023 20:51
> > On Sun, Dec 3, 2023, at 19:41, Dmitry Torokhov wrote:
> > > On Mon, Nov 27, 2023 at 03:42:06PM -0500, Zack Rusin wrote:
> > >> From: Zack Rusin <zackr@vmware.com>
> > >>
> > >> 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);
> > >> | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > >
> > > This simply wastes 32 bytes. It is perfectly fine to truncate phys
> > > (which does not happen in real life).
> > >
> > > -Wformat-truncation is disabled in normal builds, folks should stop
> > > using it with W=1 as well.
> >
> > It does find real bugs, and we are fairly close to being able
> > to enable it by default once the remaining warnings are all
> > fixed.
> >
> > It also doesn't waste any memory
... at this time ...
> > in this specific case since
> > vmmouse_data is currently at 168 bytes, which gets rounded
> > up to either 192 or 256 bytes anyway. I'd suggest using
> > the minimum size that is large enough though, in this case
> > 39 bytes for the string I guess.
This assumes we never change how our allocators work to provide better
memory packing.
>
> That rather depends on whether any of the earlier char[] lengths
> have been rounded up to a 'nice' value.
>
> I'd also have thought that dangerous overflows would come from
> unbounded %s formats, not fixed size strings or integers that are
> always small.
>
> There really ought to be a sane method of telling gcc not to bleat
> about snprintf() potentially overflowing the target.
Yes, that would be my preference before we enable this warning globally.
Thanks.
--
Dmitry
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH v2] input/vmmouse: Fix device name copies
2023-11-27 20:42 [PATCH] input/vmmouse: Fix device name copies Zack Rusin
2023-12-03 18:41 ` Dmitry Torokhov
@ 2024-01-04 5:06 ` Zack Rusin
2024-01-04 5:07 ` Zack Rusin
` (4 more replies)
1 sibling, 5 replies; 12+ messages in thread
From: Zack Rusin @ 2024-01-04 5:06 UTC (permalink / raw)
To: linux-kernel
Cc: Zack Rusin, Dmitry Torokhov, Arnd Bergmann, Robert Jarzmik,
Raul Rangel, linux-input, stable
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);
/* Mimic name setup for relative device in psmouse-base.c */
--
2.40.1
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH v2] input/vmmouse: Fix device name copies
2024-01-04 5:06 ` [PATCH v2] " Zack Rusin
@ 2024-01-04 5:07 ` Zack Rusin
2024-01-04 16:03 ` kernel test robot
` (3 subsequent siblings)
4 siblings, 0 replies; 12+ messages in thread
From: Zack Rusin @ 2024-01-04 5:07 UTC (permalink / raw)
To: linux-kernel
Cc: Dmitry Torokhov, Arnd Bergmann, Robert Jarzmik, Raul Rangel,
linux-input, stable
On Thu, Jan 4, 2024 at 12:06 AM Zack Rusin <zack.rusin@broadcom.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@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);
>
> /* 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
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v2] input/vmmouse: Fix device name copies
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
` (2 subsequent siblings)
4 siblings, 1 reply; 12+ messages in thread
From: kernel test robot @ 2024-01-04 16:03 UTC (permalink / raw)
To: Zack Rusin, linux-kernel
Cc: oe-kbuild-all, Zack Rusin, Dmitry Torokhov, Arnd Bergmann,
Robert Jarzmik, Raul Rangel, linux-input, stable
Hi Zack,
kernel test robot noticed the following build errors:
[auto build test ERROR on dtor-input/next]
[also build test ERROR on dtor-input/for-linus linus/master v6.7-rc8 next-20240104]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Zack-Rusin/input-vmmouse-Fix-device-name-copies/20240104-130724
base: https://git.kernel.org/pub/scm/linux/kernel/git/dtor/input.git next
patch link: https://lore.kernel.org/r/20240104050605.1773158-1-zack.rusin%40broadcom.com
patch subject: [PATCH v2] input/vmmouse: Fix device name copies
config: i386-buildonly-randconfig-001-20240104 (https://download.01.org/0day-ci/archive/20240104/202401042305.WdnDeo57-lkp@intel.com/config)
compiler: gcc-7 (Ubuntu 7.5.0-6ubuntu2) 7.5.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240104/202401042305.WdnDeo57-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202401042305.WdnDeo57-lkp@intel.com/
All errors (new ones prefixed by >>):
>> drivers/input/mouse/vmmouse.c:77:7: error: variably modified 'phys' at file scope
char phys[sizeof_field(struct serio, phys) +
^~~~
vim +/phys +77 drivers/input/mouse/vmmouse.c
67
68 /**
69 * struct vmmouse_data - private data structure for the vmmouse driver
70 *
71 * @abs_dev: "Absolute" device used to report absolute mouse movement.
72 * @phys: Physical path for the absolute device.
73 * @dev_name: Name attribute name for the absolute device.
74 */
75 struct vmmouse_data {
76 struct input_dev *abs_dev;
> 77 char phys[sizeof_field(struct serio, phys) +
78 strlen(VMMOUSE_PHYS_NAME_POSTFIX_STR)];
79 char dev_name[128];
80 };
81
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v2] input/vmmouse: Fix device name copies
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 19:23 ` kernel test robot
2024-01-04 22:01 ` kernel test robot
2024-01-04 22:57 ` David Laight
4 siblings, 0 replies; 12+ messages in thread
From: kernel test robot @ 2024-01-04 19:23 UTC (permalink / raw)
To: Zack Rusin, linux-kernel
Cc: oe-kbuild-all, Zack Rusin, Dmitry Torokhov, Arnd Bergmann,
Robert Jarzmik, Raul Rangel, linux-input, stable
Hi Zack,
kernel test robot noticed the following build warnings:
[auto build test WARNING on dtor-input/next]
[also build test WARNING on dtor-input/for-linus linus/master v6.7-rc8 next-20240104]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Zack-Rusin/input-vmmouse-Fix-device-name-copies/20240104-130724
base: https://git.kernel.org/pub/scm/linux/kernel/git/dtor/input.git next
patch link: https://lore.kernel.org/r/20240104050605.1773158-1-zack.rusin%40broadcom.com
patch subject: [PATCH v2] input/vmmouse: Fix device name copies
config: i386-randconfig-061-20240104 (https://download.01.org/0day-ci/archive/20240105/202401050307.tWbIHuS1-lkp@intel.com/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240105/202401050307.tWbIHuS1-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202401050307.tWbIHuS1-lkp@intel.com/
sparse warnings: (new ones prefixed by >>)
>> drivers/input/mouse/vmmouse.c:77:52: sparse: sparse: Variable length array is used.
>> drivers/input/mouse/vmmouse.c:77:14: sparse: sparse: flexible array member 'phys' is not last
vim +77 drivers/input/mouse/vmmouse.c
67
68 /**
69 * struct vmmouse_data - private data structure for the vmmouse driver
70 *
71 * @abs_dev: "Absolute" device used to report absolute mouse movement.
72 * @phys: Physical path for the absolute device.
73 * @dev_name: Name attribute name for the absolute device.
74 */
75 struct vmmouse_data {
76 struct input_dev *abs_dev;
> 77 char phys[sizeof_field(struct serio, phys) +
78 strlen(VMMOUSE_PHYS_NAME_POSTFIX_STR)];
79 char dev_name[128];
80 };
81
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v2] input/vmmouse: Fix device name copies
2024-01-04 16:03 ` kernel test robot
@ 2024-01-04 21:29 ` Zack Rusin
0 siblings, 0 replies; 12+ messages in thread
From: Zack Rusin @ 2024-01-04 21:29 UTC (permalink / raw)
To: kernel test robot
Cc: linux-kernel, oe-kbuild-all, Dmitry Torokhov, Arnd Bergmann,
Robert Jarzmik, Raul Rangel, linux-input, stable
On Thu, Jan 4, 2024 at 11:04 AM kernel test robot <lkp@intel.com> wrote:
>
> Hi Zack,
>
> kernel test robot noticed the following build errors:
>
> [auto build test ERROR on dtor-input/next]
> [also build test ERROR on dtor-input/for-linus linus/master v6.7-rc8 next-20240104]
> [If your patch is applied to the wrong git tree, kindly drop us a note.
> And when submitting patch, we suggest to use '--base' as documented in
> https://git-scm.com/docs/git-format-patch#_base_tree_information]
>
> url: https://github.com/intel-lab-lkp/linux/commits/Zack-Rusin/input-vmmouse-Fix-device-name-copies/20240104-130724
> base: https://git.kernel.org/pub/scm/linux/kernel/git/dtor/input.git next
> patch link: https://lore.kernel.org/r/20240104050605.1773158-1-zack.rusin%40broadcom.com
> patch subject: [PATCH v2] input/vmmouse: Fix device name copies
> config: i386-buildonly-randconfig-001-20240104 (https://download.01.org/0day-ci/archive/20240104/202401042305.WdnDeo57-lkp@intel.com/config)
> compiler: gcc-7 (Ubuntu 7.5.0-6ubuntu2) 7.5.0
> reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240104/202401042305.WdnDeo57-lkp@intel.com/reproduce)
>
> If you fix the issue in a separate patch/commit (i.e. not just a new version of
> the same patch/commit), kindly add following tags
> | Reported-by: kernel test robot <lkp@intel.com>
> | Closes: https://lore.kernel.org/oe-kbuild-all/202401042305.WdnDeo57-lkp@intel.com/
>
> All errors (new ones prefixed by >>):
>
> >> drivers/input/mouse/vmmouse.c:77:7: error: variably modified 'phys' at file scope
> char phys[sizeof_field(struct serio, phys) +
> ^~~~
This can be trivially fixed by using __builtin_strlen which with
fortify-strings.h is used anyway but before respining this I'll wait
to hear if this approach is ok. The sparse warning we can't do much
about because it doesn't recognize the fact that the array size is a
compile time expression.
z
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v2] input/vmmouse: Fix device name copies
2024-01-04 5:06 ` [PATCH v2] " Zack Rusin
` (2 preceding siblings ...)
2024-01-04 19:23 ` kernel test robot
@ 2024-01-04 22:01 ` kernel test robot
2024-01-04 22:57 ` David Laight
4 siblings, 0 replies; 12+ messages in thread
From: kernel test robot @ 2024-01-04 22:01 UTC (permalink / raw)
To: Zack Rusin, linux-kernel
Cc: llvm, oe-kbuild-all, Zack Rusin, Dmitry Torokhov, Arnd Bergmann,
Robert Jarzmik, Raul Rangel, linux-input, stable
Hi Zack,
kernel test robot noticed the following build errors:
[auto build test ERROR on dtor-input/next]
[also build test ERROR on dtor-input/for-linus linus/master v6.7-rc8 next-20240104]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Zack-Rusin/input-vmmouse-Fix-device-name-copies/20240104-130724
base: https://git.kernel.org/pub/scm/linux/kernel/git/dtor/input.git next
patch link: https://lore.kernel.org/r/20240104050605.1773158-1-zack.rusin%40broadcom.com
patch subject: [PATCH v2] input/vmmouse: Fix device name copies
config: i386-allmodconfig (https://download.01.org/0day-ci/archive/20240105/202401050506.N1aMF9sD-lkp@intel.com/config)
compiler: ClangBuiltLinux clang version 17.0.6 (https://github.com/llvm/llvm-project 6009708b4367171ccdbf4b5905cb6a803753fe18)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240105/202401050506.N1aMF9sD-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202401050506.N1aMF9sD-lkp@intel.com/
All error/warnings (new ones prefixed by >>):
>> drivers/input/mouse/vmmouse.c:78:5: warning: variable length array used [-Wvla]
77 | char phys[sizeof_field(struct serio, phys) +
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
78 | strlen(VMMOUSE_PHYS_NAME_POSTFIX_STR)];
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> drivers/input/mouse/vmmouse.c:77:7: error: fields must have a constant size: 'variable length array in structure' extension will never be supported
77 | char phys[sizeof_field(struct serio, phys) +
| ^
1 warning and 1 error generated.
vim +77 drivers/input/mouse/vmmouse.c
67
68 /**
69 * struct vmmouse_data - private data structure for the vmmouse driver
70 *
71 * @abs_dev: "Absolute" device used to report absolute mouse movement.
72 * @phys: Physical path for the absolute device.
73 * @dev_name: Name attribute name for the absolute device.
74 */
75 struct vmmouse_data {
76 struct input_dev *abs_dev;
> 77 char phys[sizeof_field(struct serio, phys) +
> 78 strlen(VMMOUSE_PHYS_NAME_POSTFIX_STR)];
79 char dev_name[128];
80 };
81
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 12+ messages in thread
* RE: [PATCH v2] input/vmmouse: Fix device name copies
2024-01-04 5:06 ` [PATCH v2] " Zack Rusin
` (3 preceding siblings ...)
2024-01-04 22:01 ` kernel test robot
@ 2024-01-04 22:57 ` David Laight
4 siblings, 0 replies; 12+ messages in thread
From: David Laight @ 2024-01-04 22:57 UTC (permalink / raw)
To: 'Zack Rusin', linux-kernel@vger.kernel.org
Cc: Dmitry Torokhov, Arnd Bergmann, Robert Jarzmik, Raul Rangel,
linux-input@vger.kernel.org, stable@vger.kernel.org
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)
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2024-01-04 22:57 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).