Subject: Re: [PATCH v2 03/10] net: Convert proto_ops bind() callbacks to use sockaddr_unspec

From: Simon Horman <[email-masked]>
Date: Wed, 15 Oct 2025 13:15:19 +0100

On Tue, Oct 14, 2025 at 03:43:25PM -0700, Kees Cook wrote:
> Update all struct proto_ops bind() callback function prototypes from
> "struct sockaddr *" to "struct sockaddr_unspec *" to avoid lying to the
> compiler about object sizes. Calls into struct proto handlers gain casts
> that will be removed in the struct proto conversion patch.
> 
> No binary changes expected.
> 
> Signed-off-by: Kees Cook <[email-masked]>

...

> diff --git a/net/mctp/af_mctp.c b/net/mctp/af_mctp.c
> index b99ba14f39d2..0a795901e4f2 100644
> --- a/net/mctp/af_mctp.c
> +++ b/net/mctp/af_mctp.c
> @@ -49,7 +49,7 @@ static bool mctp_sockaddr_ext_is_ok(const struct sockaddr_mctp_ext *addr)
>  	       !addr->__smctp_pad0[2];
>  }
>  
> -static int mctp_bind(struct socket *sock, struct sockaddr *addr, int addrlen)
> +static int mctp_bind(struct socket *sock, struct sockaddr_unspec *addr, int addrlen)
>  {
>  	struct sock *sk = sock->sk;
>  	struct mctp_sock *msk = container_of(sk, struct mctp_sock, sk);
> @@ -128,7 +128,7 @@ static int mctp_bind(struct socket *sock, struct sockaddr *addr, int addrlen)
>  /* 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,
> +static int mctp_connect(struct socket *sock, struct sockaddr_unspec *addr,
>  			int addrlen, int flags)
>  {
>  	struct sock *sk = sock->sk;

Hi Kees,

The change to mctp_connect() results GCC 15.2.0 warning as follows:

net/mctp/af_mctp.c:632:27: error: initialization of 'int (*)(struct socket *, struct sockaddr *, int,  int)' from incompatible pointer type 'int (*)(struct socket *, struct sockaddr_unspec *, int,  int)' [-Wincompatible-pointer-types]
  632 |         .connect        = mctp_connect,
      |                           ^~~~~~~~~~~~

As I don't see other _connect functions updated in this patch,
perhaps it is out of place here and should be dropped from this patch.

...

-- 
pw-bot: cr