Re: [PATCH v3] netlabel: Fix NULL pointer exception caused by CALIPSO on IPv4 sockets

From: Paul Moore
Date: Wed Apr 02 2025 - 14:29:20 EST


On Wed, Apr 2, 2025 at 5:36 AM Simon Horman <horms@xxxxxxxxxx> wrote:
> On Tue, Apr 01, 2025 at 08:40:18PM +0800, Debin Zhu wrote:
> > When calling netlbl_conn_setattr(), addr->sa_family is used
> > to determine the function behavior. If sk is an IPv4 socket,
> > but the connect function is called with an IPv6 address,
> > the function calipso_sock_setattr() is triggered.
> > Inside this function, the following code is executed:
> >
> > sk_fullsock(__sk) ? inet_sk(__sk)->pinet6 : NULL;
> >
> > Since sk is an IPv4 socket, pinet6 is NULL, leading to a
> > null pointer dereference.
> >
> > This patch fixes the issue by checking if inet6_sk(sk)
> > returns a NULL pointer before accessing pinet6.
> >
> > Fixes: ceba1832b1b2("calipso: Set the calipso socket label to match the secattr.")
>
> There is probably no need to repost for this, but
> there is a missing space in the Fixes tag. It should be like this:
>
> Fixes: ceba1832b1b2 ("calipso: Set the calipso socket label to match the secattr.")

Thanks.

Not sure if the netdev folks are going to pick this up or if I'll end
up taking it, but if I end up taking it I'll update the tag while
merging.

> > Signed-off-by: Debin Zhu <mowenroot@xxxxxxx>
> > Signed-off-by: Bitao Ouyang <1985755126@xxxxxx>
> > Acked-by: Paul Moore <paul@xxxxxxxxxxxxxx>

--
paul-moore.com