public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Eulgyu Kim <eulgyukim@snu.ac.kr>
To: edumazet@google.com, jiayuan.chen@linux.dev, pabeni@redhat.com
Cc: davem@davemloft.net, kuba@kernel.org, horms@kernel.org,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	byoungyoung@snu.ac.kr, jjy600901@snu.ac.kr
Subject: Re: [BUG] KASAN: slab-use-after-free Write in sk_skb_reason_drop
Date: Mon, 27 Apr 2026 11:21:35 +0900	[thread overview]
Message-ID: <20260427022135.38925-1-eulgyukim@snu.ac.kr> (raw)
In-Reply-To: <9992caa6-ec37-4727-ae5d-80d0b5b596c0@linux.dev>

>
> The fix could be this:
>
> diff --git a/drivers/net/tun.c b/drivers/net/tun.c
> index b183189f1853..6a0bbd4def76 100644
> --- a/drivers/net/tun.c
> +++ b/drivers/net/tun.c
> @@ -289,8 +289,12 @@ static void tun_napi_disable(struct tun_file *tfile)
>
>   static void tun_napi_del(struct tun_file *tfile)
>   {
> -       if (tfile->napi_enabled)
> -               netif_napi_del(&tfile->napi);
> +       if (!tfile->napi_enabled)
> +               return;
> +
> +       mutex_lock(&tfile->napi_mutex);
> +       netif_napi_del(&tfile->napi);
> +       mutex_unlock(&tfile->napi_mutex);
>   }
>
>   static bool tun_napi_frags_enabled(const struct tun_file *tfile)
> @@ -1783,6 +1787,12 @@ static ssize_t tun_get_user(struct tun_struct
> *tun, struct tun_file *tfile,
>
>                  if (frags) {
>                          mutex_lock(&tfile->napi_mutex);
> +                       if (unlikely(tfile->detached ||
> + rcu_access_pointer(tfile->tun) != tun)) {
> +                               err = -EBUSY;
> +  mutex_unlock(&tfile->napi_mutex);
> +                               goto out;
> +                       }
>                          skb = tun_napi_alloc_frags(tfile, copylen, from);
>                          /* tun_napi_alloc_frags() enforces a layout for
> the skb.
>                           * If zerocopy is enabled, then this layout will be
> @@ -1981,6 +1991,7 @@ static ssize_t tun_get_user(struct tun_struct
> *tun, struct tun_file *tfile,
>                  mutex_unlock(&tfile->napi_mutex);
>          }
>
> +out:
>          return err ?: total_len;
>   }
>

Hello,

We have tested the proposed patch, and our reproducer did not trigger any issue.

Thanks!

Best Regards,
Eulgyu Kim

      reply	other threads:[~2026-04-27  2:21 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-23 13:41 [BUG] KASAN: slab-use-after-free Write in sk_skb_reason_drop Eulgyu Kim
2026-04-23 14:13 ` Eric Dumazet
2026-04-23 14:27 ` Jiayuan Chen
2026-04-27  2:21   ` Eulgyu Kim [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=20260427022135.38925-1-eulgyukim@snu.ac.kr \
    --to=eulgyukim@snu.ac.kr \
    --cc=byoungyoung@snu.ac.kr \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=jiayuan.chen@linux.dev \
    --cc=jjy600901@snu.ac.kr \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    /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