From: Dan Carpenter <dan.carpenter@linaro.org>
To: oe-kbuild@lists.linux.dev, Ivan Vecera <ivecera@redhat.com>,
netdev@vger.kernel.org
Cc: lkp@intel.com, oe-kbuild-all@lists.linux.dev,
Jiri Pirko <jiri@resnulli.us>, Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Simon Horman <horms@kernel.org>, Jonathan Corbet <corbet@lwn.net>,
Prathosh Satish <Prathosh.Satish@microchip.com>,
linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
Michal Schmidt <mschmidt@redhat.com>,
Petr Oros <poros@redhat.com>,
Przemek Kitszel <przemyslaw.kitszel@intel.com>
Subject: Re: [PATCH net-next v3 3/5] dpll: zl3073x: Add firmware loading functionality
Date: Wed, 20 Aug 2025 09:40:23 +0300 [thread overview]
Message-ID: <202508200929.zEY4ejFt-lkp@intel.com> (raw)
In-Reply-To: <20250813174408.1146717-4-ivecera@redhat.com>
Hi Ivan,
kernel test robot noticed the following build warnings:
url: https://github.com/intel-lab-lkp/linux/commits/Ivan-Vecera/dpll-zl3073x-Add-functions-to-access-hardware-registers/20250814-014831
base: net-next/main
patch link: https://lore.kernel.org/r/20250813174408.1146717-4-ivecera%40redhat.com
patch subject: [PATCH net-next v3 3/5] dpll: zl3073x: Add firmware loading functionality
config: xtensa-randconfig-r073-20250819 (https://download.01.org/0day-ci/archive/20250820/202508200929.zEY4ejFt-lkp@intel.com/config)
compiler: xtensa-linux-gcc (GCC) 9.5.0
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>
| Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
| Closes: https://lore.kernel.org/r/202508200929.zEY4ejFt-lkp@intel.com/
smatch warnings:
drivers/dpll/zl3073x/fw.c:239 zl3073x_fw_component_load() warn: potential user controlled sizeof overflow 'count * 4' '0-u32max * 4'
vim +239 drivers/dpll/zl3073x/fw.c
cd5cfd9ddd76800 Ivan Vecera 2025-08-13 202 static ssize_t
cd5cfd9ddd76800 Ivan Vecera 2025-08-13 203 zl3073x_fw_component_load(struct zl3073x_dev *zldev,
cd5cfd9ddd76800 Ivan Vecera 2025-08-13 204 struct zl3073x_fw_component **pcomp,
cd5cfd9ddd76800 Ivan Vecera 2025-08-13 205 const char **psrc, size_t *psize,
cd5cfd9ddd76800 Ivan Vecera 2025-08-13 206 struct netlink_ext_ack *extack)
cd5cfd9ddd76800 Ivan Vecera 2025-08-13 207 {
cd5cfd9ddd76800 Ivan Vecera 2025-08-13 208 const struct zl3073x_fw_component_info *info;
cd5cfd9ddd76800 Ivan Vecera 2025-08-13 209 struct zl3073x_fw_component *comp = NULL;
cd5cfd9ddd76800 Ivan Vecera 2025-08-13 210 struct device *dev = zldev->dev;
cd5cfd9ddd76800 Ivan Vecera 2025-08-13 211 enum zl3073x_fw_component_id id;
cd5cfd9ddd76800 Ivan Vecera 2025-08-13 212 char buf[32], name[16];
cd5cfd9ddd76800 Ivan Vecera 2025-08-13 213 u32 count, size, *dest;
cd5cfd9ddd76800 Ivan Vecera 2025-08-13 214 int pos, rc;
cd5cfd9ddd76800 Ivan Vecera 2025-08-13 215
cd5cfd9ddd76800 Ivan Vecera 2025-08-13 216 /* Fetch image name and size from input */
cd5cfd9ddd76800 Ivan Vecera 2025-08-13 217 strscpy(buf, *psrc, min(sizeof(buf), *psize));
cd5cfd9ddd76800 Ivan Vecera 2025-08-13 218 rc = sscanf(buf, "%15s %u %n", name, &count, &pos);
cd5cfd9ddd76800 Ivan Vecera 2025-08-13 219 if (!rc) {
cd5cfd9ddd76800 Ivan Vecera 2025-08-13 220 /* No more data */
cd5cfd9ddd76800 Ivan Vecera 2025-08-13 221 return 0;
cd5cfd9ddd76800 Ivan Vecera 2025-08-13 222 } else if (rc == 1) {
cd5cfd9ddd76800 Ivan Vecera 2025-08-13 223 ZL3073X_FW_ERR_MSG(zldev, extack, "invalid component size");
cd5cfd9ddd76800 Ivan Vecera 2025-08-13 224 return -EINVAL;
cd5cfd9ddd76800 Ivan Vecera 2025-08-13 225 }
cd5cfd9ddd76800 Ivan Vecera 2025-08-13 226 *psrc += pos;
cd5cfd9ddd76800 Ivan Vecera 2025-08-13 227 *psize -= pos;
cd5cfd9ddd76800 Ivan Vecera 2025-08-13 228
cd5cfd9ddd76800 Ivan Vecera 2025-08-13 229 dev_dbg(dev, "Firmware component '%s' found\n", name);
cd5cfd9ddd76800 Ivan Vecera 2025-08-13 230
cd5cfd9ddd76800 Ivan Vecera 2025-08-13 231 id = zl3073x_fw_component_id_get(name);
cd5cfd9ddd76800 Ivan Vecera 2025-08-13 232 if (id == ZL_FW_COMPONENT_INVALID) {
cd5cfd9ddd76800 Ivan Vecera 2025-08-13 233 ZL3073X_FW_ERR_MSG(zldev, extack, "unknown component type '%s'",
cd5cfd9ddd76800 Ivan Vecera 2025-08-13 234 name);
cd5cfd9ddd76800 Ivan Vecera 2025-08-13 235 return -EINVAL;
cd5cfd9ddd76800 Ivan Vecera 2025-08-13 236 }
cd5cfd9ddd76800 Ivan Vecera 2025-08-13 237
cd5cfd9ddd76800 Ivan Vecera 2025-08-13 238 info = &component_info[id];
cd5cfd9ddd76800 Ivan Vecera 2025-08-13 @239 size = count * sizeof(u32); /* get size in bytes */
This is an integer overflow. Imagine count is 0x80000001. That means
size is 4.
cd5cfd9ddd76800 Ivan Vecera 2025-08-13 240
cd5cfd9ddd76800 Ivan Vecera 2025-08-13 241 /* Check image size validity */
cd5cfd9ddd76800 Ivan Vecera 2025-08-13 242 if (size > component_info[id].max_size) {
size is valid.
cd5cfd9ddd76800 Ivan Vecera 2025-08-13 243 ZL3073X_FW_ERR_MSG(zldev, extack,
cd5cfd9ddd76800 Ivan Vecera 2025-08-13 244 "[%s] component is too big (%u bytes)\n",
cd5cfd9ddd76800 Ivan Vecera 2025-08-13 245 info->name, size);
cd5cfd9ddd76800 Ivan Vecera 2025-08-13 246 return -EINVAL;
cd5cfd9ddd76800 Ivan Vecera 2025-08-13 247 }
cd5cfd9ddd76800 Ivan Vecera 2025-08-13 248
cd5cfd9ddd76800 Ivan Vecera 2025-08-13 249 dev_dbg(dev, "Indicated component image size: %u bytes\n", size);
cd5cfd9ddd76800 Ivan Vecera 2025-08-13 250
cd5cfd9ddd76800 Ivan Vecera 2025-08-13 251 /* Alloc component */
cd5cfd9ddd76800 Ivan Vecera 2025-08-13 252 comp = zl3073x_fw_component_alloc(size);
The allocation succeeds.
cd5cfd9ddd76800 Ivan Vecera 2025-08-13 253 if (!comp) {
cd5cfd9ddd76800 Ivan Vecera 2025-08-13 254 ZL3073X_FW_ERR_MSG(zldev, extack, "failed to alloc memory");
cd5cfd9ddd76800 Ivan Vecera 2025-08-13 255 return -ENOMEM;
cd5cfd9ddd76800 Ivan Vecera 2025-08-13 256 }
cd5cfd9ddd76800 Ivan Vecera 2025-08-13 257 comp->id = id;
cd5cfd9ddd76800 Ivan Vecera 2025-08-13 258
cd5cfd9ddd76800 Ivan Vecera 2025-08-13 259 /* Load component data from firmware source */
cd5cfd9ddd76800 Ivan Vecera 2025-08-13 260 for (dest = comp->data; count; count--, dest++) {
But count is invalid so so we will loop 134 million times.
cd5cfd9ddd76800 Ivan Vecera 2025-08-13 261 strscpy(buf, *psrc, min(sizeof(buf), *psize));
cd5cfd9ddd76800 Ivan Vecera 2025-08-13 262 rc = sscanf(buf, "%x %n", dest, &pos);
cd5cfd9ddd76800 Ivan Vecera 2025-08-13 263 if (!rc)
cd5cfd9ddd76800 Ivan Vecera 2025-08-13 264 goto err_data;
cd5cfd9ddd76800 Ivan Vecera 2025-08-13 265
cd5cfd9ddd76800 Ivan Vecera 2025-08-13 266 *psrc += pos;
cd5cfd9ddd76800 Ivan Vecera 2025-08-13 267 *psize -= pos;
cd5cfd9ddd76800 Ivan Vecera 2025-08-13 268 }
cd5cfd9ddd76800 Ivan Vecera 2025-08-13 269
cd5cfd9ddd76800 Ivan Vecera 2025-08-13 270 *pcomp = comp;
cd5cfd9ddd76800 Ivan Vecera 2025-08-13 271
cd5cfd9ddd76800 Ivan Vecera 2025-08-13 272 return 1;
cd5cfd9ddd76800 Ivan Vecera 2025-08-13 273
cd5cfd9ddd76800 Ivan Vecera 2025-08-13 274 err_data:
cd5cfd9ddd76800 Ivan Vecera 2025-08-13 275 ZL3073X_FW_ERR_MSG(zldev, extack, "[%s] invalid or missing data",
cd5cfd9ddd76800 Ivan Vecera 2025-08-13 276 info->name);
cd5cfd9ddd76800 Ivan Vecera 2025-08-13 277
cd5cfd9ddd76800 Ivan Vecera 2025-08-13 278 zl3073x_fw_component_free(comp);
cd5cfd9ddd76800 Ivan Vecera 2025-08-13 279
cd5cfd9ddd76800 Ivan Vecera 2025-08-13 280 return -ENODATA;
cd5cfd9ddd76800 Ivan Vecera 2025-08-13 281 }
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
next prev parent reply other threads:[~2025-08-20 6:40 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-13 17:44 [PATCH net-next v3 0/5] dpll: zl3073x: Add support for devlink flash Ivan Vecera
2025-08-13 17:44 ` [PATCH net-next v3 1/5] dpll: zl3073x: Add functions to access hardware registers Ivan Vecera
2025-08-13 17:44 ` [PATCH net-next v3 2/5] dpll: zl3073x: Add low-level flash functions Ivan Vecera
2025-08-13 17:44 ` [PATCH net-next v3 3/5] dpll: zl3073x: Add firmware loading functionality Ivan Vecera
2025-08-19 2:22 ` Jakub Kicinski
2025-08-29 10:39 ` Ivan Vecera
2025-08-29 23:52 ` Jakub Kicinski
2025-08-20 6:40 ` Dan Carpenter [this message]
2025-08-29 10:31 ` Ivan Vecera
2025-08-13 17:44 ` [PATCH net-next v3 4/5] dpll: zl3073x: Refactor DPLL initialization Ivan Vecera
2025-08-13 17:44 ` [PATCH net-next v3 5/5] dpll: zl3073x: Implement devlink flash callback Ivan Vecera
2025-08-19 2:29 ` Jakub Kicinski
2025-08-29 14:49 ` Ivan Vecera
2025-08-29 23:56 ` Jakub Kicinski
2025-09-01 16:34 ` Ivan Vecera
2025-09-01 17:05 ` Jakub Kicinski
2025-08-14 9:30 ` [PATCH net-next v3 0/5] dpll: zl3073x: Add support for devlink flash Przemek Kitszel
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=202508200929.zEY4ejFt-lkp@intel.com \
--to=dan.carpenter@linaro.org \
--cc=Prathosh.Satish@microchip.com \
--cc=corbet@lwn.net \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=ivecera@redhat.com \
--cc=jiri@resnulli.us \
--cc=kuba@kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lkp@intel.com \
--cc=mschmidt@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=oe-kbuild-all@lists.linux.dev \
--cc=oe-kbuild@lists.linux.dev \
--cc=pabeni@redhat.com \
--cc=poros@redhat.com \
--cc=przemyslaw.kitszel@intel.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;
as well as URLs for NNTP newsgroup(s).