All of lore.kernel.org
 help / color / mirror / Atom feed
* 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
* [PATCH net-next 0/7] net: mctp: Improved bind handling
@ 2025-07-03  9:11 Matt Johnston
  2025-07-03  9:11 ` [PATCH net-next 5/7] net: mctp: Allow limiting binds to a peer address Matt Johnston
  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

This series improves a couple of aspects of MCTP bind() handling.

MCTP wasn't checking whether the same MCTP type was bound by multiple
sockets. That would result in messages being received by an arbitrary
socket, which isn't useful behaviour. Instead it makes more sense to
have the duplicate binds fail, the same as other network protocols.
An exception is made for more-specific binds to particular MCTP
addresses.

It is also useful to be able to limit a bind to only receive incoming
request messages (MCTP TO bit set) from a specific peer+type, so that
individual processes can communicate with separate MCTP peers. One
example is PLDM firmware update responder, which will initiate
communication with a device, and then the device will connect back to the
responder process. 

These limited binds are implemented by a connect() call on the socket
prior to bind. connect() isn't used in the general case for MCTP, since
a plain send() wouldn't provide the required MCTP tag argument for
addressing.

route-test.c will have non-trivial conflicts with Jeremy's in-review
"net: mctp: Add support for gateway routing" series - I'll post an
updated series once that lands.

Signed-off-by: Matt Johnston <matt@codeconstruct.com.au>
---
Matt Johnston (7):
      net: mctp: Prevent duplicate binds
      net: mctp: Treat MCTP_NET_ANY specially in bind()
      net: mctp: Add test for conflicting bind()s
      net: mctp: Use hashtable for binds
      net: mctp: Allow limiting binds to a peer address
      net: mctp: Test conflicts of connect() with bind()
      net: mctp: Add bind lookup test

 include/net/mctp.h         |   5 +-
 include/net/netns/mctp.h   |  15 +-
 net/mctp/af_mctp.c         | 145 +++++++++++++++--
 net/mctp/route.c           |  80 ++++++++--
 net/mctp/test/route-test.c | 391 ++++++++++++++++++++++++++++++++++++++++++++-
 5 files changed, 606 insertions(+), 30 deletions(-)
---
base-commit: 8b98f34ce1d8c520403362cb785231f9898eb3ff
change-id: 20250321-mctp-bind-e77968f180fd

Best regards,
-- 
Matt Johnston <matt@codeconstruct.com.au>


^ 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.