mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-12-27 10:01:39 -05:00
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. Also it does not break binary compatibility. The widening enables large-file access support via dynptr, implemented in the next patches. Signed-off-by: Mykyta Yatsenko <yatsenko@meta.com> Acked-by: Eduard Zingerman <eddyz87@gmail.com> Link: https://lore.kernel.org/r/20251026203853.135105-3-mykyta.yatsenko5@gmail.com Signed-off-by: Alexei Starovoitov <ast@kernel.org>
99 lines
3.5 KiB
C
99 lines
3.5 KiB
C
#ifndef __BPF_KFUNCS__
|
|
#define __BPF_KFUNCS__
|
|
|
|
struct bpf_sock_addr_kern;
|
|
|
|
/* Description
|
|
* Initializes an skb-type dynptr
|
|
* Returns
|
|
* Error code
|
|
*/
|
|
extern int bpf_dynptr_from_skb(struct __sk_buff *skb, __u64 flags,
|
|
struct bpf_dynptr *ptr__uninit) __ksym __weak;
|
|
|
|
/* Description
|
|
* Initializes an xdp-type dynptr
|
|
* Returns
|
|
* Error code
|
|
*/
|
|
extern int bpf_dynptr_from_xdp(struct xdp_md *xdp, __u64 flags,
|
|
struct bpf_dynptr *ptr__uninit) __ksym __weak;
|
|
|
|
extern int bpf_dynptr_from_skb_meta(struct __sk_buff *skb, __u64 flags,
|
|
struct bpf_dynptr *ptr__uninit) __ksym __weak;
|
|
|
|
/* Description
|
|
* Obtain a read-only pointer to the dynptr's data
|
|
* Returns
|
|
* Either a direct pointer to the dynptr data or a pointer to the user-provided
|
|
* buffer if unable to obtain a direct pointer
|
|
*/
|
|
extern void *bpf_dynptr_slice(const struct bpf_dynptr *ptr, __u64 offset,
|
|
void *buffer, __u64 buffer__szk) __ksym __weak;
|
|
|
|
/* Description
|
|
* Obtain a read-write pointer to the dynptr's data
|
|
* Returns
|
|
* Either a direct pointer to the dynptr data or a pointer to the user-provided
|
|
* buffer if unable to obtain a direct pointer
|
|
*/
|
|
extern void *bpf_dynptr_slice_rdwr(const struct bpf_dynptr *ptr, __u64 offset, void *buffer,
|
|
__u64 buffer__szk) __ksym __weak;
|
|
|
|
extern int bpf_dynptr_adjust(const struct bpf_dynptr *ptr, __u64 start, __u64 end) __ksym __weak;
|
|
extern bool bpf_dynptr_is_null(const struct bpf_dynptr *ptr) __ksym __weak;
|
|
extern bool bpf_dynptr_is_rdonly(const struct bpf_dynptr *ptr) __ksym __weak;
|
|
extern __u64 bpf_dynptr_size(const struct bpf_dynptr *ptr) __ksym __weak;
|
|
extern int bpf_dynptr_clone(const struct bpf_dynptr *ptr, struct bpf_dynptr *clone__init) __ksym __weak;
|
|
|
|
/* Description
|
|
* Modify the address of a AF_UNIX sockaddr.
|
|
* Returns
|
|
* -EINVAL if the address size is too big or, 0 if the sockaddr was successfully modified.
|
|
*/
|
|
extern int bpf_sock_addr_set_sun_path(struct bpf_sock_addr_kern *sa_kern,
|
|
const __u8 *sun_path, __u32 sun_path__sz) __ksym;
|
|
|
|
/* Description
|
|
* Allocate and configure a reqsk and link it with a listener and skb.
|
|
* Returns
|
|
* Error code
|
|
*/
|
|
struct sock;
|
|
struct bpf_tcp_req_attrs;
|
|
extern int bpf_sk_assign_tcp_reqsk(struct __sk_buff *skb, struct sock *sk,
|
|
struct bpf_tcp_req_attrs *attrs, int attrs__sz) __ksym;
|
|
|
|
void *bpf_cast_to_kern_ctx(void *) __ksym;
|
|
|
|
extern void *bpf_rdonly_cast(const void *obj, __u32 btf_id) __ksym __weak;
|
|
|
|
extern int bpf_get_file_xattr(struct file *file, const char *name,
|
|
struct bpf_dynptr *value_ptr) __ksym;
|
|
extern int bpf_get_fsverity_digest(struct file *file, struct bpf_dynptr *digest_ptr) __ksym;
|
|
|
|
extern struct bpf_key *bpf_lookup_user_key(__s32 serial, __u64 flags) __ksym;
|
|
extern struct bpf_key *bpf_lookup_system_key(__u64 id) __ksym;
|
|
extern void bpf_key_put(struct bpf_key *key) __ksym;
|
|
extern int bpf_verify_pkcs7_signature(struct bpf_dynptr *data_ptr,
|
|
struct bpf_dynptr *sig_ptr,
|
|
struct bpf_key *trusted_keyring) __ksym;
|
|
|
|
extern bool bpf_session_is_return(void) __ksym __weak;
|
|
extern __u64 *bpf_session_cookie(void) __ksym __weak;
|
|
|
|
struct dentry;
|
|
/* Description
|
|
* Returns xattr of a dentry
|
|
* Returns
|
|
* Error code
|
|
*/
|
|
extern int bpf_get_dentry_xattr(struct dentry *dentry, const char *name,
|
|
struct bpf_dynptr *value_ptr) __ksym __weak;
|
|
|
|
extern int bpf_set_dentry_xattr(struct dentry *dentry, const char *name__str,
|
|
const struct bpf_dynptr *value_p, int flags) __ksym __weak;
|
|
extern int bpf_remove_dentry_xattr(struct dentry *dentry, const char *name__str) __ksym __weak;
|
|
|
|
#endif
|