From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f170.google.com (mail-pf1-f170.google.com [209.85.210.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D04FA2571B8 for ; Mon, 27 Apr 2026 02:21:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.170 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777256508; cv=none; b=M3mulTbjt/9H1jGVXLCusmlVLd/IZ1AUr5HkzPULBZ2VJlJMgqrYEcVEfWb/drg2irourpGUiYITG2WKM81IFlN73yXDSGgQwSSwSSb2qkwNifaUQ/CduIl2z5oSr+GTw61izTS3vdkhjfNi4h/VTPKQhEz2jxh/Q8AGK/5tnSk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777256508; c=relaxed/simple; bh=sWrJUi8cl9/CaVwIOP0PW2RVAENzXIRsdanxfXkA3LM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=iAUNMrK1AfiDBKBJT+gfpqGUb1vcipZQo76ioxZwmIUmt1bQEizrru4rivgxyQEBL3FtdzrhKRfzJTjYTUugZVtdKJjgC+69AGk+iojlAfbFZ4EzIPrVzlYV1qn45Fz+eYMGysH73EOsbCbahUcp8NfsI0AD69d2jN1COyBg7ww= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=snu.ac.kr; spf=pass smtp.mailfrom=snu.ac.kr; dkim=pass (1024-bit key) header.d=snu.ac.kr header.i=@snu.ac.kr header.b=uIcAWcs4; arc=none smtp.client-ip=209.85.210.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=snu.ac.kr Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=snu.ac.kr Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=snu.ac.kr header.i=@snu.ac.kr header.b="uIcAWcs4" Received: by mail-pf1-f170.google.com with SMTP id d2e1a72fcca58-82f83bd32efso7264597b3a.2 for ; Sun, 26 Apr 2026 19:21:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=snu.ac.kr; s=google; t=1777256503; x=1777861303; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=sWrJUi8cl9/CaVwIOP0PW2RVAENzXIRsdanxfXkA3LM=; b=uIcAWcs4Kfx5nl67IF3h/SKO+v3LmAqJQrvIX5LCewRx7VYla9jouh88b8kotqUHOU oOJNy35WvA8f2yRyFOpNnElREb9bf/BZiygXeau9Y7CdEALB+q5vnmhrhH0sovuBxDwT XipfqS8OXVfqL19jc+uSXajlsfEg0MntBfhcw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777256503; x=1777861303; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=sWrJUi8cl9/CaVwIOP0PW2RVAENzXIRsdanxfXkA3LM=; b=rMWr1b0enRqNilFDjgmd1xwPxOrpoXNdBfDDSa9E/xwp1VYbnNrddOSmL7MGDnQoSv 1CnjFVKSYLzBp6YwBwLVD8D+o6ixXP5//O4g7uwt5ZKX0VstQ735laGifU1SULddUSsm PhV8Pun12FKybK8IVZwfeXWgSt0D7HYU9wbDmkoFo9vlebAodSPVWBrWgCraYTpmGuYG 2vDu60RbABuKY5q11Epfc0BqUYultHYeBtBZmd/I7DCIC+qmx7AcZ4kBKmKX3MaJmQ0P pHOeKVweVSU9iR+8zIoOmNHvo/TqhjAKPm0mWcr48DZpagNptPfoxTYh3LuXa3WhwJjv Nxjg== X-Forwarded-Encrypted: i=1; AFNElJ8IyB+VvJHgpoe9vaxojI9AOfiMjKw6mNmZTHqwRxIno4rCtVoQ/UR/TKe+PjkcIcbG0HpclYoymIB6tk0=@vger.kernel.org X-Gm-Message-State: AOJu0YwdRWmNF882p5BSszv62W6JyvBxCnfOH0xpQmNO5rs+e/fjpXIA JGei2Kjx4AQYND/6JBE0XGvlBYGQV689azDy+4ENcRbszQgKyTL2EKp24hvStG+zrSY= X-Gm-Gg: AeBDievJuqXyda/8I/OMJarBRjQr957bheJP3d/W6kNtZyNKKMUyZ0LhKwFy+I45lz1 sDwSJXqZLN15dEAFPJXIJUG9MnymaS+e1IppUJUdwPjcpdrc99VXjugp3zWxCcj2jfPz/1YIrgv gxHF0SAo2IUQ8Inqz/zD+Nv7NsHnHIaZDYWxoVXhp+pmuWT8KJHZkciyjEMDP77qGihqeks80VD ipqMfszV87dyHx3jlm3jXcNhv5jQAxX/DptmF2BngUdkcntZITut6UVQMEl1sMSBkEzUPxcXF8o MWr6wSUe8UG3BRZp7HPl0HooLOS57KrGFpfx42N+3hMaJ0/hphgTfXiDv2+b9t4vtT1hKqJ3weH HDOcEtkzi8UBj4EnDc/pONXevokAfdSX4IsVToFwrAj7j/wXndLlfjlmxHB4kDGJDg4b/SpZNej SBIIAeTiUnN47SB1viOGkPvtjwvynBfTkMPDdiBJ86w3ey/Y2BEaqpAAZlqXhyShSEyJEiGzckJ GkoC+MHDeq+ X-Received: by 2002:a05:6a00:2d25:b0:824:adf4:5a2f with SMTP id d2e1a72fcca58-82f8c934230mr42491061b3a.43.1777256503240; Sun, 26 Apr 2026 19:21:43 -0700 (PDT) Received: from eulgyu-desktop.localdomain ([147.46.174.223]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-82f8e9d9a1csm32499509b3a.20.2026.04.26.19.21.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Apr 2026 19:21:42 -0700 (PDT) From: Eulgyu Kim 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 Message-ID: <20260427022135.38925-1-eulgyukim@snu.ac.kr> X-Mailer: git-send-email 2.43.0 In-Reply-To: <9992caa6-ec37-4727-ae5d-80d0b5b596c0@linux.dev> References: <9992caa6-ec37-4727-ae5d-80d0b5b596c0@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit > > 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