All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH bpf-next v6 0/4] Add cryptographic hash and signature verification kfuncs to BPF
@ 2026-01-24 17:43 Daniel Hodges
  2026-01-24 17:43 ` [PATCH bpf-next v6 1/4] bpf: Add hash kfunc for cryptographic hashing Daniel Hodges
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Daniel Hodges @ 2026-01-24 17:43 UTC (permalink / raw)
  To: bpf
  Cc: ast, andrii, daniel, vadim.fedorenko, song, yatsenko, martin.lau,
	eddyz87, haoluo, jolsa, john.fastabend, kpsingh, sdf,
	yonghong.song, herbert, davem, linux-crypto, linux-kernel,
	linux-kselftest, Daniel Hodges

This patch series enhances BPF's cryptographic functionality by introducing
kernel functions for SHA hashing and ECDSA signature verification. The changes
enable BPF programs to verify data integrity and authenticity across
networking, security, and observability use cases.

The series addresses two gaps in BPF's cryptographic toolkit:

1. Cryptographic hashing - supports content verification and message digest
   preparation
2. Asymmetric signature verification - allows validation of signed data
   without requiring private keys in the datapath

Use cases include:
- Verifying signed network packets or application data in XDP/TC programs
- Integrity checks within tracing and security monitoring
- Zero-trust security models with BPF-based credential verification
- Content-addressed storage in BPF-based filesystems

The implementation leverages existing BPF patterns: it uses bpf_dynptr for
memory safety, reuses kernel crypto libraries (lib/crypto/sha256.c and
crypto/ecdsa.c) rather than reimplementing algorithms, and provides
context-based APIs supporting multiple program types.

v1: https://lore.kernel.org/bpf/20251117211413.1394-1-git@danielhodges.dev/

v2: https://lore.kernel.org/bpf/20251205173923.31740-1-git@danielhodges.dev/
- Fixed redundant __bpf_dynptr_is_rdonly() checks (Vadim)
- Added BPF hash algorithm type registration module in crypto/ subsystem
- Added CONFIG_CRYPTO_HASH2 guards around bpf_crypto_hash() kfunc and its
  BTF registration, matching the pattern used for CONFIG_CRYPTO_ECDSA
- Added mandatory digestsize validation for hash operations

v3: https://lore.kernel.org/bpf/20251208030117.18892-1-git@danielhodges.dev/
- Fixed patch ordering - header changes now in separate first commit before
  crypto module to ensure bisectability (bot+bpf-ci)
- Fixed type mismatch - changed u32 to u64 for dynptr sizes in
  bpf_crypto_hash() to match __bpf_dynptr_size() return type (Mykyta)
- Added CONFIG_CRYPTO_ECDSA to selftest config (Song)
- Refactored test code duplication with setup_skel() helper (Song)
- Added copyright notices to all new files

v4: https://lore.kernel.org/bpf/20260105173755.22515-1-git@danielhodges.dev/
- Reused common bpf_crypto_ctx structure for hash and signature operations
  instead of separate context types (Song)
- Fixed integer truncation in bpf_crypto_hash when data_len > UINT_MAX
- Corrected KF_RCU flags for ECDSA kfuncs (only bpf_ecdsa_verify needs KF_RCU)
- Updated MAINTAINERS file in test patches
- Refactored selftests to use crypto_common.h for kfunc declarations

v5: https://lore.kernel.org/bpf/20260120184701.23082-1-git@danielhodges.dev/
- Fixed bisectability: moved bpf_crypto_type_id enum and type_id field
  introduction to the hash module commit, before it's used by hash kfunc
- Renamed kfuncs from bpf_ecdsa_* to bpf_sig_* since signature verification
  is not ECDSA-specific (Vadim)
- Added NULL checks in bpf_crypto_sig wrapper functions for optional
  digest_size and max_size callbacks to prevent NULL pointer dereference
- Added extra validation in bpf_sig_digestsize/bpf_sig_maxsize kfuncs to
  return -EOPNOTSUPP when underlying algorithm returns 0
- Renamed test files from ecdsa_verify to sig_verify for consistency

v6:
- Fixed bisectability issue flagged by CI: squash hash module and hash kfunc
  commits so NULL checks in bpf_crypto_ctx_create() are present before the
  hash type is registered (bot+bpf-ci)
- Squash signature module and signature kfunc commits for the same reason
- This reduces the series from 7 to 4 commits while preserving all functionality
- Added type_id checks to bpf_crypto_encrypt() and bpf_crypto_decrypt() to
  prevent NULL pointer dereference when called with non-skcipher contexts

Daniel Hodges (4):
  bpf: Add hash kfunc for cryptographic hashing
  selftests/bpf: Add tests for bpf_crypto_hash kfunc
  bpf: Add signature verification kfuncs
  selftests/bpf: Add tests for signature verification kfuncs

 MAINTAINERS                                   |   6 +
 crypto/Makefile                               |   6 +
 crypto/bpf_crypto_shash.c                     |  96 ++++++
 crypto/bpf_crypto_sig.c                       |  89 ++++++
 crypto/bpf_crypto_skcipher.c                  |   1 +
 include/linux/bpf_crypto.h                    |  13 +
 kernel/bpf/crypto.c                           | 210 ++++++++++++-
 tools/testing/selftests/bpf/config            |   2 +
 .../selftests/bpf/prog_tests/crypto_hash.c    | 210 +++++++++++++
 .../selftests/bpf/prog_tests/sig_verify.c     | 163 ++++++++++
 .../selftests/bpf/progs/crypto_common.h       |   8 +
 .../testing/selftests/bpf/progs/crypto_hash.c | 231 ++++++++++++++
 .../testing/selftests/bpf/progs/sig_verify.c  | 286 ++++++++++++++++++
 13 files changed, 1312 insertions(+), 9 deletions(-)
 create mode 100644 crypto/bpf_crypto_shash.c
 create mode 100644 crypto/bpf_crypto_sig.c
 create mode 100644 tools/testing/selftests/bpf/prog_tests/crypto_hash.c
 create mode 100644 tools/testing/selftests/bpf/prog_tests/sig_verify.c
 create mode 100644 tools/testing/selftests/bpf/progs/crypto_hash.c
 create mode 100644 tools/testing/selftests/bpf/progs/sig_verify.c

--
2.52.0


^ permalink raw reply	[flat|nested] 9+ messages in thread
* Re: [PATCH bpf-next v6 3/4] bpf: Add signature verification kfuncs
@ 2026-01-25  8:51 kernel test robot
  0 siblings, 0 replies; 9+ messages in thread
From: kernel test robot @ 2026-01-25  8:51 UTC (permalink / raw)
  To: oe-kbuild; +Cc: lkp

:::::: 
:::::: Manual check reason: "low confidence static check warning: crypto/bpf_crypto_sig.c:88:1: sparse: sparse: bad integer constant expression"
:::::: 

BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
In-Reply-To: <20260124174349.16861-4-git@danielhodges.dev>
References: <20260124174349.16861-4-git@danielhodges.dev>
TO: Daniel Hodges <git@danielhodges.dev>
TO: bpf@vger.kernel.org
CC: ast@kernel.org
CC: andrii@kernel.org
CC: daniel@iogearbox.net
CC: vadim.fedorenko@linux.dev
CC: song@kernel.org
CC: yatsenko@meta.com
CC: martin.lau@linux.dev
CC: eddyz87@gmail.com
CC: haoluo@google.com
CC: jolsa@kernel.org
CC: john.fastabend@gmail.com
CC: kpsingh@kernel.org
CC: sdf@fomichev.me
CC: yonghong.song@linux.dev
CC: herbert@gondor.apana.org.au
CC: davem@davemloft.net
CC: linux-crypto@vger.kernel.org
CC: linux-kernel@vger.kernel.org
CC: linux-kselftest@vger.kernel.org
CC: Daniel Hodges <git@danielhodges.dev>

Hi Daniel,

kernel test robot noticed the following build warnings:

[auto build test WARNING on bpf-next/master]

url:    https://github.com/intel-lab-lkp/linux/commits/Daniel-Hodges/bpf-Add-hash-kfunc-for-cryptographic-hashing/20260125-015004
base:   https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git master
patch link:    https://lore.kernel.org/r/20260124174349.16861-4-git%40danielhodges.dev
patch subject: [PATCH bpf-next v6 3/4] bpf: Add signature verification kfuncs
:::::: branch date: 15 hours ago
:::::: commit date: 15 hours ago
config: m68k-randconfig-r131-20260125 (https://download.01.org/0day-ci/archive/20260125/202601251601.ChPv1VSq-lkp@intel.com/config)
compiler: m68k-linux-gcc (GCC) 8.5.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260125/202601251601.ChPv1VSq-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/r/202601251601.ChPv1VSq-lkp@intel.com/

sparse warnings: (new ones prefixed by >>)
>> crypto/bpf_crypto_sig.c:88:1: sparse: sparse: bad integer constant expression
   crypto/bpf_crypto_sig.c:88:1: sparse: sparse: static assertion failed: "MODULE_INFO(file, ...) contains embedded NUL byte"
>> crypto/bpf_crypto_sig.c:88:1: sparse: sparse: bad integer constant expression
   crypto/bpf_crypto_sig.c:88:1: sparse: sparse: static assertion failed: "MODULE_INFO(license, ...) contains embedded NUL byte"
   crypto/bpf_crypto_sig.c:89:1: sparse: sparse: bad integer constant expression
   crypto/bpf_crypto_sig.c:89:1: sparse: sparse: static assertion failed: "MODULE_INFO(description, ...) contains embedded NUL byte"

vim +88 crypto/bpf_crypto_sig.c

0363f73e3051ae8 Daniel Hodges 2026-01-24  85  
0363f73e3051ae8 Daniel Hodges 2026-01-24  86  module_init(bpf_crypto_sig_init);
0363f73e3051ae8 Daniel Hodges 2026-01-24  87  module_exit(bpf_crypto_sig_exit);
0363f73e3051ae8 Daniel Hodges 2026-01-24 @88  MODULE_LICENSE("GPL");

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2026-01-25 12:35 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-24 17:43 [PATCH bpf-next v6 0/4] Add cryptographic hash and signature verification kfuncs to BPF Daniel Hodges
2026-01-24 17:43 ` [PATCH bpf-next v6 1/4] bpf: Add hash kfunc for cryptographic hashing Daniel Hodges
2026-01-24 18:03   ` bot+bpf-ci
2026-01-24 17:43 ` [PATCH bpf-next v6 2/4] selftests/bpf: Add tests for bpf_crypto_hash kfunc Daniel Hodges
2026-01-24 17:43 ` [PATCH bpf-next v6 3/4] bpf: Add signature verification kfuncs Daniel Hodges
2026-01-24 17:43 ` [PATCH bpf-next v6 4/4] selftests/bpf: Add tests for " Daniel Hodges
2026-01-25  0:19   ` Alexei Starovoitov
2026-01-25 12:34     ` Daniel Hodges
  -- strict thread matches above, loose matches on Subject: below --
2026-01-25  8:51 [PATCH bpf-next v6 3/4] bpf: Add " kernel test robot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.