mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Simon Horman <horms@kernel.org>
To: "Cen Zhang (Microsoft)" <blbllhy@gmail.com>
Cc: pablo@netfilter.org, laforge@gnumonks.org, andrew+netdev@lunn.ch,
	davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
	pabeni@redhat.com, osmocom-net-gprs@lists.osmocom.org,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	AutonomousCodeSecurity@microsoft.com,
	tgopinath@linux.microsoft.com, kys@microsoft.com,
	"Xiang Mei (Microsoft)" <xmei5@asu.edu>
Subject: Re: [PATCH net] gtp: fix NULL pointer dereference in gtp0_handle_echo_resp()
Date: Wed, 19 Aug 2026 13:48:20 +0100	[thread overview]
Message-ID: <20260819124820.GR265046@horms.kernel.org> (raw)
In-Reply-To: <20260816035205.57966-1-blbllhy@gmail.com>

On Sat, Aug 15, 2026 at 11:52:05PM -0400, Cen Zhang (Microsoft) wrote:
> In gtp_create_sockets(), gtp->sk_created is set to true before gtp->sk0
> and gtp->sk1u are assigned. A concurrent GTP Echo Response packet on
> another CPU observes sk_created == true and dereferences the still-NULL
> gtp->sk0 in gtp0_handle_echo_resp(), causing a kernel panic.
> 
>   KASAN: null-ptr-deref in range [0x0000000000000010-0x0000000000000017]
>   RIP: 0010:gtp_encap_recv  (drivers/net/gtp.c:542 gtp0_handle_echo_resp)
>   Call Trace:
>    <IRQ>
>    udp_queue_rcv_one_skb
>    ip_protocol_deliver_rcu
>    ip_local_deliver
>   Kernel panic - not syncing: Fatal exception in interrupt
> 
> Reorder the assignments so that gtp->sk0 and gtp->sk1u are fully visible
> before gtp->sk_created is set to true. This ensures no concurrent packet
> path can observe the flag without valid socket pointers.
> 
> Fixes: b20dc3c68458 ("gtp: Allow to create GTP device without FDs")
> Reported-by: AutonomousCodeSecurity@microsoft.com
> Reported-by: Xiang Mei (Microsoft) <xmei5@asu.edu>
> Reported-by: Cen Zhang (Microsoft) <blbllhy@gmail.com>
> Signed-off-by: Cen Zhang (Microsoft) <blbllhy@gmail.com>
> ---
>  drivers/net/gtp.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/gtp.c b/drivers/net/gtp.c
> index 9a12cc53da00..2b5a8f6d24d0 100644
> --- a/drivers/net/gtp.c
> +++ b/drivers/net/gtp.c
> @@ -1456,9 +1456,9 @@ static int gtp_create_sockets(struct gtp_dev *gtp, const struct nlattr *nla,
>  		return PTR_ERR(sk1u);
>  	}
>  
> -	gtp->sk_created = true;
>  	gtp->sk0 = sk0;
>  	gtp->sk1u = sk1u;
> +	gtp->sk_created = true;

I don't believe that this is sufficient to address the problem described as
there is no synchronisation between the reader and writer of sk_created.

I wonder if this might be addressed using smp_store_release/smp_load_acquire.

-- 
pw-bot: changes-requested

      reply	other threads:[~2026-08-19 12:48 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-16  3:52 Cen Zhang (Microsoft)
2026-08-19 12:48 ` Simon Horman [this message]

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=20260819124820.GR265046@horms.kernel.org \
    --to=horms@kernel.org \
    --cc=AutonomousCodeSecurity@microsoft.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=blbllhy@gmail.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=kys@microsoft.com \
    --cc=laforge@gnumonks.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=osmocom-net-gprs@lists.osmocom.org \
    --cc=pabeni@redhat.com \
    --cc=pablo@netfilter.org \
    --cc=tgopinath@linux.microsoft.com \
    --cc=xmei5@asu.edu \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®