From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-dl1-f73.google.com (mail-dl1-f73.google.com [74.125.82.73]) (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 66D8423D7CF for ; Sat, 10 Jan 2026 08:25:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.73 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768033557; cv=none; b=jMEAXdo7T3a4QUx4Kw8LLgWCtpWeyq3AcVruQnKcF0bdLazo3qbk4I0JQYgzVhVL2TE7/hGBj5eEieemDs6c2+Igl8qw5NJtQlRDgiwFau27myOON1MniKuH14TUNd8kXAP0g2YjPAq4AR7bOJeH2iat+vaf6PodbSklBJhmIjw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768033557; c=relaxed/simple; bh=+WCxHkobeBiamCzOgNQN1b1ukkZevHJDtSyFuYSqpzE=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=ZenD7VP+QkNQxJRjp8Xkq0aPLnc2mYe4wv5Y1rduXCE7ilVXzB3TYwpasrhCEUGk70wDssmyAQBR8rh3UconNEk6ZEE7gm2PULE/ylfpMkUZNYNCpnKtI0THf+mNMFDOT4Gm5h4rRlQjFGgXbH69ZCCJv5IVHikxqu6dNOp3X2U= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--samitolvanen.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=SNaipUC5; arc=none smtp.client-ip=74.125.82.73 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--samitolvanen.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="SNaipUC5" Received: by mail-dl1-f73.google.com with SMTP id a92af1059eb24-1219f27037fso20891232c88.1 for ; Sat, 10 Jan 2026 00:25:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1768033555; x=1768638355; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=iWBBLHK2sr+uF7Yqahqe2lWrrVOJVg2mMFqkCxu3N3o=; b=SNaipUC55GiHgkC1YHM9Rh+nRa7JWnZvYS+k79rdbunryZU8U1Ap1OspaCWFYL2fRb /5IEFLT4D1jh7s0RdceTj+KrPU/czdgFVTgKcpipfk6m8CzXIj0W8fUwIDxsDuAZomjl BKmgpX/7c78+5YQJZ1/yRHutQZobYl6b8ZaQ1sLtf4+ZhkfhU047bKlwXDzk86xRIsVm WFaDCBvpHCGv7rQ5u6Kz53MaYoomQb3eW7dautFCc3wu5LkL8kcv/t/Wn5PdJrw0nePj Pagr87qAcioLbvc3ZaBadgkQsxLdmMKkEKubtv4rsc7WGjnHoQdBLaijpsOYwSb0OciS trVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768033555; x=1768638355; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=iWBBLHK2sr+uF7Yqahqe2lWrrVOJVg2mMFqkCxu3N3o=; b=R+mSqa5L3rjZG492dJiH4rA6cEOPmtNsPy2s1J7jltddLQtxba5GmkXWvqxSY2f+no Tu8Ox8S/pMN622hdAWgxjnojJAyajZdZcQmaLMPoVWSQweXO4FuiDhQSQx/yfnoaK4RR TlnxWYqm5m8s1eV3k3U0b/2QrDRg5bD4vuE7tRdC9qqHsYznkciLFtQqV7PqcArjKFKs 9Tl8HDjz12XefpCc0w+zvnBsPNsV14OJ5HtHJiDyFnfDdCay3Dl8LC+2uS+kbDWhDgQA ckiEZR9LPJcg4TBYsPuHjicLhmEK7hNgPmg6kf2MK76wcJqCvRB0vU/N0pAb6/w/998q GWSg== X-Forwarded-Encrypted: i=1; AJvYcCUEvHV28QV8IoHAQq5XjFgck4ojdVdqgb/5KqaQDcHJPRYnRWVx8sY5tQ/unZuNhf+Fl1m8WIxzG5TgJI0=@vger.kernel.org X-Gm-Message-State: AOJu0Yz+W1zQUIVcda15TimhZkp1u+VvdNXW8eyzLnrNvAZZ/rqTBHzx 05SjsB4O8gD4ySBpkxQ1EyXc/jxuSPHOmPdpLoZaElsTDBGchV9d2R3RaMqkaf9vtZwHTzdvVQW GeyY5Cw92yuUr94RinZKooAsj30Tkeg== X-Google-Smtp-Source: AGHT+IHxLIJv96PRs95CR1ojfDI8HdfrX1TZOcGlAqJf2BSMh2rHldiYFXn4BO9stMSyoMeJTnQ+6APQ3tlZrxv0GZg= X-Received: from dlbuy4.prod.google.com ([2002:a05:7022:1e04:b0:11f:3f33:f0a5]) (user=samitolvanen job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7022:fb09:b0:122:153:d161 with SMTP id a92af1059eb24-1220153da5emr7432434c88.17.1768033555440; Sat, 10 Jan 2026 00:25:55 -0800 (PST) Date: Sat, 10 Jan 2026 08:25:49 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-Developer-Key: i=samitolvanen@google.com; a=openpgp; fpr=35CCFB63B283D6D3AEB783944CB5F6848BBC56EE X-Developer-Signature: v=1; a=openpgp-sha256; l=2161; i=samitolvanen@google.com; h=from:subject; bh=+WCxHkobeBiamCzOgNQN1b1ukkZevHJDtSyFuYSqpzE=; b=owGbwMvMwCUWxa662nLh8irG02pJDJlJvLwTHZam71i8x/P7m0IpH+kVFtG6tncamdXv8U5fe r+9OcS8o5SFQYyLQVZMkaXl6+qtu787pb76XCQBM4eVCWQIAxenAExkgS8jw6/UNYqCixJVfn1d GfBQdj7T58bcx41aN74tnfWIv+aB9wqG/3Enpx2OCHm6+/hBEwsVj4a4K2ohDH9zWqw2bHm6Qvr yER4A X-Mailer: git-send-email 2.52.0.457.g6b5491de43-goog Message-ID: <20260110082548.113748-6-samitolvanen@google.com> Subject: [PATCH bpf-next v5 0/4] Use correct destructor kfunc types From: Sami Tolvanen To: bpf@vger.kernel.org Cc: Vadim Fedorenko , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Eduard Zingerman , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Jamal Hadi Salim , Cong Wang , Jiri Pirko , Viktor Malik , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Sami Tolvanen Content-Type: text/plain; charset="UTF-8" Hi folks, While running BPF self-tests with CONFIG_CFI (Control Flow Integrity) enabled, I ran into a couple of failures in bpf_obj_free_fields() caused by type mismatches between the btf_dtor_kfunc_t function pointer type and the registered destructor functions. It looks like we can't change the argument type for these functions to match btf_dtor_kfunc_t because the verifier doesn't like void pointer arguments for functions used in BPF programs, so this series fixes the issue by adding stubs with correct types to use as destructors for each instance of this I found in the kernel tree. The last patch changes btf_check_dtor_kfuncs() to enforce the function type when CFI is enabled, so we don't end up registering destructors that panic the kernel. Sami --- v5: - Rebased on bpf-next/master again. v4: https://lore.kernel.org/bpf/20251126221724.897221-6-samitolvanen@google.com/ - Rebased on bpf-next/master. - Renamed CONFIG_CFI_CLANG to CONFIG_CFI. - Picked up Acked/Tested-by tags. v3: https://lore.kernel.org/bpf/20250728202656.559071-6-samitolvanen@google.com/ - Renamed the functions and went back to __bpf_kfunc based on review feedback. v2: https://lore.kernel.org/bpf/20250725214401.1475224-6-samitolvanen@google.com/ - Annotated the stubs with CFI_NOSEAL to fix issues with IBT sealing on x86. - Changed __bpf_kfunc to explicit __used __retain. v1: https://lore.kernel.org/bpf/20250724223225.1481960-6-samitolvanen@google.com/ --- Sami Tolvanen (4): bpf: crypto: Use the correct destructor kfunc type bpf: net_sched: Use the correct destructor kfunc type selftests/bpf: Use the correct destructor kfunc type bpf, btf: Enforce destructor kfunc type with CFI kernel/bpf/btf.c | 7 +++++++ kernel/bpf/crypto.c | 8 +++++++- net/sched/bpf_qdisc.c | 8 +++++++- tools/testing/selftests/bpf/test_kmods/bpf_testmod.c | 8 +++++++- 4 files changed, 28 insertions(+), 3 deletions(-) base-commit: 5714ca8cba5ed736f3733663c446cbee63a10a64 -- 2.52.0.457.g6b5491de43-goog