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: <201808060909.jUzh9QG0%fengguang.wu@intel.com>
Date:   Mon, 6 Aug 2018 09:38:11 +0800
From:   kbuild test robot <lkp@...el.com>
To:     Vasundhara Volam <vasundhara-v.volam@...adcom.com>
Cc:     kbuild-all@...org, netdev@...r.kernel.org,
        Michael Chan <michael.chan@...adcom.com>
Subject: [net-next:master 1709/1739]
 drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c:2863:2: warning: 'strncpy'
 output truncated before terminating nul copying as many bytes from a string
 as its length

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git master
head:   981467033a37d916649647fa3afe1fe99bba1817
commit: 6c5657d085ae8c13a8565b98e6a23fe68f0bede4 [1709/1739] bnxt_en: Add support for ethtool get dump.
config: ia64-allmodconfig (attached as .config)
compiler: ia64-linux-gcc (GCC) 8.1.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        git checkout 6c5657d085ae8c13a8565b98e6a23fe68f0bede4
        # save the attached .config to linux build tree
        GCC_VERSION=8.1.0 make.cross ARCH=ia64 

All warnings (new ones prefixed by >>):

   In function 'bnxt_fill_coredump_record',
       inlined from 'bnxt_get_coredump' at drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c:2980:3:
>> drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c:2863:2: warning: 'strncpy' output truncated before terminating nul copying as many bytes from a string as its length [-Wstringop-truncation]
     strncpy(record->system_name, utsname()->nodename,
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      strlen(utsname()->nodename));
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~

vim +/strncpy +2863 drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c

  2846	
  2847	static void
  2848	bnxt_fill_coredump_record(struct bnxt *bp, struct bnxt_coredump_record *record,
  2849				  time64_t start, s16 start_utc, u16 total_segs,
  2850				  int status)
  2851	{
  2852		time64_t end = ktime_get_real_seconds();
  2853		u32 os_ver_major = 0, os_ver_minor = 0;
  2854		struct tm tm;
  2855	
  2856		time64_to_tm(start, 0, &tm);
  2857		memset(record, 0, sizeof(*record));
  2858		strcpy(record->signature, "cOrE");
  2859		record->flags = 0;
  2860		record->low_version = 0;
  2861		record->high_version = 1;
  2862		record->asic_state = 0;
> 2863		strncpy(record->system_name, utsname()->nodename,
  2864			strlen(utsname()->nodename));
  2865		record->year = cpu_to_le16(tm.tm_year);
  2866		record->month = cpu_to_le16(tm.tm_mon);
  2867		record->day = cpu_to_le16(tm.tm_mday);
  2868		record->hour = cpu_to_le16(tm.tm_hour);
  2869		record->minute = cpu_to_le16(tm.tm_min);
  2870		record->second = cpu_to_le16(tm.tm_sec);
  2871		record->utc_bias = cpu_to_le16(start_utc);
  2872		strcpy(record->commandline, "ethtool -w");
  2873		record->total_segments = cpu_to_le32(total_segs);
  2874	
  2875		sscanf(utsname()->release, "%u.%u", &os_ver_major, &os_ver_minor);
  2876		record->os_ver_major = cpu_to_le32(os_ver_major);
  2877		record->os_ver_minor = cpu_to_le32(os_ver_minor);
  2878	
  2879		strcpy(record->os_name, utsname()->sysname);
  2880		time64_to_tm(end, 0, &tm);
  2881		record->end_year = cpu_to_le16(tm.tm_year + 1900);
  2882		record->end_month = cpu_to_le16(tm.tm_mon + 1);
  2883		record->end_day = cpu_to_le16(tm.tm_mday);
  2884		record->end_hour = cpu_to_le16(tm.tm_hour);
  2885		record->end_minute = cpu_to_le16(tm.tm_min);
  2886		record->end_second = cpu_to_le16(tm.tm_sec);
  2887		record->end_utc_bias = cpu_to_le16(sys_tz.tz_minuteswest * 60);
  2888		record->asic_id1 = cpu_to_le32(bp->chip_num << 16 |
  2889					       bp->ver_resp.chip_rev << 8 |
  2890					       bp->ver_resp.chip_metal);
  2891		record->asic_id2 = 0;
  2892		record->coredump_status = cpu_to_le32(status);
  2893		record->ioctl_low_version = 0;
  2894		record->ioctl_high_version = 0;
  2895	}
  2896	
  2897	static int bnxt_get_coredump(struct bnxt *bp, void *buf, u32 *dump_len)
  2898	{
  2899		u32 ver_get_resp_len = sizeof(struct hwrm_ver_get_output);
  2900		struct coredump_segment_record *seg_record = NULL;
  2901		u32 offset = 0, seg_hdr_len, seg_record_len;
  2902		struct bnxt_coredump_segment_hdr seg_hdr;
  2903		struct bnxt_coredump_record coredump_rec;
  2904		struct bnxt_coredump coredump = {NULL};
  2905		time64_t start_time;
  2906		u16 start_utc;
  2907		int rc = 0, i;
  2908	
  2909		start_time = ktime_get_real_seconds();
  2910		start_utc = sys_tz.tz_minuteswest * 60;
  2911		seg_hdr_len = sizeof(seg_hdr);
  2912	
  2913		/* First segment should be hwrm_ver_get response */
  2914		*dump_len = seg_hdr_len + ver_get_resp_len;
  2915		if (buf) {
  2916			bnxt_fill_coredump_seg_hdr(bp, &seg_hdr, NULL, ver_get_resp_len,
  2917						   0, 0, 0);
  2918			memcpy(buf + offset, &seg_hdr, seg_hdr_len);
  2919			offset += seg_hdr_len;
  2920			memcpy(buf + offset, &bp->ver_resp, ver_get_resp_len);
  2921			offset += ver_get_resp_len;
  2922		}
  2923	
  2924		rc = bnxt_hwrm_dbg_coredump_list(bp, &coredump);
  2925		if (rc) {
  2926			netdev_err(bp->dev, "Failed to get coredump segment list\n");
  2927			goto err;
  2928		}
  2929	
  2930		*dump_len += seg_hdr_len * coredump.total_segs;
  2931	
  2932		seg_record = (struct coredump_segment_record *)coredump.data;
  2933		seg_record_len = sizeof(*seg_record);
  2934	
  2935		for (i = 0; i < coredump.total_segs; i++) {
  2936			u16 comp_id = le16_to_cpu(seg_record->component_id);
  2937			u16 seg_id = le16_to_cpu(seg_record->segment_id);
  2938			u32 duration = 0, seg_len = 0;
  2939			unsigned long start, end;
  2940	
  2941			start = jiffies;
  2942	
  2943			rc = bnxt_hwrm_dbg_coredump_initiate(bp, comp_id, seg_id);
  2944			if (rc) {
  2945				netdev_err(bp->dev,
  2946					   "Failed to initiate coredump for seg = %d\n",
  2947					   seg_record->segment_id);
  2948				goto next_seg;
  2949			}
  2950	
  2951			/* Write segment data into the buffer */
  2952			rc = bnxt_hwrm_dbg_coredump_retrieve(bp, comp_id, seg_id,
  2953							     &seg_len, buf,
  2954							     offset + seg_hdr_len);
  2955			if (rc)
  2956				netdev_err(bp->dev,
  2957					   "Failed to retrieve coredump for seg = %d\n",
  2958					   seg_record->segment_id);
  2959	
  2960	next_seg:
  2961			end = jiffies;
  2962			duration = jiffies_to_msecs(end - start);
  2963			bnxt_fill_coredump_seg_hdr(bp, &seg_hdr, seg_record, seg_len,
  2964						   rc, duration, 0);
  2965	
  2966			if (buf) {
  2967				/* Write segment header into the buffer */
  2968				memcpy(buf + offset, &seg_hdr, seg_hdr_len);
  2969				offset += seg_hdr_len + seg_len;
  2970			}
  2971	
  2972			*dump_len += seg_len;
  2973			seg_record =
  2974				(struct coredump_segment_record *)((u8 *)seg_record +
  2975								   seg_record_len);
  2976		}
  2977	
  2978	err:
  2979		if (buf) {
> 2980			bnxt_fill_coredump_record(bp, &coredump_rec, start_time,
  2981						  start_utc, coredump.total_segs + 1,
  2982						  rc);
  2983			memcpy(buf + offset, &coredump_rec, sizeof(coredump_rec));
  2984		}
  2985		kfree(coredump.data);
  2986		*dump_len += sizeof(coredump_rec);
  2987	
  2988		return rc;
  2989	}
  2990	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

Download attachment ".config.gz" of type "application/gzip" (50936 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ