Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:kernel\bpf\syscall.c Create Date:2022-07-28 12:54:37
Last Modify:2022-05-19 18:06:12 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:bpf_prog_get_info_by_fd

Proto:static int bpf_prog_get_info_by_fd(struct bpf_prog *prog, const union bpf_attr *attr, union bpf_attr __user *uattr)

Type:int

Parameter:

TypeParameterName
struct bpf_prog *prog
const union bpf_attr *attr
union bpf_attr __user *uattr
2479  __user * uinfo = u64_to_user_ptr(info)
2480  struct bpf_prog_info info = {}
2481  info_len = info_len
2483  __user * uinsns
2487  err = If we're handed a bigger struct than we know of, ensure all the unknown bits* are 0 - i.e. new user-space does not rely on any kernel feature extensions* we don't know about yet.* There is a ToCToU between this function call and the following
2488  If err Then Return err
2490  info_len = min_t - return minimum of two values, using the specified type*@type: data type to use*@x: first value*@y: second value(u32, size of info , info_len)
2492  If copy_from_user( & info, uinfo, info_len) Then Return -EFAULT
2495  type = Type of BPF program
2496  id = id
2497  ns since boottime = ns since boottime
2498  created_by_uid = m_kuid_munged - Create a uid from a kuid user-namespace pair.*@targ: The user namespace we want a uid in.*@kuid: The kernel internal uid to start with.* Map @kuid into the user-namespace specified by @targ and* return the resulting uid.
2500  gpl_compatible = Is filter GPL compatible?
2502  No 3D Now!(tag, tag, size of tag )
2503  No 3D Now!(name, name, size of name )
2505  ulen = nr_map_ids
2506  nr_map_ids = used_map_cnt
2507  ulen = min_t - return minimum of two values, using the specified type*@type: data type to use*@x: first value*@y: second value(u32, nr_map_ids, ulen)
2508  If ulen Then
2509  __user * user_map_ids = u64_to_user_ptr(map_ids)
2512  When i < ulen cycle If Write a simple value into user space(id, & user_map_ids[i]) Then
2515  Return -EFAULT
2518  err = set_info_rec_size( & info)
2519  If err Then Return err
2522  bpf_prog_get_stats(prog, & stats)
2523  run_time_ns = nsecs
2524  run_cnt = cnt
2526  If Not Check operation authority Then
2527  jited_prog_len = 0
2528  xlated_prog_len = 0
2529  nr_jited_ksyms = 0
2530  nr_jited_func_lens = 0
2531  nr_func_info = 0
2532  nr_line_info = 0
2533  nr_jited_line_info = 0
2534  Go to done
2537  ulen = xlated_prog_len
2538  xlated_prog_len = bpf_prog_insn_size(prog)
2539  If xlated_prog_len && ulen Then
2543  If Was blinded && Not bpf_dump_raw_ok() Then
2544  xlated_prog_insns = 0
2545  Go to done
2547  insns_sanitized = bpf_insn_prepare_dump(prog)
2548  If Not insns_sanitized Then Return -ENOMEM
2550  uinsns = u64_to_user_ptr(xlated_prog_insns)
2551  ulen = min_t - return minimum of two values, using the specified type*@type: data type to use*@x: first value*@y: second value(u32, xlated_prog_len, ulen)
2552  fault = copy_to_user(uinsns, insns_sanitized, ulen)
2553  kfree(insns_sanitized)
2554  If fault Then Return -EFAULT
2558  If bpf_prog_is_dev_bound( Auxiliary fields ) Then
2559  err = bpf_prog_offload_info_fill( & info, prog)
2560  If err Then Return err
2562  Go to done
2569  ulen = jited_prog_len
2570  If used by non-func prog as the number of func progs Then
2573  jited_prog_len = 0
2574  When i < used by non-func prog as the number of func progs cycle jited_prog_len += Size of jited insns in bytes
2576  Else
2577  jited_prog_len = Size of jited insns in bytes
2580  If jited_prog_len && ulen Then
2581  If bpf_dump_raw_ok() Then
2604  Else
2605  If copy_to_user(uinsns, bpf_func, ulen) Then Return -EFAULT
2608  Else
2609  jited_prog_insns = 0
2613  ulen = nr_jited_ksyms
2614  nr_jited_ksyms = If used by non-func prog as the number of func progs Else 1
2615  If ulen Then
2616  If bpf_dump_raw_ok() Then
2618  __user * user_ksyms
2627  When i < ulen cycle
2634  Else
2639  Else
2640  jited_ksyms = 0
2644  ulen = nr_jited_func_lens
2645  nr_jited_func_lens = If used by non-func prog as the number of func progs Else 1
2646  If ulen Then
2647  If bpf_dump_raw_ok() Then
2648  __user * user_lens
2661  Else
2666  Else
2667  jited_func_lens = 0
2671  If btf Then btf_id = btf_id(btf)
2674  ulen = nr_func_info
2675  nr_func_info = func_info_cnt
2676  If nr_func_info && ulen Then
2677  __user * user_finfo
2679  user_finfo = u64_to_user_ptr(func_info)
2680  ulen = min_t - return minimum of two values, using the specified type*@type: data type to use*@x: first value*@y: second value(u32, nr_func_info, ulen)
2681  If copy_to_user(user_finfo, func_info, func_info_rec_size * ulen) Then Return -EFAULT
2686  ulen = nr_line_info
2687  nr_line_info = nr_linfo
2688  If nr_line_info && ulen Then
2689  __user * user_linfo
2691  user_linfo = u64_to_user_ptr(line_info)
2692  ulen = min_t - return minimum of two values, using the specified type*@type: data type to use*@x: first value*@y: second value(u32, nr_line_info, ulen)
2693  If copy_to_user(user_linfo, bpf_line_info loaded from userspace. linfo->insn_off * has the xlated insn offset. * Both the main and sub prog share the same linfo. * The subprog can access its first linfo by * using the linfo_idx., line_info_rec_size * ulen) Then Return -EFAULT
2698  ulen = nr_jited_line_info
2699  If jited_linfo is the jited addr of the linfo. It has a * one to one mapping to linfo: * jited_linfo[i] is the jited addr for the linfo[i]->insn_off. * Both the main and sub prog share the same jited_linfo. * The subprog can access its first jited_linfo by * Then nr_jited_line_info = nr_linfo
2701  Else nr_jited_line_info = 0
2703  If nr_jited_line_info && ulen Then
2704  If bpf_dump_raw_ok() Then
2705  __user * user_linfo
2710  When i < ulen cycle
2715  Else
2716  jited_line_info = 0
2720  ulen = nr_prog_tags
2721  nr_prog_tags = If used by non-func prog as the number of func progs Else 1
2722  If ulen Then
2723  __u8 __user( * user_prog_tags)[8]
2726  user_prog_tags = u64_to_user_ptr(prog_tags)
2727  ulen = min_t - return minimum of two values, using the specified type*@type: data type to use*@x: first value*@y: second value(u32, nr_prog_tags, ulen)
2729  When i < ulen cycle
2730  If copy_to_user(user_prog_tags[i], tag, BPF_TAG_SIZE) Then Return -EFAULT
2735  Else
2736  If copy_to_user(user_prog_tags[0], tag, BPF_TAG_SIZE) Then Return -EFAULT
2742  done :
2743  If copy_to_user(uinfo, & info, info_len) || Write a simple value into user space(info_len, & info_len) Then Return -EFAULT
2747  Return 0
Caller
NameDescribe
bpf_obj_get_info_by_fd