diff mbox series

[bpf-next,v2,3/4] bpf/crib: Add struct file related CRIB kfuncs

Message ID AM6PR03MB584858690D5A02162502A02099542@AM6PR03MB5848.eurprd03.prod.outlook.com (mailing list archive)
State Superseded
Delegated to: BPF
Headers show
Series bpf/crib: Add open-coded style process file iterator and file related CRIB kfuncs | expand

Checks

Context Check Description
bpf/vmtest-bpf-next-PR success PR summary
bpf/vmtest-bpf-next-VM_Test-14 success Logs for s390x-gcc / test (test_progs_no_alu32, false, 360) / test_progs_no_alu32 on s390x with gcc
bpf/vmtest-bpf-next-VM_Test-20 success Logs for x86_64-gcc / test (test_maps, false, 360) / test_maps on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-21 success Logs for x86_64-gcc / test (test_progs, false, 360) / test_progs on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-22 success Logs for x86_64-gcc / test (test_progs_no_alu32, false, 360) / test_progs_no_alu32 on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-23 success Logs for x86_64-gcc / test (test_progs_no_alu32_parallel, true, 30) / test_progs_no_alu32_parallel on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-24 success Logs for x86_64-gcc / test (test_progs_parallel, true, 30) / test_progs_parallel on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-26 success Logs for x86_64-gcc / veristat / veristat on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-25 success Logs for x86_64-gcc / test (test_verifier, false, 360) / test_verifier on x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-29 success Logs for x86_64-llvm-17 / test (test_maps, false, 360) / test_maps on x86_64 with llvm-17
bpf/vmtest-bpf-next-VM_Test-30 success Logs for x86_64-llvm-17 / test (test_progs, false, 360) / test_progs on x86_64 with llvm-17
bpf/vmtest-bpf-next-VM_Test-32 success Logs for x86_64-llvm-17 / test (test_verifier, false, 360) / test_verifier on x86_64 with llvm-17
bpf/vmtest-bpf-next-VM_Test-36 success Logs for x86_64-llvm-18 / test (test_maps, false, 360) / test_maps on x86_64 with llvm-18
bpf/vmtest-bpf-next-VM_Test-40 success Logs for x86_64-llvm-18 / test (test_verifier, false, 360) / test_verifier on x86_64 with llvm-18
bpf/vmtest-bpf-next-VM_Test-31 success Logs for x86_64-llvm-17 / test (test_progs_no_alu32, false, 360) / test_progs_no_alu32 on x86_64 with llvm-17
bpf/vmtest-bpf-next-VM_Test-37 success Logs for x86_64-llvm-18 / test (test_progs, false, 360) / test_progs on x86_64 with llvm-18
bpf/vmtest-bpf-next-VM_Test-38 success Logs for x86_64-llvm-18 / test (test_progs_cpuv4, false, 360) / test_progs_cpuv4 on x86_64 with llvm-18
bpf/vmtest-bpf-next-VM_Test-39 success Logs for x86_64-llvm-18 / test (test_progs_no_alu32, false, 360) / test_progs_no_alu32 on x86_64 with llvm-18
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for bpf-next, async
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit fail Errors and warnings before: 7 this patch: 8
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 14 of 14 maintainers
netdev/build_clang fail Errors and warnings before: 5 this patch: 6
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn fail Errors and warnings before: 10 this patch: 13
netdev/checkpatch warning WARNING: line length of 81 exceeds 80 columns
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc fail Errors and warnings before: 5 this patch: 11
netdev/source_inline success Was 0 now: 0
bpf/vmtest-bpf-next-VM_Test-0 success Logs for Lint
bpf/vmtest-bpf-next-VM_Test-2 success Logs for Unittests
bpf/vmtest-bpf-next-VM_Test-3 success Logs for Validate matrix.py
bpf/vmtest-bpf-next-VM_Test-1 success Logs for ShellCheck
bpf/vmtest-bpf-next-VM_Test-5 success Logs for aarch64-gcc / build-release
bpf/vmtest-bpf-next-VM_Test-12 success Logs for s390x-gcc / build-release
bpf/vmtest-bpf-next-VM_Test-10 success Logs for aarch64-gcc / veristat
bpf/vmtest-bpf-next-VM_Test-4 success Logs for aarch64-gcc / build / build for aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-9 success Logs for aarch64-gcc / test (test_verifier, false, 360) / test_verifier on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-6 success Logs for aarch64-gcc / test (test_maps, false, 360) / test_maps on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-8 success Logs for aarch64-gcc / test (test_progs_no_alu32, false, 360) / test_progs_no_alu32 on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-7 success Logs for aarch64-gcc / test (test_progs, false, 360) / test_progs on aarch64 with gcc
bpf/vmtest-bpf-next-VM_Test-27 success Logs for x86_64-llvm-17 / build / build for x86_64 with llvm-17
bpf/vmtest-bpf-next-VM_Test-28 success Logs for x86_64-llvm-17 / build-release / build for x86_64 with llvm-17-O2
bpf/vmtest-bpf-next-VM_Test-34 success Logs for x86_64-llvm-18 / build / build for x86_64 with llvm-18
bpf/vmtest-bpf-next-VM_Test-33 success Logs for x86_64-llvm-17 / veristat
bpf/vmtest-bpf-next-VM_Test-35 success Logs for x86_64-llvm-18 / build-release / build for x86_64 with llvm-18-O2
bpf/vmtest-bpf-next-VM_Test-41 success Logs for x86_64-llvm-18 / veristat
bpf/vmtest-bpf-next-VM_Test-16 success Logs for s390x-gcc / veristat
bpf/vmtest-bpf-next-VM_Test-17 success Logs for set-matrix
bpf/vmtest-bpf-next-VM_Test-15 success Logs for s390x-gcc / test (test_verifier, false, 360) / test_verifier on s390x with gcc
bpf/vmtest-bpf-next-VM_Test-11 success Logs for s390x-gcc / build / build for s390x with gcc
bpf/vmtest-bpf-next-VM_Test-19 success Logs for x86_64-gcc / build-release
bpf/vmtest-bpf-next-VM_Test-18 success Logs for x86_64-gcc / build / build for x86_64 with gcc
bpf/vmtest-bpf-next-VM_Test-13 success Logs for s390x-gcc / test (test_progs, false, 360) / test_progs on s390x with gcc

Commit Message

Juntong Deng Oct. 30, 2024, 12:14 a.m. UTC
This patch adds struct file related CRIB kfuncs.

bpf_fget_task() is used to get a pointer to the struct file
corresponding to the task file descriptor. Note that this function
acquires a reference to struct file.

bpf_get_file_ops_type() is used to determine what exactly this file
is based on the file operations, such as socket, eventfd, timerfd,
pipe, etc, in order to perform different checkpoint/restore processing
for different file types. This function currently has only one return
value, FILE_OPS_UNKNOWN, but will increase with the file types that
CRIB supports for checkpoint/restore.

Signed-off-by: Juntong Deng <juntong.deng@outlook.com>
---
 kernel/bpf/crib/crib.c  |  4 ++++
 kernel/bpf/crib/files.c | 44 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 48 insertions(+)

Comments

Andrii Nakryiko Nov. 1, 2024, 7:08 p.m. UTC | #1
On Tue, Oct 29, 2024 at 5:17 PM Juntong Deng <juntong.deng@outlook.com> wrote:
>
> This patch adds struct file related CRIB kfuncs.
>
> bpf_fget_task() is used to get a pointer to the struct file
> corresponding to the task file descriptor. Note that this function
> acquires a reference to struct file.
>
> bpf_get_file_ops_type() is used to determine what exactly this file
> is based on the file operations, such as socket, eventfd, timerfd,
> pipe, etc, in order to perform different checkpoint/restore processing
> for different file types. This function currently has only one return
> value, FILE_OPS_UNKNOWN, but will increase with the file types that
> CRIB supports for checkpoint/restore.
>
> Signed-off-by: Juntong Deng <juntong.deng@outlook.com>
> ---
>  kernel/bpf/crib/crib.c  |  4 ++++
>  kernel/bpf/crib/files.c | 44 +++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 48 insertions(+)
>

Please CC Christian Brauner and fs mailing list
(linux-fsdevel@vger.kernel.org, both cc'ed) on changes like this (this
entire patch set)

> diff --git a/kernel/bpf/crib/crib.c b/kernel/bpf/crib/crib.c
> index e6536ee9a845..78ddd19d5693 100644
> --- a/kernel/bpf/crib/crib.c
> +++ b/kernel/bpf/crib/crib.c
> @@ -14,6 +14,10 @@ BTF_ID_FLAGS(func, bpf_iter_task_file_next, KF_ITER_NEXT | KF_RET_NULL)
>  BTF_ID_FLAGS(func, bpf_iter_task_file_get_fd)
>  BTF_ID_FLAGS(func, bpf_iter_task_file_destroy, KF_ITER_DESTROY)
>
> +BTF_ID_FLAGS(func, bpf_fget_task, KF_ACQUIRE | KF_TRUSTED_ARGS | KF_RET_NULL)
> +BTF_ID_FLAGS(func, bpf_get_file_ops_type, KF_TRUSTED_ARGS)
> +BTF_ID_FLAGS(func, bpf_put_file, KF_RELEASE)
> +
>  BTF_KFUNCS_END(bpf_crib_kfuncs)
>
>  static const struct btf_kfunc_id_set bpf_crib_kfunc_set = {
> diff --git a/kernel/bpf/crib/files.c b/kernel/bpf/crib/files.c
> index ececf150303f..8e0e29877359 100644
> --- a/kernel/bpf/crib/files.c
> +++ b/kernel/bpf/crib/files.c
> @@ -5,6 +5,14 @@
>  #include <linux/fdtable.h>
>  #include <linux/net.h>
>
> +/**
> + * This enum will grow with the file types that CRIB supports for
> + * checkpoint/restore.
> + */
> +enum {
> +       FILE_OPS_UNKNOWN = 0
> +};
> +
>  struct bpf_iter_task_file {
>         __u64 __opaque[3];
>  } __aligned(8);
> @@ -102,4 +110,40 @@ __bpf_kfunc void bpf_iter_task_file_destroy(struct bpf_iter_task_file *it)
>                 fput(kit->file);
>  }
>
> +/**
> + * bpf_fget_task() - Get a pointer to the struct file corresponding to
> + * the task file descriptor
> + *
> + * Note that this function acquires a reference to struct file.
> + *
> + * @task: the specified struct task_struct
> + * @fd: the file descriptor
> + *
> + * @returns the corresponding struct file pointer if found,
> + * otherwise returns NULL
> + */
> +__bpf_kfunc struct file *bpf_fget_task(struct task_struct *task, unsigned int fd)
> +{
> +       struct file *file;
> +
> +       file = fget_task(task, fd);
> +       return file;
> +}
> +
> +/**
> + * bpf_get_file_ops_type() - Determine what exactly this file is based on
> + * the file operations, such as socket, eventfd, timerfd, pipe, etc
> + *
> + * This function will grow with the file types that CRIB supports for
> + * checkpoint/restore.
> + *
> + * @file: a pointer to the struct file
> + *
> + * @returns the file operations type
> + */
> +__bpf_kfunc unsigned int bpf_get_file_ops_type(struct file *file)
> +{
> +       return FILE_OPS_UNKNOWN;
> +}
> +

this is not very supportable, users can do the same by accessing
file->f_op and comparing it to a set of known struct file_operations
references.

>  __bpf_kfunc_end_defs();
> --
> 2.39.5
>
Juntong Deng Nov. 1, 2024, 8:28 p.m. UTC | #2
On 2024/11/1 19:08, Andrii Nakryiko wrote:
> On Tue, Oct 29, 2024 at 5:17 PM Juntong Deng <juntong.deng@outlook.com> wrote:
>>
>> This patch adds struct file related CRIB kfuncs.
>>
>> bpf_fget_task() is used to get a pointer to the struct file
>> corresponding to the task file descriptor. Note that this function
>> acquires a reference to struct file.
>>
>> bpf_get_file_ops_type() is used to determine what exactly this file
>> is based on the file operations, such as socket, eventfd, timerfd,
>> pipe, etc, in order to perform different checkpoint/restore processing
>> for different file types. This function currently has only one return
>> value, FILE_OPS_UNKNOWN, but will increase with the file types that
>> CRIB supports for checkpoint/restore.
>>
>> Signed-off-by: Juntong Deng <juntong.deng@outlook.com>
>> ---
>>   kernel/bpf/crib/crib.c  |  4 ++++
>>   kernel/bpf/crib/files.c | 44 +++++++++++++++++++++++++++++++++++++++++
>>   2 files changed, 48 insertions(+)
>>
> 
> Please CC Christian Brauner and fs mailing list
> (linux-fsdevel@vger.kernel.org, both cc'ed) on changes like this (this
> entire patch set)
> 

Thanks for your reply!

I will CC Christian Brauner and fs mailing list in the next
patch series.

>> diff --git a/kernel/bpf/crib/crib.c b/kernel/bpf/crib/crib.c
>> index e6536ee9a845..78ddd19d5693 100644
>> --- a/kernel/bpf/crib/crib.c
>> +++ b/kernel/bpf/crib/crib.c
>> @@ -14,6 +14,10 @@ BTF_ID_FLAGS(func, bpf_iter_task_file_next, KF_ITER_NEXT | KF_RET_NULL)
>>   BTF_ID_FLAGS(func, bpf_iter_task_file_get_fd)
>>   BTF_ID_FLAGS(func, bpf_iter_task_file_destroy, KF_ITER_DESTROY)
>>
>> +BTF_ID_FLAGS(func, bpf_fget_task, KF_ACQUIRE | KF_TRUSTED_ARGS | KF_RET_NULL)
>> +BTF_ID_FLAGS(func, bpf_get_file_ops_type, KF_TRUSTED_ARGS)
>> +BTF_ID_FLAGS(func, bpf_put_file, KF_RELEASE)
>> +
>>   BTF_KFUNCS_END(bpf_crib_kfuncs)
>>
>>   static const struct btf_kfunc_id_set bpf_crib_kfunc_set = {
>> diff --git a/kernel/bpf/crib/files.c b/kernel/bpf/crib/files.c
>> index ececf150303f..8e0e29877359 100644
>> --- a/kernel/bpf/crib/files.c
>> +++ b/kernel/bpf/crib/files.c
>> @@ -5,6 +5,14 @@
>>   #include <linux/fdtable.h>
>>   #include <linux/net.h>
>>
>> +/**
>> + * This enum will grow with the file types that CRIB supports for
>> + * checkpoint/restore.
>> + */
>> +enum {
>> +       FILE_OPS_UNKNOWN = 0
>> +};
>> +
>>   struct bpf_iter_task_file {
>>          __u64 __opaque[3];
>>   } __aligned(8);
>> @@ -102,4 +110,40 @@ __bpf_kfunc void bpf_iter_task_file_destroy(struct bpf_iter_task_file *it)
>>                  fput(kit->file);
>>   }
>>
>> +/**
>> + * bpf_fget_task() - Get a pointer to the struct file corresponding to
>> + * the task file descriptor
>> + *
>> + * Note that this function acquires a reference to struct file.
>> + *
>> + * @task: the specified struct task_struct
>> + * @fd: the file descriptor
>> + *
>> + * @returns the corresponding struct file pointer if found,
>> + * otherwise returns NULL
>> + */
>> +__bpf_kfunc struct file *bpf_fget_task(struct task_struct *task, unsigned int fd)
>> +{
>> +       struct file *file;
>> +
>> +       file = fget_task(task, fd);
>> +       return file;
>> +}
>> +
>> +/**
>> + * bpf_get_file_ops_type() - Determine what exactly this file is based on
>> + * the file operations, such as socket, eventfd, timerfd, pipe, etc
>> + *
>> + * This function will grow with the file types that CRIB supports for
>> + * checkpoint/restore.
>> + *
>> + * @file: a pointer to the struct file
>> + *
>> + * @returns the file operations type
>> + */
>> +__bpf_kfunc unsigned int bpf_get_file_ops_type(struct file *file)
>> +{
>> +       return FILE_OPS_UNKNOWN;
>> +}
>> +
> 
> this is not very supportable, users can do the same by accessing
> file->f_op and comparing it to a set of known struct file_operations
> references.
> 

Yes, users can access file->f_op, but there seems to be no way for
users to get references to struct file_operations for the various file
types? For example, how does a user get a reference to socket_file_ops?

Also, currently the struct file_operations for most of the file types
are static, and I cannot even get a reference to them in
crib/files.c directly.

My future plan is to add functions like is_socket_file_ops to the
corresponding files (e.g. net/socket.c).

>>   __bpf_kfunc_end_defs();
>> --
>> 2.39.5
>>
Andrii Nakryiko Nov. 6, 2024, 7:56 p.m. UTC | #3
On Fri, Nov 1, 2024 at 1:28 PM Juntong Deng <juntong.deng@outlook.com> wrote:
>
> On 2024/11/1 19:08, Andrii Nakryiko wrote:
> > On Tue, Oct 29, 2024 at 5:17 PM Juntong Deng <juntong.deng@outlook.com> wrote:
> >>
> >> This patch adds struct file related CRIB kfuncs.
> >>
> >> bpf_fget_task() is used to get a pointer to the struct file
> >> corresponding to the task file descriptor. Note that this function
> >> acquires a reference to struct file.
> >>
> >> bpf_get_file_ops_type() is used to determine what exactly this file
> >> is based on the file operations, such as socket, eventfd, timerfd,
> >> pipe, etc, in order to perform different checkpoint/restore processing
> >> for different file types. This function currently has only one return
> >> value, FILE_OPS_UNKNOWN, but will increase with the file types that
> >> CRIB supports for checkpoint/restore.
> >>
> >> Signed-off-by: Juntong Deng <juntong.deng@outlook.com>
> >> ---
> >>   kernel/bpf/crib/crib.c  |  4 ++++
> >>   kernel/bpf/crib/files.c | 44 +++++++++++++++++++++++++++++++++++++++++
> >>   2 files changed, 48 insertions(+)
> >>
> >
> > Please CC Christian Brauner and fs mailing list
> > (linux-fsdevel@vger.kernel.org, both cc'ed) on changes like this (this
> > entire patch set)
> >
>
> Thanks for your reply!
>
> I will CC Christian Brauner and fs mailing list in the next
> patch series.
>
> >> diff --git a/kernel/bpf/crib/crib.c b/kernel/bpf/crib/crib.c
> >> index e6536ee9a845..78ddd19d5693 100644
> >> --- a/kernel/bpf/crib/crib.c
> >> +++ b/kernel/bpf/crib/crib.c
> >> @@ -14,6 +14,10 @@ BTF_ID_FLAGS(func, bpf_iter_task_file_next, KF_ITER_NEXT | KF_RET_NULL)
> >>   BTF_ID_FLAGS(func, bpf_iter_task_file_get_fd)
> >>   BTF_ID_FLAGS(func, bpf_iter_task_file_destroy, KF_ITER_DESTROY)
> >>
> >> +BTF_ID_FLAGS(func, bpf_fget_task, KF_ACQUIRE | KF_TRUSTED_ARGS | KF_RET_NULL)
> >> +BTF_ID_FLAGS(func, bpf_get_file_ops_type, KF_TRUSTED_ARGS)
> >> +BTF_ID_FLAGS(func, bpf_put_file, KF_RELEASE)
> >> +
> >>   BTF_KFUNCS_END(bpf_crib_kfuncs)
> >>
> >>   static const struct btf_kfunc_id_set bpf_crib_kfunc_set = {
> >> diff --git a/kernel/bpf/crib/files.c b/kernel/bpf/crib/files.c
> >> index ececf150303f..8e0e29877359 100644
> >> --- a/kernel/bpf/crib/files.c
> >> +++ b/kernel/bpf/crib/files.c
> >> @@ -5,6 +5,14 @@
> >>   #include <linux/fdtable.h>
> >>   #include <linux/net.h>
> >>
> >> +/**
> >> + * This enum will grow with the file types that CRIB supports for
> >> + * checkpoint/restore.
> >> + */
> >> +enum {
> >> +       FILE_OPS_UNKNOWN = 0
> >> +};
> >> +
> >>   struct bpf_iter_task_file {
> >>          __u64 __opaque[3];
> >>   } __aligned(8);
> >> @@ -102,4 +110,40 @@ __bpf_kfunc void bpf_iter_task_file_destroy(struct bpf_iter_task_file *it)
> >>                  fput(kit->file);
> >>   }
> >>
> >> +/**
> >> + * bpf_fget_task() - Get a pointer to the struct file corresponding to
> >> + * the task file descriptor
> >> + *
> >> + * Note that this function acquires a reference to struct file.
> >> + *
> >> + * @task: the specified struct task_struct
> >> + * @fd: the file descriptor
> >> + *
> >> + * @returns the corresponding struct file pointer if found,
> >> + * otherwise returns NULL
> >> + */
> >> +__bpf_kfunc struct file *bpf_fget_task(struct task_struct *task, unsigned int fd)
> >> +{
> >> +       struct file *file;
> >> +
> >> +       file = fget_task(task, fd);
> >> +       return file;
> >> +}
> >> +
> >> +/**
> >> + * bpf_get_file_ops_type() - Determine what exactly this file is based on
> >> + * the file operations, such as socket, eventfd, timerfd, pipe, etc
> >> + *
> >> + * This function will grow with the file types that CRIB supports for
> >> + * checkpoint/restore.
> >> + *
> >> + * @file: a pointer to the struct file
> >> + *
> >> + * @returns the file operations type
> >> + */
> >> +__bpf_kfunc unsigned int bpf_get_file_ops_type(struct file *file)
> >> +{
> >> +       return FILE_OPS_UNKNOWN;
> >> +}
> >> +
> >
> > this is not very supportable, users can do the same by accessing
> > file->f_op and comparing it to a set of known struct file_operations
> > references.
> >
>
> Yes, users can access file->f_op, but there seems to be no way for
> users to get references to struct file_operations for the various file
> types? For example, how does a user get a reference to socket_file_ops?

See [0]. Libbpf will find it for the BPF program from kallsyms.

  [0] https://github.com/torvalds/linux/blob/master/tools/testing/selftests/bpf/progs/test_ksyms.c#L13-L18

>
> Also, currently the struct file_operations for most of the file types
> are static, and I cannot even get a reference to them in
> crib/files.c directly.
>
> My future plan is to add functions like is_socket_file_ops to the
> corresponding files (e.g. net/socket.c).
>
> >>   __bpf_kfunc_end_defs();
> >> --
> >> 2.39.5
> >>
>
diff mbox series

Patch

diff --git a/kernel/bpf/crib/crib.c b/kernel/bpf/crib/crib.c
index e6536ee9a845..78ddd19d5693 100644
--- a/kernel/bpf/crib/crib.c
+++ b/kernel/bpf/crib/crib.c
@@ -14,6 +14,10 @@  BTF_ID_FLAGS(func, bpf_iter_task_file_next, KF_ITER_NEXT | KF_RET_NULL)
 BTF_ID_FLAGS(func, bpf_iter_task_file_get_fd)
 BTF_ID_FLAGS(func, bpf_iter_task_file_destroy, KF_ITER_DESTROY)
 
+BTF_ID_FLAGS(func, bpf_fget_task, KF_ACQUIRE | KF_TRUSTED_ARGS | KF_RET_NULL)
+BTF_ID_FLAGS(func, bpf_get_file_ops_type, KF_TRUSTED_ARGS)
+BTF_ID_FLAGS(func, bpf_put_file, KF_RELEASE)
+
 BTF_KFUNCS_END(bpf_crib_kfuncs)
 
 static const struct btf_kfunc_id_set bpf_crib_kfunc_set = {
diff --git a/kernel/bpf/crib/files.c b/kernel/bpf/crib/files.c
index ececf150303f..8e0e29877359 100644
--- a/kernel/bpf/crib/files.c
+++ b/kernel/bpf/crib/files.c
@@ -5,6 +5,14 @@ 
 #include <linux/fdtable.h>
 #include <linux/net.h>
 
+/**
+ * This enum will grow with the file types that CRIB supports for
+ * checkpoint/restore.
+ */
+enum {
+	FILE_OPS_UNKNOWN = 0
+};
+
 struct bpf_iter_task_file {
 	__u64 __opaque[3];
 } __aligned(8);
@@ -102,4 +110,40 @@  __bpf_kfunc void bpf_iter_task_file_destroy(struct bpf_iter_task_file *it)
 		fput(kit->file);
 }
 
+/**
+ * bpf_fget_task() - Get a pointer to the struct file corresponding to
+ * the task file descriptor
+ *
+ * Note that this function acquires a reference to struct file.
+ *
+ * @task: the specified struct task_struct
+ * @fd: the file descriptor
+ *
+ * @returns the corresponding struct file pointer if found,
+ * otherwise returns NULL
+ */
+__bpf_kfunc struct file *bpf_fget_task(struct task_struct *task, unsigned int fd)
+{
+	struct file *file;
+
+	file = fget_task(task, fd);
+	return file;
+}
+
+/**
+ * bpf_get_file_ops_type() - Determine what exactly this file is based on
+ * the file operations, such as socket, eventfd, timerfd, pipe, etc
+ *
+ * This function will grow with the file types that CRIB supports for
+ * checkpoint/restore.
+ *
+ * @file: a pointer to the struct file
+ *
+ * @returns the file operations type
+ */
+__bpf_kfunc unsigned int bpf_get_file_ops_type(struct file *file)
+{
+	return FILE_OPS_UNKNOWN;
+}
+
 __bpf_kfunc_end_defs();