Skip to content

Conversation

mykyta5
Copy link
Contributor

@mykyta5 mykyta5 commented Sep 25, 2025

No description provided.

Remove unnecessary kfunc prototypes from test programs, these are
provided by vmlinux.h

Signed-off-by: Mykyta Yatsenko <[email protected]>
@kernel-patches-daemon-bpf kernel-patches-daemon-bpf bot force-pushed the bpf-next_base branch 13 times, most recently from c199778 to b0c73f0 Compare September 28, 2025 11:38
@mykyta5 mykyta5 force-pushed the bpf_file_read branch 3 times, most recently from b670a79 to 3f42686 Compare September 29, 2025 19:47
Dynptr currently caps size and offset at 24 bits, which isn’t sufficient
for file-backed use cases; even 32 bits can be limiting. Refactor dynptr
helpers/kfuncs to use 64-bit size and offset, ensuring consistency
across the APIs.

This change does not affect internals of xdp, skb or other dynptrs,
which continue to behave as before.

The widening enables large-file access support via dynptr, implemented
in the next patches.

Signed-off-by: Mykyta Yatsenko <[email protected]>
Move the freader implementation from buildid.{c,h} into a dedicated
compilation unit, freader.{c,h}.

This allows reuse of freader outside buildid, e.g. for file dynptr
support added later. Includes are updated and symbols are exported as
needed. No functional change intended.

Signed-off-by: Mykyta Yatsenko <[email protected]>
freader_fetch currently reads from at most two folios. When a read spans
into a third folio, the overflow bytes are copied adjacent to the second
folio’s data instead of being handled as a separate folio.
This patch modifies fetch algorithm to support reading from many folios.

Signed-off-by: Mykyta Yatsenko <[email protected]>
@mykyta5 mykyta5 force-pushed the bpf_file_read branch 10 times, most recently from 52b727d to e8d850d Compare September 30, 2025 16:31
@mykyta5 mykyta5 force-pushed the bpf_file_read branch 6 times, most recently from 84de2bc to 4d9fa16 Compare October 1, 2025 13:39
@mykyta5 mykyta5 force-pushed the bpf_file_read branch 6 times, most recently from eb03455 to 10f4420 Compare October 2, 2025 21:26
@mykyta5 mykyta5 force-pushed the bpf_file_read branch 4 times, most recently from 49bea87 to 460b4ed Compare October 3, 2025 14:44
…nptr()

Move the const dynptr check into unmark_stack_slots_dynptr() so callers
don’t have to duplicate it. This puts the validation next to the code
that manipulates dynptr stack slots and allows upcoming changes to reuse
it directly.

Signed-off-by: Mykyta Yatsenko <[email protected]>
Add the necessary verifier plumbing for the new file-backed dynptr type.
Introduce two kfuncs for its lifecycle management:
 * bpf_dynptr_from_file() for initialization
 * bpf_dynptr_file_discard() for destruction

Currently there is no mechanism for kfunc to release dynptr, this patch
add one:
 * Introduce is_dynptr_release_arg() to tell if given dynptr argument
 should be released
 * Set meta->release_regno and regs[regno].ref_obj_id to make release
 happen

Signed-off-by: Mykyta Yatsenko <[email protected]>
Add support for file dynptr.

Introduce struct bpf_dynptr_file_impl to hold internal state for file
dynptrs, with 64-bit size and offset support.

Introduce lifecycle management kfuncs:
  - bpf_dynptr_from_file() for initialization
  - bpf_dynptr_file_discard() for destruction

Extend existing helpers to support file dynptrs in:
  - bpf_dynptr_read()
  - bpf_dynptr_slice()

Signed-off-by: Mykyta Yatsenko <[email protected]>
Move kfunc specialization (function address substitution) to later stage
of verification to support a new use case, where we need to take into
consideration whether kfunc is called in sleepable context.

Minor refactoring in add_kfunc_call(), making sure that if function
fails, kfunc desc is not added to tab->descs (previously it could be
added or not, depending on what failed).

Signed-off-by: Mykyta Yatsenko <[email protected]>
File dynptr reads may sleep when the requested folios are not in
the page cache. To avoid sleeping in non-sleepable contexts while still
supporting valid sleepable use, given that dynptrs are non-sleepable by
default, enable sleeping only when bpf_dynptr_from_file() is invoked
from a sleepable context.

This change:
  * Introduces a sleepable constructor: bpf_dynptr_from_file_sleepable()
  * Detects whether the kfunc is called in a sleepable context and
  stores the result in bpf_insn_aux_data (kfunc_in_sleepable_ctx)
  * Rewrites bpf_dynptr_from_file() calls to the sleepable variant when
  kfunc_in_sleepable_ctx is set

Signed-off-by: Mykyta Yatsenko <[email protected]>
Introducing selftests for validating file-backed dynptr works as
expected.
 * validate implementation supports dynptr slice and read operations
 * validate destructors should be paired with initializers

Signed-off-by: Mykyta Yatsenko <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant