Article View: linux.kernel.netdev
Article #4196[PATCH bpf-next 19/38] bpf: Fix stale offload->prog pointer after realloc
From: Alexei Starovoitov
Date: Sat, 17 Oct 2026 01:24
Date: Sat, 17 Oct 2026 01:24
42 lines
9758 bytes
9758 bytes
From: Josef Bacik <josef@toxicpanda.com>
bpf_prog_realloc() moves a program that the rewrites of the verifier make
outgrow its pages. It updates aux->prog, but not the offload->prog of a
device-bound program. When the device is unregistered,
__bpf_offload_dev_netdev_unregister() hands the stale pointer to
__bpf_prog_offload_destroy(), which faults on the freed program:
BUG: unable to handle page fault for address: ffffc90000071050
RIP: 0010:__bpf_prog_offload_destroy+0x3f/0x310
It takes the right to load a device-bound XDP program, CAP_BPF and
CAP_NET_ADMIN or a BPF token, and a device that can be removed.
Commit a1aa9ef47c29 ("bpf: Fix stale offload->prog pointer after constant
blinding") repaired the other place that replaces a program. Do the same
here.
Fixes: ab3f0063c48c ("bpf: offload: add infrastructure for loading programs for a specific netdev")
Fixes: 2b3486bc2d23 ("bpf: Introduce device-bound XDP programs")
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
---
kernel/bpf/core.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c
index 642f0ab8eb2d..2154c18a5a4d 100644
--- a/kernel/bpf/core.c
+++ b/kernel/bpf/core.c
@@ -269,6 +269,8 @@ struct bpf_prog *bpf_prog_realloc(struct bpf_prog *fp_old, unsigned int size,
memcpy(fp, fp_old, fp_old->pages * PAGE_SIZE);
fp->pages = pages;
fp->aux->prog = fp;
+ if (fp->aux->offload)
+ fp->aux->offload->prog = fp;
/* We keep fp->aux from fp_old around in the new
* reallocated structure.
--
2.55.0
Technical Details
Message-ID:
<20261017012451.364800-11-alexei.starovoitov@gmail.com>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-347605-linux-kernel-netdev=dewy.ruReferences:
<20261017012058.355787-1-alexei.starovoitov@gmail.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-347605-linux-kernel-netdev=dewy.ru
From: alexei.starovoitov@gmail.com (Alexei Starovoitov)
Newsgroups: linux.kernel.netdev
Subject: [PATCH bpf-next 19/38] bpf: Fix stale offload->prog pointer after realloc
Date: Sat, 17 Oct 2026 01:24:32 +0000
Organization: Usenet Network
Message-ID: <20261017012451.364800-11-alexei.starovoitov@gmail.com>
References: <20261017012058.355787-1-alexei.starovoitov@gmail.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
logging-data="2934741"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:4gIWjnoOE8ggfHX7LfExqpM7Oyc= sha256:RLGWe6uxYahFnmqtnW9fzJT++OBzwzpb8LxQYYFGSlI=
sha1:yC9jsdhrS7O8+Pn1phSRo89ikIY= sha256:ylRE0I1AhzNVqRM5B9RvhKT77k76LO6z6Iglha9FQXk=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
by mail.dewy.ru (Postfix) with ESMTP id 65327110647; Sat, 17 Oct 2026 04:28:52 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.048
X-Spam-Status: No, score=-3.048 tagged_above=-9999 required=6.31
tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
DKIM_VALID_AU=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001,
FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25,
MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
SPF_PASS=-0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
header.d=gmail.com
X-Received: from mail.dewy.ru ([127.0.0.1])
by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
with ESMTP id o17ZFak9Yv9n;
Sat, 17 Oct 2026 04:28:49 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=netdev+bounces-347605-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN>
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=gmail.com
X-Received: from sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4])
by mail.dewy.ru (Postfix) with ESMTPS id 9E780110420; Sat, 17 Oct 2026 04:28:40 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1])
by sin.lore.kernel.org (Postfix) with ESMTP id 49F0526C83; Sat, 17 Oct 2026 01:28:36 +0000 (UTC)
X-Received: from localhost.localdomain (localhost.localdomain [127.0.0.1])
by smtp.subspace.kernel.org (Postfix) with ESMTP id 6796837DE9D;
Sat, 17 Oct 2026 01:28:33 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="RKmzgBe1"
X-Received: from mail-pj1-f42.google.com (mail-pj1-f42.google.com [209.85.216.42])
(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 4E1CC37B41F
for <netdev@vger.kernel.org>; Sat, 17 Oct 2026 01:28:32 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.42
X-ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;
t=1792200513; cv=none; b=XpHFNtxCsh8qvC/hrJYpnLyk7ZkeKFWKTnRlVRV7ZUuPt6LQpTnMRbK3Y1VQ/7E1xFKes1PsOPANP3GRCSdlum1d9XwQowMUjLDN5p3WkqXUV25mQHLP/ldoVwOgNjsjXa1bQmNBsk9/LRq2c432MCfODDZayukZO0erOHsWHvU=
X-ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org;
s=arc-20240116; t=1792200513; c=relaxed/simple;
bh=pMesjCa/gOkBIsk6vgDz145mredVUwi7QE/iBRjmDPk=;
h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:
MIME-Version; b=b6vA4pTWsZQlx1LysgNzhIsfVWMTuL/PMYiW8+jZCpokAtVJGUvMM39fZRrCNGg67AcbNvQsKahQ8CbXejM78mLUnWBvdtmYq/Ru4foPIIoDvhOyxg0WVPL7odbn8TYY5E/LfxGpNuFFBDMqeqPDadN2b1mM2Yw6uDc46SHvVdU=
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=RKmzgBe1; arc=none smtp.client-ip=209.85.216.42
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com
X-Received: by mail-pj1-f42.google.com with SMTP id 98e67ed59e1d1-38759bcd877so360206a91.2
for <netdev@vger.kernel.org>; Fri, 16 Oct 2026 18:28:32 -0700 (PDT)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20251104; t=1792200512; x=1792805312; 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:content-type;
bh=52tfald6BXy/mbUymb59GMIOFzcDzqbQQ+kKvj8rcFA=;
b=RKmzgBe1A7URYboNrjONXBj5df4I64Iua/i5nxm1lTynV721gBlAItu5Crsy9HO0Rg
qINLAafxMyDdq+ovAqhGBkTvSUcp5L5dHDeMTG5JvEsi8AndeDdtp8z0O9ehPbcLHZnk
znuvKQ9lnhVAu2nOsBqHsA2s2itspxkRUXMFQe8rgutGzjI0nDFF95Y7ikMu1JYIsrzk
7eT886DpZAzbQeMYg/H3F68BbwzBHWIqLILphj5/eKXSV89Z6VP4nllOdwhac9KwSwSP
ZLuX8MnGcNDPZ/LSPdUrwcrtfSE9NTgUxKA/IKgsMhvc5H0CbCb4i2az1S7mbMPmxQWa
BEGg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20260707; t=1792200512; x=1792805312;
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:content-type;
bh=52tfald6BXy/mbUymb59GMIOFzcDzqbQQ+kKvj8rcFA=;
b=UchzYCp+n4Pin9JdwVM0j2JURHKsLR6dM4etubhESrKmQNsWid0/DmIhnDJH4usRoy
2SQxLu2ENUjRS5tbb1ZwqxqmOW70wHEJ2O2joxQtLgvuL0QoCleVuLvncrE0UitatTrM
jCz38uax/DDM84jSflnncGgnAhGzX7Xw18DEgdm6YNEPq6kGtzkXU4AeNj91+IjlMxCv
uBD/aHcwPIUT1D9QVBcjXRqu8w6y4DSBi0YaYyPWfYynDW8vWT8yXeG7miQL2Ge8Dywy
heCfwJ9WQYsNUt5rhcw4w/fWoe2rxJTBkkt/3ZNlG97yeI0g7qg58ahRS8q7ckwqM3St
iVfQ==
X-Forwarded-Encrypted: i=1; AKwUvBxA39WU2T+jupgCxTDI3AMX10u6nM7fc7J/xnzcH4akw2lABlyxr80CKhYqupl4m6YPf4Nkooo=@vger.kernel.org
X-Gm-Message-State: AFq9FYLX3VW037GvSWqSrIUHZ5UE+ldahKNJb1FarPdrMQQQ/HSz7opp
V9G6Ph+yb55CG7SboczAG3wepRGeBhzB7R2e5byuD0QK+WpgWwD5JDXC
X-Gm-Gg: AYBFou2FXxkuwhgwaf7WhA7UfN+J9913AbMOKUge1d1wH8TDH7jVlPIUqSIh66aH5RT
NFS84KpwYxKzjOI52ahWhTjNiqm1BkxN+Dt1zW4wkKHO6iESP+kC4oddVSN6KhWObnFWwKuKk4q
bHNbubhzfYBHS8QjsmUnzQWLPFNgMY1P2yacKH8YFL72MsZYKwtpPNeeuR9/2dsRRtQAZYa1qfi
XRWDwz/rTgl6i0STamgn8MPUCyUztL9SpFbK7d99W/iUP8VQ6BQ3b3X4HXMTeBBt3qcHw6tI9yF
KkG4sYFc/F7MBHtNOlHCBq0MLD88EtTXx1hlfKhwKYpWS2ACMcLmJvO0XIcY7X9pd5LRifX/0X9
gyr4fNLpoIRK/Na8DPC57B2DDbiQVQ/PksdZP3tc6J3Uh90EEHkP3sXQoM8Tmp0lHNZ9ez0QIof
hhKjJmfz4+VRFN3MU6LJqsE/3ffhbUDuHcCLk4Lmzp6VqkcGOcQAXLH34bwj1rNLcl5oJ/zemYH
kdCjEMZxUVQFrZTe8zSNMqZAaiMYekhuvArQ1oe80T8SQg2XBll3aKZttzHARScmqqSHBkVeZ6m
mcYYi4uQjei9JRYt+D+avMJ3+3W8MCjfI9+qJWAVl7I=
X-Received: by 2002:a17:90b:4a03:b0:3ac:7e3a:1033 with SMTP id 98e67ed59e1d1-3acef5c1a8fmr1303422a91.59.1792200511625;
Fri, 16 Oct 2026 18:28:31 -0700 (PDT)
X-Received: from coder-ast-ast-dev-ml-0.tail2dda0.ts.net ([153.61.198.252])
by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3ac94627250sm11176361a91.8.2026.10.16.18.28.30
(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
Fri, 16 Oct 2026 18:28:30 -0700 (PDT)
X-Cc: daniel@iogearbox.net,
andrii@kernel.org,
eddyz87@gmail.com,
memxor@gmail.com,
netdev@vger.kernel.org,
josef@toxicpanda.com,
mason@kernel.org
X-Mailer: git-send-email 2.55.0
X-In-Reply-To: <20261017012058.355787-1-alexei.starovoitov@gmail.com>
X-Precedence: bulk
X-Mailing-List: netdev@vger.kernel.org
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>