Re: [PATCH 4/6] net/tcp: Disable TCP-MD5 static key on tcp_md5sig_info destruction

From: kernel test robot
Date: Sun Aug 14 2022 - 12:11:53 EST


Hi Dmitry,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on 058affafc65a74cf54499fb578b66ad0b18f939b]

url: https://github.com/intel-lab-lkp/linux/commits/Dmitry-Safonov/net-crypto-Introduce-crypto_pool/20220727-041830
base: 058affafc65a74cf54499fb578b66ad0b18f939b
config: x86_64-defconfig (https://download.01.org/0day-ci/archive/20220814/202208142332.WUqM9sfv-lkp@xxxxxxxxx/config)
compiler: gcc-11 (Debian 11.3.0-3) 11.3.0
reproduce (this is a W=1 build):
# https://github.com/intel-lab-lkp/linux/commit/a4ee3ecdaada036ed6747ed86eaf7270d3f27bab
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Dmitry-Safonov/net-crypto-Introduce-crypto_pool/20220727-041830
git checkout a4ee3ecdaada036ed6747ed86eaf7270d3f27bab
# save the config file
mkdir build_dir && cp config build_dir/.config
make W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash net/ipv4/

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

All warnings (new ones prefixed by >>):

>> net/ipv4/tcp_ipv4.c:1174:5: warning: no previous prototype for '__tcp_md5_do_add' [-Wmissing-prototypes]
1174 | int __tcp_md5_do_add(struct sock *sk, const union tcp_md5_addr *addr,
| ^~~~~~~~~~~~~~~~


vim +/__tcp_md5_do_add +1174 net/ipv4/tcp_ipv4.c

1172
1173 /* This can be called on a newly created socket, from other files */
> 1174 int __tcp_md5_do_add(struct sock *sk, const union tcp_md5_addr *addr,
1175 int family, u8 prefixlen, int l3index, u8 flags,
1176 const u8 *newkey, u8 newkeylen, gfp_t gfp)
1177 {
1178 /* Add Key to the list */
1179 struct tcp_md5sig_key *key;
1180 struct tcp_sock *tp = tcp_sk(sk);
1181 struct tcp_md5sig_info *md5sig;
1182
1183 key = tcp_md5_do_lookup_exact(sk, addr, family, prefixlen, l3index, flags);
1184 if (key) {
1185 /* Pre-existing entry - just update that one.
1186 * Note that the key might be used concurrently.
1187 * data_race() is telling kcsan that we do not care of
1188 * key mismatches, since changing MD5 key on live flows
1189 * can lead to packet drops.
1190 */
1191 data_race(memcpy(key->key, newkey, newkeylen));
1192
1193 /* Pairs with READ_ONCE() in tcp_md5_hash_key().
1194 * Also note that a reader could catch new key->keylen value
1195 * but old key->key[], this is the reason we use __GFP_ZERO
1196 * at sock_kmalloc() time below these lines.
1197 */
1198 WRITE_ONCE(key->keylen, newkeylen);
1199
1200 return 0;
1201 }
1202
1203 md5sig = rcu_dereference_protected(tp->md5sig_info,
1204 lockdep_sock_is_held(sk));
1205
1206 key = sock_kmalloc(sk, sizeof(*key), gfp | __GFP_ZERO);
1207 if (!key)
1208 return -ENOMEM;
1209 if (!tcp_alloc_md5sig_pool()) {
1210 sock_kfree_s(sk, key, sizeof(*key));
1211 return -ENOMEM;
1212 }
1213
1214 memcpy(key->key, newkey, newkeylen);
1215 key->keylen = newkeylen;
1216 key->family = family;
1217 key->prefixlen = prefixlen;
1218 key->l3index = l3index;
1219 key->flags = flags;
1220 memcpy(&key->addr, addr,
1221 (IS_ENABLED(CONFIG_IPV6) && family == AF_INET6) ? sizeof(struct in6_addr) :
1222 sizeof(struct in_addr));
1223 hlist_add_head_rcu(&key->node, &md5sig->head);
1224 return 0;
1225 }
1226

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