security/selinux/hooks.c:6620:2: warning: 'strncpy' specified bound 64 equals destination size

From: kernel test robot <hidden>
Date: 2020-09-23 06:10:40
Also in: oe-kbuild-all

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   805c6d3c19210c90c109107d189744e960eae025
commit: c62da0c35d58518ddb26ff641d2485596567fd96 mm/vma: define a default value for VM_DATA_DEFAULT_FLAGS
date:   6 months ago
config: microblaze-randconfig-r033-20200923 (attached as .config)
compiler: microblaze-linux-gcc (GCC) 9.3.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
        git checkout c62da0c35d58518ddb26ff641d2485596567fd96
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=microblaze 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <redacted>

All warnings (new ones prefixed by >>):

   security/selinux/hooks.c: In function 'selinux_ib_endport_manage_subnet':
quoted
security/selinux/hooks.c:6620:2: warning: 'strncpy' specified bound 64 equals destination size [-Wstringop-truncation]
    6620 |  strncpy(ibendport.dev_name, dev_name, sizeof(ibendport.dev_name));
         |  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

# https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=c62da0c35d58518ddb26ff641d2485596567fd96
git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
git fetch --no-tags linus master
git checkout c62da0c35d58518ddb26ff641d2485596567fd96
vim +/strncpy +6620 security/selinux/hooks.c

cfc4d882d41780 Daniel Jurgens  2017-05-19  6603  
ab861dfca1652a Daniel Jurgens  2017-05-19  6604  static int selinux_ib_endport_manage_subnet(void *ib_sec, const char *dev_name,
ab861dfca1652a Daniel Jurgens  2017-05-19  6605  					    u8 port_num)
ab861dfca1652a Daniel Jurgens  2017-05-19  6606  {
ab861dfca1652a Daniel Jurgens  2017-05-19  6607  	struct common_audit_data ad;
ab861dfca1652a Daniel Jurgens  2017-05-19  6608  	int err;
ab861dfca1652a Daniel Jurgens  2017-05-19  6609  	u32 sid = 0;
ab861dfca1652a Daniel Jurgens  2017-05-19  6610  	struct ib_security_struct *sec = ib_sec;
ab861dfca1652a Daniel Jurgens  2017-05-19  6611  	struct lsm_ibendport_audit ibendport;
ab861dfca1652a Daniel Jurgens  2017-05-19  6612  
aa8e712cee93d5 Stephen Smalley 2018-03-01  6613  	err = security_ib_endport_sid(&selinux_state, dev_name, port_num,
aa8e712cee93d5 Stephen Smalley 2018-03-01  6614  				      &sid);
ab861dfca1652a Daniel Jurgens  2017-05-19  6615  
ab861dfca1652a Daniel Jurgens  2017-05-19  6616  	if (err)
ab861dfca1652a Daniel Jurgens  2017-05-19  6617  		return err;
70a5bb72b55e82 David Howells   2008-04-29  6618  
ab861dfca1652a Daniel Jurgens  2017-05-19  6619  	ad.type = LSM_AUDIT_DATA_IBENDPORT;
ab861dfca1652a Daniel Jurgens  2017-05-19 @6620  	strncpy(ibendport.dev_name, dev_name, sizeof(ibendport.dev_name));
ab861dfca1652a Daniel Jurgens  2017-05-19  6621  	ibendport.port = port_num;
ab861dfca1652a Daniel Jurgens  2017-05-19  6622  	ad.u.ibendport = &ibendport;
6b6bc6205d9879 Stephen Smalley 2018-03-05  6623  	return avc_has_perm(&selinux_state,
6b6bc6205d9879 Stephen Smalley 2018-03-05  6624  			    sec->sid, sid,
ab861dfca1652a Daniel Jurgens  2017-05-19  6625  			    SECCLASS_INFINIBAND_ENDPORT,
ab861dfca1652a Daniel Jurgens  2017-05-19  6626  			    INFINIBAND_ENDPORT__MANAGE_SUBNET, &ad);
ab861dfca1652a Daniel Jurgens  2017-05-19  6627  }
ab861dfca1652a Daniel Jurgens  2017-05-19  6628  

:::::: The code at line 6620 was first introduced by commit
:::::: ab861dfca1652aa09b26b7aa2899feb29b33dfd9 selinux: Add IB Port SMP access vector

:::::: TO: Daniel Jurgens [off-list ref]
:::::: CC: Paul Moore [off-list ref]

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

Attachments

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help