Message ID | 20240104050605.1773158-1-zack.rusin@broadcom.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-16252-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp5421372dyb; Wed, 3 Jan 2024 21:06:52 -0800 (PST) X-Google-Smtp-Source: AGHT+IGnEesl2GD69/whfq5ISPjcBigpwoH05xsRjyYIR+sPOIE+tw6BYTdJJAW4gzmHOkCCSsET X-Received: by 2002:a05:6214:29ea:b0:67f:a534:9adf with SMTP id jv10-20020a05621429ea00b0067fa5349adfmr155204qvb.18.1704344812207; Wed, 03 Jan 2024 21:06:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704344812; cv=none; d=google.com; s=arc-20160816; b=KkDcs4eekWaK9cOq8x0TDJxa0HdFfwKqnVwX8E6a3lN1AjjaQ72pFgebhHdKn1Mg2z o39+RGNOdCM+ekf4BlIPuxHQZCu2x8quxJsrhssD+GzCaPMOACrXsjjbBtxVAuPv/hOP QIZ3qj4GaLnYPQ8FUIOoZeFQNv9Itkh+WTUBa+t/+xxgx01IvbASb3BVhsFh9QNvqCF7 x2p8k7JV4WUeU02Ja247gtENHUexTnrykfJLIieYWz9ie98V2DOa4/G3hX7U4DbyzkbO skJgq+CWC+zLs815jSfA5fWYICZn86mW2WbnlLIi8TPkXnch0Qm9yNHNSinpLWXBAqv3 XG5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=H33gCbmiCN5gguVTQt+3mux0fwghJWfcdcsWeLLveeo=; fh=NjlAqUwycaxGttFqg4iPzaT1jGKpZGWXsOHM+munHTU=; b=VPJfpDfEVcdAlA7CZd2L1wTH9haHwfoHMI1Bd7g5lZTy5ySSLgrHadNrucEjVqAb8Y nIDSHP9/kprAGdW95LLSbkfawez/5N1Qasr0431G8aYvfmvlCzL3MxivSwVN+R8Ekp/E LNTzNGkdtDGw3wXvyLe0OnU8fCGq45tAi3s+gyk6luK8q7Rr2oLjhqSzqTdm/4Bzfqtk 2MlLe6agTG30Vpn8Vw5PK4Ur9b+xRuRy1nv4H/yoON/phjZqhyJusRHYKFKcsJJTNZlp KLWhLadQV8bikjQbk+/MPM7BY5CJmqxnFUrnFAsejBE3Efa5Q8mf8UkjEl4i1an8JcP9 OibA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@broadcom.com header.s=google header.b=fM6Iz2rW; spf=pass (google.com: domain of linux-kernel+bounces-16252-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-16252-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id a4-20020a0ca984000000b006807fa7c107si13871784qvb.214.2024.01.03.21.06.52 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jan 2024 21:06:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-16252-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@broadcom.com header.s=google header.b=fM6Iz2rW; spf=pass (google.com: domain of linux-kernel+bounces-16252-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-16252-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 057A21C24BA5 for <ouuuleilei@gmail.com>; Thu, 4 Jan 2024 05:06:52 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B39DF1BDD6; Thu, 4 Jan 2024 05:06:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="fM6Iz2rW" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-pl1-f182.google.com (mail-pl1-f182.google.com [209.85.214.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B395715485 for <linux-kernel@vger.kernel.org>; Thu, 4 Jan 2024 05:06:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=broadcom.com Received: by mail-pl1-f182.google.com with SMTP id d9443c01a7336-1d420aaa2abso708675ad.3 for <linux-kernel@vger.kernel.org>; Wed, 03 Jan 2024 21:06:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1704344780; x=1704949580; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=H33gCbmiCN5gguVTQt+3mux0fwghJWfcdcsWeLLveeo=; b=fM6Iz2rWnlkCnJ2AAGjTgFN77xMNaEFKhTPkisoahrqnVBg6205GZP2A2i8Nv8B27b 8RL3MPCDZGBwHzXdpGABKQp+EdZa59l9/b8y/YnElU+xRc9MLjCnuz0iMx+gxYog9zGP gvwKPvyOdxW4OjdBta2bknVLIv+MtQVVu7iVY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704344780; x=1704949580; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=H33gCbmiCN5gguVTQt+3mux0fwghJWfcdcsWeLLveeo=; b=sbV/N7odmNreN1/uu8cP7OrJA25boo9YwMrsIb8ZS2RNsiLhzvJic2tcUvyv+MyMJ4 bQM9jeEUziw2hT9foDZwJ0MX3F2941HxjIJPt+IOWeXaTxgy0ITO25BfMoOKYcJy+3a4 nQoRpKmnrNpgwVd2ptP2LSyuUd0C4WlY4WeJ7sy5JmnjgEUSh8oGmRq1B7Yl83P75F9M yj4/fGo0oKo1D4c87v99t6tKoJFP2cncrMlJuSIQqFJas0vYFIpBQyj1f7bdOIXB5PYC wG6zsbsQsxU0+ocXedIXGLzDV54ed+1I5AFDcviZCGZUOBAPWWimTnOLN9/YeW4ysGd1 f7/A== X-Gm-Message-State: AOJu0YyZG/xKOfb13jJJez1Qgqfb/zT348UkCJmkYvmQg1cHShnL0XNj 05Nid3TYJqSRuLAaCa49//u5gDs6kxcP44QAzWugHUj13LIVmwI45SZeYXVqQVAPg5GB+p3Tfa3 AFobWIcdU4YRKZkjekqg8ya7X8VfuFt+NyRxFQXMDgdHVNmh8XAYSsQmGqXZ/OcO9s0LniGMuDP 6ZTi+EHN4rAD/RTtFG X-Received: by 2002:a17:903:1210:b0:1d4:4ae9:a23d with SMTP id l16-20020a170903121000b001d44ae9a23dmr55700plh.57.1704344779784; Wed, 03 Jan 2024 21:06:19 -0800 (PST) Received: from vertex.vmware.com (pool-173-49-113-140.phlapa.fios.verizon.net. [173.49.113.140]) by smtp.gmail.com with ESMTPSA id z3-20020a170902ee0300b001d3561680aasm24505803plb.82.2024.01.03.21.06.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Jan 2024 21:06:19 -0800 (PST) From: Zack Rusin <zack.rusin@broadcom.com> To: linux-kernel@vger.kernel.org Cc: Zack Rusin <zack.rusin@broadcom.com>, 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, stable@vger.kernel.org Subject: [PATCH v2] input/vmmouse: Fix device name copies Date: Thu, 4 Jan 2024 00:06:05 -0500 Message-Id: <20240104050605.1773158-1-zack.rusin@broadcom.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231127204206.3593559-1-zack@kde.org> References: <20231127204206.3593559-1-zack@kde.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783751786082315107 X-GMAIL-MSGID: 1787135065669481715 |
Series |
[v2] input/vmmouse: Fix device name copies
|
|
Commit Message
Zack Rusin
Jan. 4, 2024, 5:06 a.m. UTC
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(-)
Comments
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
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
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
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
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
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)
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 */