* [PATCH net-next 5/7] net: mctp: Allow limiting binds to a peer address
2025-07-03 9:11 [PATCH net-next 0/7] net: mctp: Improved bind handling Matt Johnston
@ 2025-07-03 9:11 ` Matt Johnston
2025-07-14 19:16 ` Dan Carpenter
0 siblings, 1 reply; 4+ messages in thread
From: Matt Johnston @ 2025-07-03 9:11 UTC (permalink / raw)
To: Jeremy Kerr, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Simon Horman
Cc: netdev, Matt Johnston
Prior to calling bind() a program may call connect() on a socket to
restrict to a remote peer address.
Using connect() is the normal mechanism to specify a remote network
peer, so we use that here. In MCTP connect() is only used for bound
sockets - send() is not available for MCTP since a tag must be provided
for each message.
The smctp_type must match between connect() and bind() calls.
Signed-off-by: Matt Johnston <matt@codeconstruct.com.au>
---
include/net/mctp.h | 5 ++-
net/mctp/af_mctp.c | 104 +++++++++++++++++++++++++++++++++++++++++++++++++----
net/mctp/route.c | 6 +++-
3 files changed, 107 insertions(+), 8 deletions(-)
diff --git a/include/net/mctp.h b/include/net/mctp.h
index 07d458990113d2bc2ca597e40152f3d30e41e5dd..8d3c45bd9cda642af2fc3b3bc403bf36fc8d2990 100644
--- a/include/net/mctp.h
+++ b/include/net/mctp.h
@@ -69,7 +69,10 @@ struct mctp_sock {
/* bind() params */
unsigned int bind_net;
- mctp_eid_t bind_addr;
+ mctp_eid_t bind_local_addr;
+ mctp_eid_t bind_peer_addr;
+ unsigned int bind_peer_net;
+ bool bind_peer_set;
__u8 bind_type;
/* sendmsg()/recvmsg() uses struct sockaddr_mctp_ext */
diff --git a/net/mctp/af_mctp.c b/net/mctp/af_mctp.c
index 7638e22bf03848868768700fdac07f74891dad0d..a390460b2d5fc38555b8a6df45040c167cded628 100644
--- a/net/mctp/af_mctp.c
+++ b/net/mctp/af_mctp.c
@@ -79,20 +79,40 @@ static int mctp_bind(struct socket *sock, struct sockaddr *addr, int addrlen)
goto out_release;
}
- msk->bind_addr = smctp->smctp_addr.s_addr;
+ msk->bind_local_addr = smctp->smctp_addr.s_addr;
/* MCTP_NET_ANY with a specific EID is resolved to the default net
* at bind() time.
* For bind_addr=MCTP_ADDR_ANY it is handled specially at route lookup time.
*/
if (smctp->smctp_network == MCTP_NET_ANY &&
- msk->bind_addr != MCTP_ADDR_ANY) {
+ msk->bind_local_addr != MCTP_ADDR_ANY) {
msk->bind_net = mctp_default_net(net);
} else {
msk->bind_net = smctp->smctp_network;
}
- msk->bind_type = smctp->smctp_type & 0x7f; /* ignore the IC bit */
+ /* ignore the IC bit */
+ smctp->smctp_type &= 0x7f;
+
+ if (msk->bind_peer_set) {
+ if (msk->bind_type != smctp->smctp_type) {
+ /* Prior connect() had a different type */
+ return -EINVAL;
+ }
+
+ if (msk->bind_net == MCTP_NET_ANY) {
+ /* Restrict to the network passed to connect() */
+ msk->bind_net = msk->bind_peer_net;
+ }
+
+ if (msk->bind_net != msk->bind_peer_net) {
+ /* connect() had a different net to bind() */
+ return -EINVAL;
+ }
+ } else {
+ msk->bind_type = smctp->smctp_type;
+ }
rc = sk->sk_prot->hash(sk);
@@ -102,6 +122,67 @@ static int mctp_bind(struct socket *sock, struct sockaddr *addr, int addrlen)
return rc;
}
+/* Used to set a specific peer prior to bind. Not used for outbound
+ * connections (Tag Owner set) since MCTP is a datagram protocol.
+ */
+static int mctp_connect(struct socket *sock, struct sockaddr *addr,
+ int addrlen, int flags)
+{
+ struct sock *sk = sock->sk;
+ struct mctp_sock *msk = container_of(sk, struct mctp_sock, sk);
+ struct net *net = sock_net(&msk->sk);
+ struct sockaddr_mctp *smctp;
+ int rc;
+
+ if (addrlen != sizeof(*smctp))
+ return -EINVAL;
+
+ if (addr->sa_family != AF_MCTP)
+ return -EAFNOSUPPORT;
+
+ /* It's a valid sockaddr for MCTP, cast and do protocol checks */
+ smctp = (struct sockaddr_mctp *)addr;
+
+ if (!mctp_sockaddr_is_ok(smctp))
+ return -EINVAL;
+
+ /* Can't bind by tag */
+ if (smctp->smctp_tag)
+ return -EINVAL;
+
+ /* IC bit must be unset */
+ if (smctp->smctp_type & 0x80)
+ return -EINVAL;
+
+ lock_sock(sk);
+
+ if (sk_hashed(sk)) {
+ /* bind() already */
+ rc = -EADDRINUSE;
+ goto out_release;
+ }
+
+ if (msk->bind_peer_set) {
+ /* connect() already */
+ rc = -EADDRINUSE;
+ goto out_release;
+ }
+
+ msk->bind_peer_set = true;
+ msk->bind_peer_addr = smctp->smctp_addr.s_addr;
+ msk->bind_type = smctp->smctp_type;
+ if (smctp->smctp_network == MCTP_NET_ANY)
+ msk->bind_peer_net = mctp_default_net(net);
+ else
+ msk->bind_peer_net = smctp->smctp_network;
+
+ rc = 0;
+
+out_release:
+ release_sock(sk);
+ return rc;
+}
+
static int mctp_sendmsg(struct socket *sock, struct msghdr *msg, size_t len)
{
DECLARE_SOCKADDR(struct sockaddr_mctp *, addr, msg->msg_name);
@@ -563,7 +644,7 @@ static const struct proto_ops mctp_dgram_ops = {
.family = PF_MCTP,
.release = mctp_release,
.bind = mctp_bind,
- .connect = sock_no_connect,
+ .connect = mctp_connect,
.socketpair = sock_no_socketpair,
.accept = sock_no_accept,
.getname = sock_no_getname,
@@ -630,6 +711,7 @@ static int mctp_sk_init(struct sock *sk)
INIT_HLIST_HEAD(&msk->keys);
timer_setup(&msk->key_expiry, mctp_sk_expire_keys, 0);
+ msk->bind_peer_set = false;
return 0;
}
@@ -643,12 +725,17 @@ static int mctp_sk_hash(struct sock *sk)
struct net *net = sock_net(sk);
struct sock *existing;
struct mctp_sock *msk;
+ mctp_eid_t remote;
u32 hash;
int rc;
msk = container_of(sk, struct mctp_sock, sk);
- hash = mctp_bind_hash(msk->bind_type, msk->bind_addr, MCTP_ADDR_ANY);
+ if (msk->bind_peer_set)
+ remote = msk->bind_peer_addr;
+ else
+ remote = MCTP_ADDR_ANY;
+ hash = mctp_bind_hash(msk->bind_type, msk->bind_local_addr, remote);
mutex_lock(&net->mctp.bind_lock);
@@ -656,8 +743,13 @@ static int mctp_sk_hash(struct sock *sk)
sk_for_each(existing, &net->mctp.binds[hash]) {
struct mctp_sock *mex = container_of(existing, struct mctp_sock, sk);
+ bool same_peer = (mex->bind_peer_set && msk->bind_peer_set &&
+ mex->bind_peer_addr == msk->bind_peer_addr) ||
+ (!mex->bind_peer_set && !msk->bind_peer_set);
+
if (mex->bind_type == msk->bind_type &&
- mex->bind_addr == msk->bind_addr &&
+ mex->bind_local_addr == msk->bind_local_addr &&
+ same_peer &&
mex->bind_net == msk->bind_net) {
rc = -EADDRINUSE;
goto out;
diff --git a/net/mctp/route.c b/net/mctp/route.c
index 8a8c7841d2382717b3c9a6698036d56f64da77f0..3e5b87be312857282947399750566d90c474546c 100644
--- a/net/mctp/route.c
+++ b/net/mctp/route.c
@@ -63,7 +63,11 @@ static struct mctp_sock *mctp_lookup_bind_details(struct net *net,
if (msk->bind_type != type)
continue;
- if (!mctp_address_matches(msk->bind_addr, dest))
+ if (msk->bind_peer_set &&
+ !mctp_address_matches(msk->bind_peer_addr, src))
+ continue;
+
+ if (!mctp_address_matches(msk->bind_local_addr, dest))
continue;
return msk;
--
2.43.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH net-next 5/7] net: mctp: Allow limiting binds to a peer address
@ 2025-07-07 21:27 kernel test robot
0 siblings, 0 replies; 4+ messages in thread
From: kernel test robot @ 2025-07-07 21:27 UTC (permalink / raw)
To: oe-kbuild; +Cc: lkp, Dan Carpenter
BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
In-Reply-To: <20250703-mctp-bind-v1-5-bb7e97c24613@codeconstruct.com.au>
References: <20250703-mctp-bind-v1-5-bb7e97c24613@codeconstruct.com.au>
TO: Matt Johnston <matt@codeconstruct.com.au>
TO: Jeremy Kerr <jk@codeconstruct.com.au>
TO: "David S. Miller" <davem@davemloft.net>
CC: netdev@vger.kernel.org
TO: Eric Dumazet <edumazet@google.com>
TO: Jakub Kicinski <kuba@kernel.org>
TO: Paolo Abeni <pabeni@redhat.com>
TO: Simon Horman <horms@kernel.org>
CC: Matt Johnston <matt@codeconstruct.com.au>
Hi Matt,
kernel test robot noticed the following build warnings:
[auto build test WARNING on 8b98f34ce1d8c520403362cb785231f9898eb3ff]
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
:::::: branch date: 5 days ago
:::::: commit date: 5 days ago
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@intel.com>
| Reported-by: Dan Carpenter <error27@gmail.com>
| 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
e9ea574ec1c27e5 Eugene Syromiatnikov 2021-11-03 51
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);
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;
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;
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 }
8f601a1e4f8c84f Jeremy Kerr 2021-07-29 124
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net-next 5/7] net: mctp: Allow limiting binds to a peer address
2025-07-03 9:11 ` [PATCH net-next 5/7] net: mctp: Allow limiting binds to a peer address Matt Johnston
@ 2025-07-14 19:16 ` Dan Carpenter
2025-07-15 1:13 ` Matt Johnston
0 siblings, 1 reply; 4+ messages in thread
From: Dan Carpenter @ 2025-07-14 19:16 UTC (permalink / raw)
To: oe-kbuild, Matt Johnston, Jeremy Kerr, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Simon Horman
Cc: lkp, oe-kbuild-all, netdev, Matt Johnston
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@intel.com>
| Reported-by: Dan Carpenter <dan.carpenter@linaro.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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net-next 5/7] net: mctp: Allow limiting binds to a peer address
2025-07-14 19:16 ` Dan Carpenter
@ 2025-07-15 1:13 ` Matt Johnston
0 siblings, 0 replies; 4+ messages in thread
From: Matt Johnston @ 2025-07-15 1:13 UTC (permalink / raw)
To: Dan Carpenter, oe-kbuild, Jeremy Kerr, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Simon Horman
Cc: lkp, oe-kbuild-all, netdev
Hi,
On Mon, 2025-07-14 at 22:16 +0300, Dan Carpenter wrote:
> 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
...
> smatch warnings:
> net/mctp/af_mctp.c:122 mctp_bind() warn: inconsistent returns 'sk'.
...
> 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?
This was fixed in the v4 series.
Cheers,
Matt
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-07-15 1:13 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-07 21:27 [PATCH net-next 5/7] net: mctp: Allow limiting binds to a peer address kernel test robot
-- strict thread matches above, loose matches on Subject: below --
2025-07-03 9:11 [PATCH net-next 0/7] net: mctp: Improved bind handling Matt Johnston
2025-07-03 9:11 ` [PATCH net-next 5/7] net: mctp: Allow limiting binds to a peer address Matt Johnston
2025-07-14 19:16 ` Dan Carpenter
2025-07-15 1:13 ` Matt Johnston
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.