From nobody Mon Jun 8 04:24:35 2026 Received: from mail-ot1-f71.google.com (mail-ot1-f71.google.com [209.85.210.71]) (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 515002D780C for ; Tue, 2 Jun 2026 01:39:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.71 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780364398; cv=none; b=RMcNOwhvVWzrv4pi4fHze+Fihx0+c9/n4gVdlt8c3r1b9nFl4mkuHJB2cwcRx5NjVBT95klGBy1IpYJ7IHlUbyPkTIzTms4pFL1rj/hOMp47eOx/c1ENeleBefITlRHLGyqSZK+AJK+ewY4qKmpWVKbEgWRoXEYNAyT9OCYnaOA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780364398; c=relaxed/simple; bh=0IJ+Gjb+UgW6a1WFcO8qESKdRVhp1824Is/5BJl+KAE=; h=MIME-Version:Date:In-Reply-To:Message-ID:Subject:From:To: Content-Type; b=uP70Tcnnl5gsfJVTHyjQ5lYRpDcuWiCQ3grtAw5hei5RUccf5UNnoGmWbVPk8mok6ggt4bZpqt3lrUeoYCrFa806C7/BLQjvLtsCpHMYWNQ5Yqal+idOmkVb6G+KaKldnbIqF+6QxAcI3vOUx3fdd908Loh35svt6RaO/OfLmck= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=syzkaller.appspotmail.com; spf=pass smtp.mailfrom=M3KW2WVRGUFZ5GODRSRYTGD7.apphosting.bounces.google.com; arc=none smtp.client-ip=209.85.210.71 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=syzkaller.appspotmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=M3KW2WVRGUFZ5GODRSRYTGD7.apphosting.bounces.google.com Received: by mail-ot1-f71.google.com with SMTP id 46e09a7af769-7e6c75244dcso2171444a34.0 for ; Mon, 01 Jun 2026 18:39:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780364396; x=1780969196; h=to:from:subject:message-id:in-reply-to:date:mime-version :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=bdOrtgVswca2WK8zLJQsFb2L0o85FsTFCRZ3qaXkcQM=; b=IDzWfZa8gVoEkG5ilEpW6qFUn6/0KM/SWN74Q9vOXpLsfLFPgee+sXEDhURAhe2hu1 rdypCSTH0gHnLqGA8tiRCoV+V4nzQ8TKZ0nVKZ0mVy3HfNBaMz3AWGpWeE+tM/M/CWBH PAkFn6DHHBu2qCTa6IMtjoOESaGilkqV9Au74OhyuhPlkS4oiPmk/UUHVD6XRmrnAUuB aNbYzaYLAXHm35bT97jS/lDQUWiyTxUg4JVzDxmlQf/S4d02QqVSnQPJQTqMS1Aiomyx Qnh4hVjEO9Tkwvatd34mBoG9j9Rqv4TljvMKW0KsbSLcE/L11zpSy75JGqyI7heMbHxQ Vf5Q== X-Gm-Message-State: AOJu0Ywp/XeNcpq+C0NOXNsfhfLP/1K3BIMXThJ80O9zvX/4YXNWN9EA xhjEiKpUnICViYHpqYfZL+Qni6I4JdEx0MPrh9YPDxB5wleGLbcgC/ZG0Va5cLaoFKyyNt+gNdv 1LQB5qO6DOJGrD5wDVXwXUXkr0aq1H4pirEbKIwugjvI4LVVg+7ZsWxrxQuE= Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Received: by 2002:a4a:e849:0:b0:69b:bf80:2db3 with SMTP id 006d021491bc7-69e10577beamr7123988eaf.44.1780364396397; Mon, 01 Jun 2026 18:39:56 -0700 (PDT) Date: Mon, 01 Jun 2026 18:39:56 -0700 In-Reply-To: <6a1dbc91.fbc46276.3c3783.0004.GAE@google.com> X-Google-Appengine-App-Id: s~syzkaller X-Google-Appengine-App-Id-Alias: syzkaller Message-ID: <6a1e346c.fbc46276.3c3783.0006.GAE@google.com> Subject: Forwarded: [PATCH] bpf: fix UAF by restoring RCU-delayed inode freeing in bpffs From: syzbot To: linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" For archival purposes, forwarding an incoming command email to linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com. *** Subject: [PATCH] bpf: fix UAF by restoring RCU-delayed inode freeing in bpf= fs Author: kartikey406@gmail.com #syz test: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git= master commit 4f375ade6aa9 moved all inode cleanup from ->free_inode() into ->destroy_inode() to avoid a sleeping-in-RCU-context warning when calling bpf_any_put(). However this removed the RCU delay on freeing the inode itself and the cached symlink body (i_link), both of which can be accessed by RCU pathwalk (pick_link, may_lookup etc.). This causes a use-after-free when a concurrent unlinkat() drops the last inode reference and destroy_inode() frees the inode immediately, while another task is still walking the path in RCU mode and reads inode->i_opflags (offset +2) inside current_time() -> is_mgtime(). KASAN reports: BUG: KASAN: slab-use-after-free in is_mgtime include/linux/fs.h:2313 Read of size 2 at addr ffff8880407e4282 (offset +2 =3D i_opflags) The rules (per Al Viro): ->destroy_inode() called immediately, can sleep, use for blocking cleanup e.g. bpf_any_put() ->free_inode() called after RCU grace period, use for freeing inode and anything RCU-accessible e.g. i_link Fix: keep bpf_any_put() in destroy_inode() since it is blocking, but move kfree(i_link) and free_inode_nonrcu() into a new bpf_free_inode() so they happen after RCU delay, preventing the UAF. Reported-by: syzbot+36e50496c8ac4bcde3f9@syzkaller.appspotmail.com Link: https://syzkaller.appspot.com/bug?extid=3D36e50496c8ac4bcde3f9 Link: https://lore.kernel.org/all/20260423043906.GN3518998@ZenIV/ Signed-off-by: Deepanshu Kartikey --- kernel/bpf/inode.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/kernel/bpf/inode.c b/kernel/bpf/inode.c index 25c06a011825..188c774a469c 100644 --- a/kernel/bpf/inode.c +++ b/kernel/bpf/inode.c @@ -766,10 +766,18 @@ static void bpf_destroy_inode(struct inode *inode) { enum bpf_type type; =20 - if (S_ISLNK(inode->i_mode)) - kfree(inode->i_link); if (!bpf_inode_type(inode, &type)) bpf_any_put(inode->i_private, type); +} + +/* + * Called after RCU grace period - safe to free inode and anything + * that might be accessed by RCU pathwalk (inode fields, i_link). + */ +static void bpf_free_inode(struct inode *inode) +{ + if (S_ISLNK(inode->i_mode)) + kfree(inode->i_link); free_inode_nonrcu(inode); } =20 @@ -778,6 +786,7 @@ const struct super_operations bpf_super_ops =3D { .drop_inode =3D inode_just_drop, .show_options =3D bpf_show_options, .destroy_inode =3D bpf_destroy_inode, + .free_inode =3D bpf_free_inode, }; =20 enum { --=20 2.43.0