lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <202210120137.797H4cj3-lkp@intel.com>
Date:   Wed, 12 Oct 2022 01:55:54 +0800
From:   kernel test robot <lkp@...el.com>
To:     INAGAKI Hiroshi <musashino.open@...il.com>, rafal@...ecki.pl,
        srinivas.kandagatla@...aro.org
Cc:     kbuild-all@...ts.01.org, linux-kernel@...r.kernel.org,
        INAGAKI Hiroshi <musashino.open@...il.com>
Subject: Re: [PATCH] nvmem: u-boot-env: align endianness of crc32 values

Hi INAGAKI,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on linus/master]
[also build test WARNING on next-20221011]
[cannot apply to v6.0]
[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/INAGAKI-Hiroshi/nvmem-u-boot-env-align-endianness-of-crc32-values/20221011-105205
base:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 27bc50fc90647bbf7b734c3fc306a5e61350da53
config: ia64-randconfig-s041-20221010
compiler: ia64-linux-gcc (GCC) 12.1.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # apt-get install sparse
        # sparse version: v0.6.4-39-gce1a6720-dirty
        # https://github.com/intel-lab-lkp/linux/commit/8c370eeba07506f18fb242d6cc570c755c18be38
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review INAGAKI-Hiroshi/nvmem-u-boot-env-align-endianness-of-crc32-values/20221011-105205
        git checkout 8c370eeba07506f18fb242d6cc570c755c18be38
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=ia64 SHELL=/bin/bash drivers/nvmem/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@...el.com>

sparse warnings: (new ones prefixed by >>)
>> drivers/nvmem/u-boot-env.c:146:16: sparse: sparse: cast to restricted __le32

vim +146 drivers/nvmem/u-boot-env.c

   103	
   104	static int u_boot_env_parse(struct u_boot_env *priv)
   105	{
   106		struct device *dev = priv->dev;
   107		size_t crc32_data_offset;
   108		size_t crc32_data_len;
   109		size_t crc32_offset;
   110		size_t data_offset;
   111		size_t data_len;
   112		uint32_t crc32;
   113		uint32_t calc;
   114		size_t bytes;
   115		uint8_t *buf;
   116		int err;
   117	
   118		buf = kcalloc(1, priv->mtd->size, GFP_KERNEL);
   119		if (!buf) {
   120			err = -ENOMEM;
   121			goto err_out;
   122		}
   123	
   124		err = mtd_read(priv->mtd, 0, priv->mtd->size, &bytes, buf);
   125		if ((err && !mtd_is_bitflip(err)) || bytes != priv->mtd->size) {
   126			dev_err(dev, "Failed to read from mtd: %d\n", err);
   127			goto err_kfree;
   128		}
   129	
   130		switch (priv->format) {
   131		case U_BOOT_FORMAT_SINGLE:
   132			crc32_offset = offsetof(struct u_boot_env_image_single, crc32);
   133			crc32_data_offset = offsetof(struct u_boot_env_image_single, data);
   134			data_offset = offsetof(struct u_boot_env_image_single, data);
   135			break;
   136		case U_BOOT_FORMAT_REDUNDANT:
   137			crc32_offset = offsetof(struct u_boot_env_image_redundant, crc32);
   138			crc32_data_offset = offsetof(struct u_boot_env_image_redundant, mark);
   139			data_offset = offsetof(struct u_boot_env_image_redundant, data);
   140			break;
   141		}
   142		crc32 = le32_to_cpu(*(__le32 *)(buf + crc32_offset));
   143		crc32_data_len = priv->mtd->size - crc32_data_offset;
   144		data_len = priv->mtd->size - data_offset;
   145	
 > 146		calc = le32_to_cpu(crc32(~0, buf + crc32_data_offset, crc32_data_len) ^ ~0L);
   147		if (calc != crc32) {
   148			dev_err(dev, "Invalid calculated CRC32: 0x%08x (expected: 0x%08x)\n", calc, crc32);
   149			err = -EINVAL;
   150			goto err_kfree;
   151		}
   152	
   153		buf[priv->mtd->size - 1] = '\0';
   154		err = u_boot_env_add_cells(priv, buf, data_offset, data_len);
   155		if (err)
   156			dev_err(dev, "Failed to add cells: %d\n", err);
   157	
   158	err_kfree:
   159		kfree(buf);
   160	err_out:
   161		return err;
   162	}
   163	

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp

View attachment "config" of type "text/plain" (173898 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ