From nobody Fri Apr 17 09:30:28 2026 Received: from mail-oo1-f69.google.com (mail-oo1-f69.google.com [209.85.161.69]) (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 88ED7286410 for ; Sat, 21 Feb 2026 05:41:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.69 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771652485; cv=none; b=S49mz9wKfoOINX9KHi/7yOG8CvrLxjsjqH1YQ///ZREJ8FSaCQ/xOfKtHSGvdeC0PQopgnrtRAGXnA9hsOXDsio5xwRMUWCbBqAovhkuQfu1oQb9RgDvIldU9eQZh5hx5qFf0QO2/LYxFHlaTAK+OlyHNNFnorJW0RpEIWcmD8M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771652485; c=relaxed/simple; bh=LRyCw29QqsfFwGv1Xkxb3Nblodx8I52dDY7TMJam3CY=; h=MIME-Version:Date:In-Reply-To:Message-ID:Subject:From:To: Content-Type; b=Kz66pvmVXO0KXGzjz08VzPMcnuHDeux2DcVbFDiTnCXSkH/7/WX5D2elRHRcBFkr0pIis/S6iuQnx2yk+vtA7EgYnW0WOL1Grxbf2AlwFqPeD3/P7JtvcYWz8JYcmISg5csT1vIoU3SdlP+BkdwBBLY/vgrppNQlkZPRcEHWSYk= 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.161.69 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-oo1-f69.google.com with SMTP id 006d021491bc7-672c40f3873so36124031eaf.2 for ; Fri, 20 Feb 2026 21:41:24 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771652483; x=1772257283; 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=FV/SLU6zsrD8zpHdgNupjD8mwdIx/CGYhbofKAzbvSU=; b=XbQAUkgTePGZXVXSbUCLbMoE07lqxgZCBbcHvVeSiqmOYiyYdD9lAygNgptKAucBnD ovmS/PGnx3tLDYNl8mmQdfXSd7rtICuKRd245jjO6NwjsrhGfIbW/O0EawNSm/rKdYP/ mFoCtKxJGQsepxmulCTjyFOu9b9whXoT7P49vtXLZGHOzp5hCkxHOA8bBF8O5TpbtOJH 49ZPa0xLhCqNcfb407ap8uoENMTjIeEzvasCRciVMNwwRpYq3tGV+9aSteRcMDl3T69R wg3FQlUrC9fphik0ijzBuSP42aJCgas1Njs2Y3Uoxl5kxGEIPerg4G/tf1bIP3cZ5b7q 4sHw== X-Gm-Message-State: AOJu0Yw9pXsoPqG84zWZLJANFcp+Jj/TVB9JHo0w+3AgQdMLIS1JCBHB YWKmBQc79gM9M+BWskNg2Feg4cAP0BRy7OA8FuWr8W4SKZ0c8u2s9ko/gl2Lit2oJt3oZtaNBx+ J/sN6/HSMK+c83PBKgAK5Jmb1CbwNrs2PD7lr2VMNufahTMk4kweFqQQq6+g= Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Received: by 2002:a05:6820:1ca8:b0:679:c328:e593 with SMTP id 006d021491bc7-679c44b1ae7mr1346427eaf.24.1771652483372; Fri, 20 Feb 2026 21:41:23 -0800 (PST) Date: Fri, 20 Feb 2026 21:41:23 -0800 In-Reply-To: <699938a6.a70a0220.2c38d7.0150.GAE@google.com> X-Google-Appengine-App-Id: s~syzkaller X-Google-Appengine-App-Id-Alias: syzkaller Message-ID: <69994583.050a0220.340abe.0d22.GAE@google.com> Subject: Forwarded: [PATCH] bpf: Fix use-after-free in bpf_raw_tp_link_dealloc 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 use-after-free in bpf_raw_tp_link_dealloc Author: kartikey406@gmail.com #syz test: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git= master When a BPF raw tracepoint link is released, bpf_raw_tp_link_release() calls bpf_probe_unregister(), which internally calls tracepoint_probe_unregister(). This function performs an RCU-deferred swap of the tracepoint's funcs array via call_rcu(), so that existing readers can finish observing the old array (which still references the link) before it is replaced. Concurrently, bpf_link_put_direct() schedules its own call_rcu() to invoke bpf_raw_tp_link_dealloc(). Since both call_rcu() calls are issued at roughly the same time, the dealloc grace period can complete before the tracepoint's internal grace period. When this happens, kfree(raw_tp) runs while RCU readers can still reach the link via the old funcs array, causing a use-after-free in __bpf_trace_run() when it dereferences link->link.prog. Fix this by replacing kfree(raw_tp) with kfree_rcu(raw_tp, rcu), adding an rcu_head field to struct bpf_raw_tp_link. This ensures a third grace period elapses before the memory is freed, guaranteeing that all readers which could have observed the old funcs array have completed before the link is released. Reported-by: syzbot+59701a78e84b0bccfe1b@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=3D59701a78e84b0bccfe1b Signed-off-by: Deepanshu Kartikey --- include/linux/bpf.h | 1 + kernel/bpf/syscall.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/include/linux/bpf.h b/include/linux/bpf.h index cd9b96434904..673d19b360a7 100644 --- a/include/linux/bpf.h +++ b/include/linux/bpf.h @@ -1893,6 +1893,7 @@ struct bpf_raw_tp_link { struct bpf_link link; struct bpf_raw_event_map *btp; u64 cookie; + struct rcu_head rcu; }; =20 struct bpf_link_primer { diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c index dd89bf809772..b9dfc36d8a77 100644 --- a/kernel/bpf/syscall.c +++ b/kernel/bpf/syscall.c @@ -3790,7 +3790,7 @@ static void bpf_raw_tp_link_dealloc(struct bpf_link *= link) struct bpf_raw_tp_link *raw_tp =3D container_of(link, struct bpf_raw_tp_link, link); =20 - kfree(raw_tp); + kfree_rcu(raw_tp, rcu); } =20 static void bpf_raw_tp_link_show_fdinfo(const struct bpf_link *link, --=20 2.43.0