[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <a51b1a51-8ff6-4607-b783-1944d324359d@suswa.mountain>
Date: Mon, 14 Jul 2025 22:16:10 +0300
From: Dan Carpenter <dan.carpenter@...aro.org>
To: oe-kbuild@...ts.linux.dev, Matt Johnston <matt@...econstruct.com.au>,
Jeremy Kerr <jk@...econstruct.com.au>,
"David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>,
Simon Horman <horms@...nel.org>
Cc: lkp@...el.com, oe-kbuild-all@...ts.linux.dev, netdev@...r.kernel.org,
Matt Johnston <matt@...econstruct.com.au>
Subject: Re: [PATCH net-next 5/7] net: mctp: Allow limiting binds to a peer
address
Hi Matt,
kernel test robot noticed the following build warnings:
url: https://github.com/intel-lab-lkp/linux/commits/Matt-Johnston/net-mctp-Prevent-duplicate-binds/20250703-171427
base: 8b98f34ce1d8c520403362cb785231f9898eb3ff
patch link: https://lore.kernel.org/r/20250703-mctp-bind-v1-5-bb7e97c24613%40codeconstruct.com.au
patch subject: [PATCH net-next 5/7] net: mctp: Allow limiting binds to a peer address
config: i386-randconfig-r072-20250708 (https://download.01.org/0day-ci/archive/20250708/202507080554.pDP37MtV-lkp@intel.com/config)
compiler: gcc-12 (Debian 12.2.0-14+deb12u1) 12.2.0
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@...el.com>
| Reported-by: Dan Carpenter <dan.carpenter@...aro.org>
| Closes: https://lore.kernel.org/r/202507080554.pDP37MtV-lkp@intel.com/
smatch warnings:
net/mctp/af_mctp.c:122 mctp_bind() warn: inconsistent returns 'sk'.
vim +/sk +122 net/mctp/af_mctp.c
8f601a1e4f8c84f Jeremy Kerr 2021-07-29 52 static int mctp_bind(struct socket *sock, struct sockaddr *addr, int addrlen)
8f601a1e4f8c84f Jeremy Kerr 2021-07-29 53 {
833ef3b91de692e Jeremy Kerr 2021-07-29 54 struct sock *sk = sock->sk;
833ef3b91de692e Jeremy Kerr 2021-07-29 55 struct mctp_sock *msk = container_of(sk, struct mctp_sock, sk);
848674f9a3c762e Matt Johnston 2025-07-03 56 struct net *net = sock_net(&msk->sk);
833ef3b91de692e Jeremy Kerr 2021-07-29 57 struct sockaddr_mctp *smctp;
833ef3b91de692e Jeremy Kerr 2021-07-29 58 int rc;
833ef3b91de692e Jeremy Kerr 2021-07-29 59
833ef3b91de692e Jeremy Kerr 2021-07-29 60 if (addrlen < sizeof(*smctp))
833ef3b91de692e Jeremy Kerr 2021-07-29 61 return -EINVAL;
833ef3b91de692e Jeremy Kerr 2021-07-29 62
833ef3b91de692e Jeremy Kerr 2021-07-29 63 if (addr->sa_family != AF_MCTP)
833ef3b91de692e Jeremy Kerr 2021-07-29 64 return -EAFNOSUPPORT;
833ef3b91de692e Jeremy Kerr 2021-07-29 65
833ef3b91de692e Jeremy Kerr 2021-07-29 66 if (!capable(CAP_NET_BIND_SERVICE))
833ef3b91de692e Jeremy Kerr 2021-07-29 67 return -EACCES;
833ef3b91de692e Jeremy Kerr 2021-07-29 68
833ef3b91de692e Jeremy Kerr 2021-07-29 69 /* it's a valid sockaddr for MCTP, cast and do protocol checks */
833ef3b91de692e Jeremy Kerr 2021-07-29 70 smctp = (struct sockaddr_mctp *)addr;
833ef3b91de692e Jeremy Kerr 2021-07-29 71
1e4b50f06d970d8 Eugene Syromiatnikov 2021-11-03 72 if (!mctp_sockaddr_is_ok(smctp))
1e4b50f06d970d8 Eugene Syromiatnikov 2021-11-03 73 return -EINVAL;
1e4b50f06d970d8 Eugene Syromiatnikov 2021-11-03 74
833ef3b91de692e Jeremy Kerr 2021-07-29 75 lock_sock(sk);
^^^^^^^^^^^^^^
locked
833ef3b91de692e Jeremy Kerr 2021-07-29 76
833ef3b91de692e Jeremy Kerr 2021-07-29 77 if (sk_hashed(sk)) {
833ef3b91de692e Jeremy Kerr 2021-07-29 78 rc = -EADDRINUSE;
833ef3b91de692e Jeremy Kerr 2021-07-29 79 goto out_release;
833ef3b91de692e Jeremy Kerr 2021-07-29 80 }
848674f9a3c762e Matt Johnston 2025-07-03 81
d58bad174be0c4b Matt Johnston 2025-07-03 82 msk->bind_local_addr = smctp->smctp_addr.s_addr;
848674f9a3c762e Matt Johnston 2025-07-03 83
848674f9a3c762e Matt Johnston 2025-07-03 84 /* MCTP_NET_ANY with a specific EID is resolved to the default net
848674f9a3c762e Matt Johnston 2025-07-03 85 * at bind() time.
848674f9a3c762e Matt Johnston 2025-07-03 86 * For bind_addr=MCTP_ADDR_ANY it is handled specially at route lookup time.
848674f9a3c762e Matt Johnston 2025-07-03 87 */
848674f9a3c762e Matt Johnston 2025-07-03 88 if (smctp->smctp_network == MCTP_NET_ANY &&
d58bad174be0c4b Matt Johnston 2025-07-03 89 msk->bind_local_addr != MCTP_ADDR_ANY) {
848674f9a3c762e Matt Johnston 2025-07-03 90 msk->bind_net = mctp_default_net(net);
848674f9a3c762e Matt Johnston 2025-07-03 91 } else {
848674f9a3c762e Matt Johnston 2025-07-03 92 msk->bind_net = smctp->smctp_network;
848674f9a3c762e Matt Johnston 2025-07-03 93 }
848674f9a3c762e Matt Johnston 2025-07-03 94
d58bad174be0c4b Matt Johnston 2025-07-03 95 /* ignore the IC bit */
d58bad174be0c4b Matt Johnston 2025-07-03 96 smctp->smctp_type &= 0x7f;
d58bad174be0c4b Matt Johnston 2025-07-03 97
d58bad174be0c4b Matt Johnston 2025-07-03 98 if (msk->bind_peer_set) {
d58bad174be0c4b Matt Johnston 2025-07-03 99 if (msk->bind_type != smctp->smctp_type) {
d58bad174be0c4b Matt Johnston 2025-07-03 100 /* Prior connect() had a different type */
d58bad174be0c4b Matt Johnston 2025-07-03 101 return -EINVAL;
goto out_release?
d58bad174be0c4b Matt Johnston 2025-07-03 102 }
d58bad174be0c4b Matt Johnston 2025-07-03 103
d58bad174be0c4b Matt Johnston 2025-07-03 104 if (msk->bind_net == MCTP_NET_ANY) {
d58bad174be0c4b Matt Johnston 2025-07-03 105 /* Restrict to the network passed to connect() */
d58bad174be0c4b Matt Johnston 2025-07-03 106 msk->bind_net = msk->bind_peer_net;
d58bad174be0c4b Matt Johnston 2025-07-03 107 }
d58bad174be0c4b Matt Johnston 2025-07-03 108
d58bad174be0c4b Matt Johnston 2025-07-03 109 if (msk->bind_net != msk->bind_peer_net) {
d58bad174be0c4b Matt Johnston 2025-07-03 110 /* connect() had a different net to bind() */
d58bad174be0c4b Matt Johnston 2025-07-03 111 return -EINVAL;
same.
d58bad174be0c4b Matt Johnston 2025-07-03 112 }
d58bad174be0c4b Matt Johnston 2025-07-03 113 } else {
d58bad174be0c4b Matt Johnston 2025-07-03 114 msk->bind_type = smctp->smctp_type;
d58bad174be0c4b Matt Johnston 2025-07-03 115 }
833ef3b91de692e Jeremy Kerr 2021-07-29 116
833ef3b91de692e Jeremy Kerr 2021-07-29 117 rc = sk->sk_prot->hash(sk);
833ef3b91de692e Jeremy Kerr 2021-07-29 118
833ef3b91de692e Jeremy Kerr 2021-07-29 119 out_release:
833ef3b91de692e Jeremy Kerr 2021-07-29 120 release_sock(sk);
833ef3b91de692e Jeremy Kerr 2021-07-29 121
833ef3b91de692e Jeremy Kerr 2021-07-29 @122 return rc;
8f601a1e4f8c84f Jeremy Kerr 2021-07-29 123 }
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
Powered by blists - more mailing lists