From nobody Fri Apr 17 09:16:54 2026 Received: from mail-oo1-f70.google.com (mail-oo1-f70.google.com [209.85.161.70]) (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 A8315207A38 for ; Sat, 21 Feb 2026 05:19:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.70 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771651171; cv=none; b=KFmpxm5Tnq07QXr7G8tW4iHuv9F3+S5Obzvd1ZH1p7q1cL/QdFYmnODdLgbYo/yMh3XImuokFlVKPDl31Hq1RvKula3AYgeR+0ae95kd8KiYppSxfK+dEB5TrHKBg1Pnw+ylOc9yp233sDJBbNrALmF64ra1zd/Iy9Jvn0XWH/s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771651171; c=relaxed/simple; bh=LRyCw29QqsfFwGv1Xkxb3Nblodx8I52dDY7TMJam3CY=; h=MIME-Version:Date:In-Reply-To:Message-ID:Subject:From:To: Content-Type; b=p5INip4dsqdHfzReqIahuXOmPvYQ72GGcEwOf460RTj+s7BKArNaS3iebVdUwXcUVfeZxLnL/t/Yjti330EK+6JE2lK9jAm7xfpBXDm9jM6QiwIYqeSZwkOY8AWnAvt7+v0kLWsHF+ojp/B47XTkHk8R08NJdb9NZjt7prorLUs= 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.70 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-f70.google.com with SMTP id 006d021491bc7-676c2e00f3fso43565623eaf.0 for ; Fri, 20 Feb 2026 21:19:29 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771651168; x=1772255968; 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=Y6wr0J0VKiFrioP861IzljOgKlFeeQttXSv9zUddd5mYSogikPetptUBxiX5HtFkqg 7nCgQW7cBD52rd0itBqWbP1FxDTyQQqb1fKy0l+CSjpuj5FmXpwBBEUXmOJex6qMYEy0 zv3opGlLdGDOZfnMM9jvECvr0Xv2JtH1srNO0Y2Hjig9kfn0yEdF47d81+Pk61P0pm48 kbyf+xiKLvpI7MfMLOoir/tEL1Ok/NMdjhch3vgs0D9gV13vV3LVOLPZCSr1ywiFB8WB 5tkJ4SHhiLIKinwj3DQp6G3wMHIkJqylC19kM0bPZAVH6xP8DG3E2yY06iwK3TGgZlAD uWMA== X-Gm-Message-State: AOJu0Yw+dolDEHi/923BPhSWN5PAYPNDKn2wcZ4Re49zd+SoMVoSv13T x8TMuyiWxR9fURWcxBoWqGTqw6UQ+yXtDNXZHO8oc0oGsGI9wzfUeOspIrnnrQBeuWmr9ALM00B oIaTc5IgAcVKYlfw01Yuk/qFdnBI6ewSFe+fVhXD/8IZVYjqo0j2c8zdgOUY= 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:1613:b0:679:a41d:2d3a with SMTP id 006d021491bc7-679b0e0bd69mr4640914eaf.14.1771651168476; Fri, 20 Feb 2026 21:19:28 -0800 (PST) Date: Fri, 20 Feb 2026 21:19:28 -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: <69994060.a70a0220.2c38d7.0152.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