From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pg1-f202.google.com (mail-pg1-f202.google.com [209.85.215.202]) (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 5783C1096F for ; Wed, 26 Nov 2025 22:17:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764195452; cv=none; b=VacHbL3ezwfLeqOgWdeOn9sjp+jCJHpnBDXA0B9qsV5Gn+pC5vnmC1Z6CeDXZ8SLCEdIkImzOHQPteBUmxQAjj1k3jGNw6qNSaLFiIJ7N5NNz4K3pBnyPpuOnll8eUVITd8QcVOZjSz3adgNlzHB4s7dn5oAbnDomXtA6Ju/oJY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764195452; c=relaxed/simple; bh=wnENT/i7AHCCTI97AeWVd6C/3Pz88vsc9+JP3PT4DCs=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=YqZ/05iON9eAL6KW/LAOCwALBXkwL33tRcYINkePKHYzXrvWAir/xq9OC6nIlbjO62HQkTRFxhjMwqiLxu5vaqyZSNXPYW2yuClcbBhui6ddBJpWVd67+CYxj2WFhuw+FbzmCpz63gISJlrPg9jz95eqAGpDXGVQ/korq/oeATg= 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=l1fg38/X; arc=none smtp.client-ip=209.85.215.202 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="l1fg38/X" Received: by mail-pg1-f202.google.com with SMTP id 41be03b00d2f7-b993eb2701bso235914a12.0 for ; Wed, 26 Nov 2025 14:17:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1764195451; x=1764800251; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=WaZfnN+3wROne/L3H9J3JAKUYfm5GqcyYNg/Uc9QV2Y=; b=l1fg38/XUV3exMf7iOZBGmo1qEC/qw4BoMYdDIVNV6H5h1q6MgN91pt/Q1HfBiJ1wU OTAAeVIfCeisN7MkHiyL2cR9q4S0HBYrC3pNvj46pW0AMfQSyAzcDPU5dArofAXUL4vH SVMsuCD+FUu/0XqbU9STY4I8E+6R5Leu0Tul9Iwm1Wfdsl5BZueKSeqS/6DVpDa+flub aIHadA9gB0nXxnuRKg/M8iS/RPyDB/l8xHqpWkiBYuR96Bf73xDPp8UMs1qnRd1v9dhG iFUaxUampTDVba7pJ0+3ceW9tiEa/5Tde3ImhrzA1aFTWYrrjc5sZFXOokD5rpyT7VSe Z+7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764195451; x=1764800251; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=WaZfnN+3wROne/L3H9J3JAKUYfm5GqcyYNg/Uc9QV2Y=; b=CGiMJ6dUSut46dzoU3DzqSeVW5rwCyltDTezBZZjzZBrXPDYhl87B+LQmCzQN4eHE5 E2q+/BT8zld1361O5xLJ1+cRSm1aP0G64s5B2uLeWEiWxVN29ky57jB6HeqS40xxdXZu XGfwyuU4LfVZ883tCbrFHoq3kPDakg/Te1j5EczlZRlE4cbJl/CH3R+TF6yR4oAYEGH3 T40F2IFDOurUzn3lkUIYzDSWgsFlnRS/nVwezEOVQHAQal/RGo0loogiynfIxXhhP/fy TJXWJLeGszdEdmU2kRFm/Z/P9oTyD7O5LhrMFXYuiu8QHVxV+cBz71EX8mdsnOcwVnF8 wQxg== X-Forwarded-Encrypted: i=1; AJvYcCX1nIz98fJjgIWWj7StdJpYJ7JzIiShX8XuYjlUNjpOX1r6MYoPqQxXtD7YjR1LVDrQx5LuxeaovS/WPW0=@vger.kernel.org X-Gm-Message-State: AOJu0YxLG64hOjhUh+rUg49uEv4OGg64BFraACy5EapYGeG487s/1WAl bwTPWG0mjypIi3DIS3iW0gFKIVeJj3UHE4g/v2wQsfYjFNFD1/J4OqB1HX1PtB4LIWaW1mqHHAu 0R2FxMrdYIAT5aTTSXR2IeQJy1Yg04A== X-Google-Smtp-Source: AGHT+IH8iX/fB3tgapZ25MpvrcT6Xf459YdbUTDtyain+2dc0liftOqtbSsWJS0Cg/PasnsVJfCnfiLsLzzVsTaNzQQ= X-Received: from dybrq3.prod.google.com ([2002:a05:7301:4683:b0:2a4:480f:9430]) (user=samitolvanen job=prod-delivery.src-stubby-dispatcher) by 2002:a05:7301:7c0e:b0:2a7:1232:f3a2 with SMTP id 5a478bee46e88-2a9413b5447mr4530275eec.0.1764195450517; Wed, 26 Nov 2025 14:17:30 -0800 (PST) Date: Wed, 26 Nov 2025 22:17:25 +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=2040; i=samitolvanen@google.com; h=from:subject; bh=wnENT/i7AHCCTI97AeWVd6C/3Pz88vsc9+JP3PT4DCs=; b=owGbwMvMwCUWxa662nLh8irG02pJDJnqNSX/zC4dLE4Vfvbr3ArvhX87zx69YZBZvSJtR+qUH eEzrvxX6ChlYRDjYpAVU2Rp+bp66+7vTqmvPhdJwMxhZQIZwsDFKQATOeDL8M/E3D/Q8fdHJ4Mz 8xbM3WlpfV37TcW1BUvNHsTfqm73VlZh+B+WXLxBp79abFdL7+u62j9XL7pdiJmo/oLZqcK4uWy DKT8A X-Mailer: git-send-email 2.52.0.487.g5c8c507ade-goog Message-ID: <20251126221724.897221-6-samitolvanen@google.com> Subject: [PATCH bpf-next v4 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 --- v4: - 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: 688b745401ab16e2e1a3b504863f0a45fd345638 -- 2.52.0.487.g5c8c507ade-goog