Re: [PATCH net-next 08/12] macsec: use NLA_POLICY_VALIDATE_FN to validate IFLA_MACSEC_CIPHER_SUITE
From: kernel test robot <hidden>
Date: 2022-09-30 04:40:11
Also in:
llvm
Hi Sabrina, Thank you for the patch! Perhaps something to improve: [auto build test WARNING on net-next/master] url: https://github.com/intel-lab-lkp/linux/commits/Sabrina-Dubroca/macsec-replace-custom-netlink-attribute-checks-with-policy-level-checks/20220929-003145 base: https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git b9a5cbf8ba24e88071a97a51a09ef5cdf0d1f6a1 config: i386-randconfig-a004 compiler: clang version 14.0.6 (https://github.com/llvm/llvm-project f28c006a5895fc0e329fe15fead81e37457cb1d1) 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://github.com/intel-lab-lkp/linux/commit/a58673e9703907581b22fff5004b3a080d50feeb git remote add linux-review https://github.com/intel-lab-lkp/linux git fetch --no-tags linux-review Sabrina-Dubroca/macsec-replace-custom-netlink-attribute-checks-with-policy-level-checks/20220929-003145 git checkout a58673e9703907581b22fff5004b3a080d50feeb # save the config file mkdir build_dir && cp config build_dir/.config COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=i386 SHELL=/bin/bash drivers/net/ If you fix the issue, kindly add following tag where applicable | Reported-by: kernel test robot [off-list ref] All warnings (new ones prefixed by >>):
quoted
drivers/net/macsec.c:4122:6: warning: variable 'csid' set but not used [-Wunused-but-set-variable]
u64 csid = MACSEC_DEFAULT_CIPHER_ID;
^
1 warning generated.
vim +/csid +4122 drivers/net/macsec.c
a58673e9703907 Sabrina Dubroca 2022-09-28 4118
a8b8a889e369de Matthias Schiffer 2017-06-25 4119 static int macsec_validate_attr(struct nlattr *tb[], struct nlattr *data[],
a8b8a889e369de Matthias Schiffer 2017-06-25 4120 struct netlink_ext_ack *extack)
c09440f7dcb304 Sabrina Dubroca 2016-03-11 4121 {
748164802c1bd2 Sabrina Dubroca 2016-04-22 @4122 u64 csid = MACSEC_DEFAULT_CIPHER_ID;
b1671253c60158 Lior Nahmanson 2022-09-05 4123 u8 icv_len = MACSEC_DEFAULT_ICV_LEN;
c09440f7dcb304 Sabrina Dubroca 2016-03-11 4124 int flag;
c09440f7dcb304 Sabrina Dubroca 2016-03-11 4125 bool es, scb, sci;
c09440f7dcb304 Sabrina Dubroca 2016-03-11 4126
c09440f7dcb304 Sabrina Dubroca 2016-03-11 4127 if (!data)
c09440f7dcb304 Sabrina Dubroca 2016-03-11 4128 return 0;
c09440f7dcb304 Sabrina Dubroca 2016-03-11 4129
c09440f7dcb304 Sabrina Dubroca 2016-03-11 4130 if (data[IFLA_MACSEC_CIPHER_SUITE])
c09440f7dcb304 Sabrina Dubroca 2016-03-11 4131 csid = nla_get_u64(data[IFLA_MACSEC_CIPHER_SUITE]);
c09440f7dcb304 Sabrina Dubroca 2016-03-11 4132
f04c392d2dd97a Davide Caratti 2016-07-22 4133 if (data[IFLA_MACSEC_ICV_LEN]) {
c09440f7dcb304 Sabrina Dubroca 2016-03-11 4134 icv_len = nla_get_u8(data[IFLA_MACSEC_ICV_LEN]);
b1671253c60158 Lior Nahmanson 2022-09-05 4135 if (icv_len != MACSEC_DEFAULT_ICV_LEN) {
f04c392d2dd97a Davide Caratti 2016-07-22 4136 char dummy_key[DEFAULT_SAK_LEN] = { 0 };
f04c392d2dd97a Davide Caratti 2016-07-22 4137 struct crypto_aead *dummy_tfm;
f04c392d2dd97a Davide Caratti 2016-07-22 4138
f04c392d2dd97a Davide Caratti 2016-07-22 4139 dummy_tfm = macsec_alloc_tfm(dummy_key,
f04c392d2dd97a Davide Caratti 2016-07-22 4140 DEFAULT_SAK_LEN,
f04c392d2dd97a Davide Caratti 2016-07-22 4141 icv_len);
f04c392d2dd97a Davide Caratti 2016-07-22 4142 if (IS_ERR(dummy_tfm))
f04c392d2dd97a Davide Caratti 2016-07-22 4143 return PTR_ERR(dummy_tfm);
f04c392d2dd97a Davide Caratti 2016-07-22 4144 crypto_free_aead(dummy_tfm);
f04c392d2dd97a Davide Caratti 2016-07-22 4145 }
f04c392d2dd97a Davide Caratti 2016-07-22 4146 }
c09440f7dcb304 Sabrina Dubroca 2016-03-11 4147
c09440f7dcb304 Sabrina Dubroca 2016-03-11 4148 if (data[IFLA_MACSEC_ENCODING_SA]) {
c09440f7dcb304 Sabrina Dubroca 2016-03-11 4149 if (nla_get_u8(data[IFLA_MACSEC_ENCODING_SA]) >= MACSEC_NUM_AN)
c09440f7dcb304 Sabrina Dubroca 2016-03-11 4150 return -EINVAL;
c09440f7dcb304 Sabrina Dubroca 2016-03-11 4151 }
c09440f7dcb304 Sabrina Dubroca 2016-03-11 4152
c09440f7dcb304 Sabrina Dubroca 2016-03-11 4153 for (flag = IFLA_MACSEC_ENCODING_SA + 1;
c09440f7dcb304 Sabrina Dubroca 2016-03-11 4154 flag < IFLA_MACSEC_VALIDATION;
c09440f7dcb304 Sabrina Dubroca 2016-03-11 4155 flag++) {
c09440f7dcb304 Sabrina Dubroca 2016-03-11 4156 if (data[flag]) {
c09440f7dcb304 Sabrina Dubroca 2016-03-11 4157 if (nla_get_u8(data[flag]) > 1)
c09440f7dcb304 Sabrina Dubroca 2016-03-11 4158 return -EINVAL;
c09440f7dcb304 Sabrina Dubroca 2016-03-11 4159 }
c09440f7dcb304 Sabrina Dubroca 2016-03-11 4160 }
c09440f7dcb304 Sabrina Dubroca 2016-03-11 4161
c09440f7dcb304 Sabrina Dubroca 2016-03-11 4162 es = data[IFLA_MACSEC_ES] ? nla_get_u8(data[IFLA_MACSEC_ES]) : false;
c09440f7dcb304 Sabrina Dubroca 2016-03-11 4163 sci = data[IFLA_MACSEC_INC_SCI] ? nla_get_u8(data[IFLA_MACSEC_INC_SCI]) : false;
c09440f7dcb304 Sabrina Dubroca 2016-03-11 4164 scb = data[IFLA_MACSEC_SCB] ? nla_get_u8(data[IFLA_MACSEC_SCB]) : false;
c09440f7dcb304 Sabrina Dubroca 2016-03-11 4165
c09440f7dcb304 Sabrina Dubroca 2016-03-11 4166 if ((sci && (scb || es)) || (scb && es))
c09440f7dcb304 Sabrina Dubroca 2016-03-11 4167 return -EINVAL;
c09440f7dcb304 Sabrina Dubroca 2016-03-11 4168
c09440f7dcb304 Sabrina Dubroca 2016-03-11 4169 if (data[IFLA_MACSEC_VALIDATION] &&
c09440f7dcb304 Sabrina Dubroca 2016-03-11 4170 nla_get_u8(data[IFLA_MACSEC_VALIDATION]) > MACSEC_VALIDATE_MAX)
c09440f7dcb304 Sabrina Dubroca 2016-03-11 4171 return -EINVAL;
c09440f7dcb304 Sabrina Dubroca 2016-03-11 4172
4b1fb9352f351f Sabrina Dubroca 2016-04-22 4173 if ((data[IFLA_MACSEC_REPLAY_PROTECT] &&
4b1fb9352f351f Sabrina Dubroca 2016-04-22 4174 nla_get_u8(data[IFLA_MACSEC_REPLAY_PROTECT])) &&
c09440f7dcb304 Sabrina Dubroca 2016-03-11 4175 !data[IFLA_MACSEC_WINDOW])
c09440f7dcb304 Sabrina Dubroca 2016-03-11 4176 return -EINVAL;
c09440f7dcb304 Sabrina Dubroca 2016-03-11 4177
c09440f7dcb304 Sabrina Dubroca 2016-03-11 4178 return 0;
c09440f7dcb304 Sabrina Dubroca 2016-03-11 4179 }
c09440f7dcb304 Sabrina Dubroca 2016-03-11 4180
--
0-DAY CI Kernel Test Service
https://01.org/lkp