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>] [day] [month] [year] [list]
Message-ID: <202212250319.xTIF4Hov-lkp@intel.com>
Date:   Sun, 25 Dec 2022 03:18:29 +0800
From:   kernel test robot <lkp@...el.com>
To:     Justin Tee <justin.tee@...adcom.com>
Cc:     oe-kbuild-all@...ts.linux.dev, linux-kernel@...r.kernel.org,
        "Martin K. Petersen" <martin.petersen@...cle.com>
Subject: drivers/scsi/lpfc/lpfc_attr.c:1908:9: warning: 'strncpy' output may
 be truncated copying 16 bytes from a string of length 255

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   72a85e2b0a1e1e6fb4ee51ae902730212b2de25c
commit: 479b0917e4477f49df2e3be454aac3cfa5dec171 scsi: lpfc: Create a sysfs entry called lpfc_xcvr_data for transceiver info
date:   9 weeks ago
config: arm64-randconfig-r005-20221225
compiler: aarch64-linux-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=479b0917e4477f49df2e3be454aac3cfa5dec171
        git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
        git fetch --no-tags linus master
        git checkout 479b0917e4477f49df2e3be454aac3cfa5dec171
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=arm64 olddefconfig
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=arm64 SHELL=/bin/bash drivers/scsi/lpfc/

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

All warnings (new ones prefixed by >>):

   drivers/scsi/lpfc/lpfc_attr.c: In function 'lpfc_xcvr_data_show':
>> drivers/scsi/lpfc/lpfc_attr.c:1908:9: warning: 'strncpy' output may be truncated copying 16 bytes from a string of length 255 [-Wstringop-truncation]
    1908 |         strncpy(chbuf, &rdp_context->page_a0[SSF_VENDOR_NAME], 16);
         |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/scsi/lpfc/lpfc_attr.c:1917:9: warning: 'strncpy' output may be truncated copying 16 bytes from a string of length 255 [-Wstringop-truncation]
    1917 |         strncpy(chbuf, &rdp_context->page_a0[SSF_VENDOR_PN], 16);
         |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/scsi/lpfc/lpfc_attr.c:1920:9: warning: 'strncpy' output may be truncated copying 16 bytes from a string of length 255 [-Wstringop-truncation]
    1920 |         strncpy(chbuf, &rdp_context->page_a0[SSF_VENDOR_SN], 16);
         |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/scsi/lpfc/lpfc_attr.c:1923:9: warning: 'strncpy' output may be truncated copying 4 bytes from a string of length 255 [-Wstringop-truncation]
    1923 |         strncpy(chbuf, &rdp_context->page_a0[SSF_VENDOR_REV], 4);
         |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/scsi/lpfc/lpfc_attr.c:1926:9: warning: 'strncpy' output may be truncated copying 8 bytes from a string of length 255 [-Wstringop-truncation]
    1926 |         strncpy(chbuf, &rdp_context->page_a0[SSF_DATE_CODE], 8);
         |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


vim +/strncpy +1908 drivers/scsi/lpfc/lpfc_attr.c

  1879	
  1880	static ssize_t
  1881	lpfc_xcvr_data_show(struct device *dev, struct device_attribute *attr,
  1882			    char *buf)
  1883	{
  1884		struct Scsi_Host  *shost = class_to_shost(dev);
  1885		struct lpfc_vport *vport = (struct lpfc_vport *)shost->hostdata;
  1886		struct lpfc_hba   *phba = vport->phba;
  1887		int rc;
  1888		int len = 0;
  1889		struct lpfc_rdp_context	*rdp_context;
  1890		u16 temperature;
  1891		u16 rx_power;
  1892		u16 tx_bias;
  1893		u16 tx_power;
  1894		u16 vcc;
  1895		char chbuf[128];
  1896		u16 wavelength = 0;
  1897		struct sff_trasnceiver_codes_byte7 *trasn_code_byte7;
  1898	
  1899		/* Get transceiver information */
  1900		rdp_context = kmalloc(sizeof(*rdp_context), GFP_KERNEL);
  1901	
  1902		rc = lpfc_get_sfp_info_wait(phba, rdp_context);
  1903		if (rc) {
  1904			len = scnprintf(buf, PAGE_SIZE - len, "SFP info NA:\n");
  1905			goto out_free_rdp;
  1906		}
  1907	
> 1908		strncpy(chbuf, &rdp_context->page_a0[SSF_VENDOR_NAME], 16);
  1909		chbuf[16] = 0;
  1910	
  1911		len = scnprintf(buf, PAGE_SIZE - len, "VendorName:\t%s\n", chbuf);
  1912		len += scnprintf(buf + len, PAGE_SIZE - len,
  1913				 "VendorOUI:\t%02x-%02x-%02x\n",
  1914				 (uint8_t)rdp_context->page_a0[SSF_VENDOR_OUI],
  1915				 (uint8_t)rdp_context->page_a0[SSF_VENDOR_OUI + 1],
  1916				 (uint8_t)rdp_context->page_a0[SSF_VENDOR_OUI + 2]);
  1917		strncpy(chbuf, &rdp_context->page_a0[SSF_VENDOR_PN], 16);
  1918		chbuf[16] = 0;
  1919		len += scnprintf(buf + len, PAGE_SIZE - len, "VendorPN:\t%s\n", chbuf);
  1920		strncpy(chbuf, &rdp_context->page_a0[SSF_VENDOR_SN], 16);
  1921		chbuf[16] = 0;
  1922		len += scnprintf(buf + len, PAGE_SIZE - len, "VendorSN:\t%s\n", chbuf);
  1923		strncpy(chbuf, &rdp_context->page_a0[SSF_VENDOR_REV], 4);
  1924		chbuf[4] = 0;
  1925		len += scnprintf(buf + len, PAGE_SIZE - len, "VendorRev:\t%s\n", chbuf);
  1926		strncpy(chbuf, &rdp_context->page_a0[SSF_DATE_CODE], 8);
  1927		chbuf[8] = 0;
  1928		len += scnprintf(buf + len, PAGE_SIZE - len, "DateCode:\t%s\n", chbuf);
  1929		len += scnprintf(buf + len, PAGE_SIZE - len, "Identifier:\t%xh\n",
  1930				 (uint8_t)rdp_context->page_a0[SSF_IDENTIFIER]);
  1931		len += scnprintf(buf + len, PAGE_SIZE - len, "ExtIdentifier:\t%xh\n",
  1932				 (uint8_t)rdp_context->page_a0[SSF_EXT_IDENTIFIER]);
  1933		len += scnprintf(buf + len, PAGE_SIZE - len, "Connector:\t%xh\n",
  1934				 (uint8_t)rdp_context->page_a0[SSF_CONNECTOR]);
  1935		wavelength = (rdp_context->page_a0[SSF_WAVELENGTH_B1] << 8) |
  1936			      rdp_context->page_a0[SSF_WAVELENGTH_B0];
  1937	
  1938		len += scnprintf(buf + len, PAGE_SIZE - len, "Wavelength:\t%d nm\n",
  1939				 wavelength);
  1940		trasn_code_byte7 = (struct sff_trasnceiver_codes_byte7 *)
  1941				&rdp_context->page_a0[SSF_TRANSCEIVER_CODE_B7];
  1942	
  1943		len += scnprintf(buf + len, PAGE_SIZE - len, "Speeds: \t");
  1944			if (*(uint8_t *)trasn_code_byte7 == 0) {
  1945				len += scnprintf(buf + len, PAGE_SIZE - len,
  1946						 "Unknown\n");
  1947			} else {
  1948				if (trasn_code_byte7->fc_sp_100MB)
  1949					len += scnprintf(buf + len, PAGE_SIZE - len,
  1950							 "1 ");
  1951				if (trasn_code_byte7->fc_sp_200mb)
  1952					len += scnprintf(buf + len, PAGE_SIZE - len,
  1953							 "2 ");
  1954				if (trasn_code_byte7->fc_sp_400MB)
  1955					len += scnprintf(buf + len, PAGE_SIZE - len,
  1956							 "4 ");
  1957				if (trasn_code_byte7->fc_sp_800MB)
  1958					len += scnprintf(buf + len, PAGE_SIZE - len,
  1959							 "8 ");
  1960				if (trasn_code_byte7->fc_sp_1600MB)
  1961					len += scnprintf(buf + len, PAGE_SIZE - len,
  1962							 "16 ");
  1963				if (trasn_code_byte7->fc_sp_3200MB)
  1964					len += scnprintf(buf + len, PAGE_SIZE - len,
  1965							 "32 ");
  1966				if (trasn_code_byte7->speed_chk_ecc)
  1967					len += scnprintf(buf + len, PAGE_SIZE - len,
  1968							 "64 ");
  1969				len += scnprintf(buf + len, PAGE_SIZE - len, "GB\n");
  1970			}
  1971		temperature = (rdp_context->page_a2[SFF_TEMPERATURE_B1] << 8 |
  1972			       rdp_context->page_a2[SFF_TEMPERATURE_B0]);
  1973		vcc = (rdp_context->page_a2[SFF_VCC_B1] << 8 |
  1974		       rdp_context->page_a2[SFF_VCC_B0]);
  1975		tx_power = (rdp_context->page_a2[SFF_TXPOWER_B1] << 8 |
  1976			    rdp_context->page_a2[SFF_TXPOWER_B0]);
  1977		tx_bias = (rdp_context->page_a2[SFF_TX_BIAS_CURRENT_B1] << 8 |
  1978			   rdp_context->page_a2[SFF_TX_BIAS_CURRENT_B0]);
  1979		rx_power = (rdp_context->page_a2[SFF_RXPOWER_B1] << 8 |
  1980			    rdp_context->page_a2[SFF_RXPOWER_B0]);
  1981	
  1982		len += scnprintf(buf + len, PAGE_SIZE - len,
  1983				 "Temperature:\tx%04x C\n", temperature);
  1984		len += scnprintf(buf + len, PAGE_SIZE - len, "Vcc:\t\tx%04x V\n", vcc);
  1985		len += scnprintf(buf + len, PAGE_SIZE - len,
  1986				 "TxBiasCurrent:\tx%04x mA\n", tx_bias);
  1987		len += scnprintf(buf + len, PAGE_SIZE - len, "TxPower:\tx%04x mW\n",
  1988				 tx_power);
  1989		len += scnprintf(buf + len, PAGE_SIZE - len, "RxPower:\tx%04x mW\n",
  1990				 rx_power);
  1991	out_free_rdp:
  1992		kfree(rdp_context);
  1993		return len;
  1994	}
  1995	

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

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ