lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250709091120.GQ452973@horms.kernel.org>
Date: Wed, 9 Jul 2025 10:11:20 +0100
From: Simon Horman <horms@...nel.org>
To: Matt Johnston <matt@...econstruct.com.au>
Cc: 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>,
	netdev@...r.kernel.org
Subject: Re: [PATCH net-next v3 6/8] net: mctp: Allow limiting binds to a
 peer address

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ