All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Horman <horms@kernel.org>
To: Matt Johnston <matt@codeconstruct.com.au>
Cc: Jeremy Kerr <jk@codeconstruct.com.au>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	netdev@vger.kernel.org
Subject: Re: [PATCH net-next v3 6/8] net: mctp: Allow limiting binds to a peer address
Date: Wed, 9 Jul 2025 10:11:20 +0100	[thread overview]
Message-ID: <20250709091120.GQ452973@horms.kernel.org> (raw)
In-Reply-To: <20250709-mctp-bind-v3-6-eac98bbf5e95@codeconstruct.com.au>

On Wed, Jul 09, 2025 at 04:31:07PM +0800, Matt Johnston wrote:

...

> @@ -87,13 +87,33 @@ static int mctp_bind(struct socket *sock, struct sockaddr *addr, int addrlen)
>  	 * 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;

Hi Matt,

I think you need to set rc and goto out_release here so
that sk is released.

> +		}
> +
> +		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;

Ditto.

Flagged by Smatch.

> +		}
> +	} else {
> +		msk->bind_type = smctp->smctp_type;
> +	}
>  
>  	rc = sk->sk_prot->hash(sk);
>  

...

-- 
pw-bot: changes-requested

  reply	other threads:[~2025-07-09  9:11 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-09  8:31 [PATCH net-next v3 0/8] net: mctp: Improved bind handling Matt Johnston
2025-07-09  8:31 ` [PATCH net-next v3 1/8] net: mctp: mctp_test_route_extaddr_input cleanup Matt Johnston
2025-07-09  9:03   ` Simon Horman
2025-07-09  9:06     ` Matt Johnston
2025-07-09  9:12       ` Simon Horman
2025-07-09  8:31 ` [PATCH net-next v3 2/8] net: mctp: Prevent duplicate binds Matt Johnston
2025-07-09  8:31 ` [PATCH net-next v3 3/8] net: mctp: Treat MCTP_NET_ANY specially in bind() Matt Johnston
2025-07-09  8:31 ` [PATCH net-next v3 4/8] net: mctp: Add test for conflicting bind()s Matt Johnston
2025-07-09  8:31 ` [PATCH net-next v3 5/8] net: mctp: Use hashtable for binds Matt Johnston
2025-07-09  8:31 ` [PATCH net-next v3 6/8] net: mctp: Allow limiting binds to a peer address Matt Johnston
2025-07-09  9:11   ` Simon Horman [this message]
2025-07-09  8:31 ` [PATCH net-next v3 7/8] net: mctp: Test conflicts of connect() with bind() Matt Johnston
2025-07-09  8:31 ` [PATCH net-next v3 8/8] net: mctp: Add bind lookup test Matt Johnston

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250709091120.GQ452973@horms.kernel.org \
    --to=horms@kernel.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=jk@codeconstruct.com.au \
    --cc=kuba@kernel.org \
    --cc=matt@codeconstruct.com.au \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.