Re: [PATCH v3] netlabel: Fix NULL pointer exception caused by CALIPSO on IPv4 sockets
From: Simon Horman
Date: Wed Apr 02 2025 - 05:36:20 EST
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.")
> Signed-off-by: Debin Zhu <mowenroot@xxxxxxx>
> Signed-off-by: Bitao Ouyang <1985755126@xxxxxx>
> Acked-by: Paul Moore <paul@xxxxxxxxxxxxxx>
...