@@ -3139,7 +3139,8 @@ static const struct bpf_map *bpf_map_from_imm(const struct bpf_prog *prog,
3139
3139
return NULL ;
3140
3140
}
3141
3141
3142
- static struct bpf_insn * bpf_insn_prepare_dump (const struct bpf_prog * prog )
3142
+ static struct bpf_insn * bpf_insn_prepare_dump (const struct bpf_prog * prog ,
3143
+ const struct cred * f_cred )
3143
3144
{
3144
3145
const struct bpf_map * map ;
3145
3146
struct bpf_insn * insns ;
@@ -3165,7 +3166,7 @@ static struct bpf_insn *bpf_insn_prepare_dump(const struct bpf_prog *prog)
3165
3166
code == (BPF_JMP | BPF_CALL_ARGS )) {
3166
3167
if (code == (BPF_JMP | BPF_CALL_ARGS ))
3167
3168
insns [i ].code = BPF_JMP | BPF_CALL ;
3168
- if (!bpf_dump_raw_ok ())
3169
+ if (!bpf_dump_raw_ok (f_cred ))
3169
3170
insns [i ].imm = 0 ;
3170
3171
continue ;
3171
3172
}
@@ -3221,7 +3222,8 @@ static int set_info_rec_size(struct bpf_prog_info *info)
3221
3222
return 0 ;
3222
3223
}
3223
3224
3224
- static int bpf_prog_get_info_by_fd (struct bpf_prog * prog ,
3225
+ static int bpf_prog_get_info_by_fd (struct file * file ,
3226
+ struct bpf_prog * prog ,
3225
3227
const union bpf_attr * attr ,
3226
3228
union bpf_attr __user * uattr )
3227
3229
{
@@ -3290,11 +3292,11 @@ static int bpf_prog_get_info_by_fd(struct bpf_prog *prog,
3290
3292
struct bpf_insn * insns_sanitized ;
3291
3293
bool fault ;
3292
3294
3293
- if (prog -> blinded && !bpf_dump_raw_ok ()) {
3295
+ if (prog -> blinded && !bpf_dump_raw_ok (file -> f_cred )) {
3294
3296
info .xlated_prog_insns = 0 ;
3295
3297
goto done ;
3296
3298
}
3297
- insns_sanitized = bpf_insn_prepare_dump (prog );
3299
+ insns_sanitized = bpf_insn_prepare_dump (prog , file -> f_cred );
3298
3300
if (!insns_sanitized )
3299
3301
return - ENOMEM ;
3300
3302
uinsns = u64_to_user_ptr (info .xlated_prog_insns );
@@ -3328,7 +3330,7 @@ static int bpf_prog_get_info_by_fd(struct bpf_prog *prog,
3328
3330
}
3329
3331
3330
3332
if (info .jited_prog_len && ulen ) {
3331
- if (bpf_dump_raw_ok ()) {
3333
+ if (bpf_dump_raw_ok (file -> f_cred )) {
3332
3334
uinsns = u64_to_user_ptr (info .jited_prog_insns );
3333
3335
ulen = min_t (u32 , info .jited_prog_len , ulen );
3334
3336
@@ -3363,7 +3365,7 @@ static int bpf_prog_get_info_by_fd(struct bpf_prog *prog,
3363
3365
ulen = info .nr_jited_ksyms ;
3364
3366
info .nr_jited_ksyms = prog -> aux -> func_cnt ? : 1 ;
3365
3367
if (ulen ) {
3366
- if (bpf_dump_raw_ok ()) {
3368
+ if (bpf_dump_raw_ok (file -> f_cred )) {
3367
3369
unsigned long ksym_addr ;
3368
3370
u64 __user * user_ksyms ;
3369
3371
u32 i ;
@@ -3394,7 +3396,7 @@ static int bpf_prog_get_info_by_fd(struct bpf_prog *prog,
3394
3396
ulen = info .nr_jited_func_lens ;
3395
3397
info .nr_jited_func_lens = prog -> aux -> func_cnt ? : 1 ;
3396
3398
if (ulen ) {
3397
- if (bpf_dump_raw_ok ()) {
3399
+ if (bpf_dump_raw_ok (file -> f_cred )) {
3398
3400
u32 __user * user_lens ;
3399
3401
u32 func_len , i ;
3400
3402
@@ -3451,7 +3453,7 @@ static int bpf_prog_get_info_by_fd(struct bpf_prog *prog,
3451
3453
else
3452
3454
info .nr_jited_line_info = 0 ;
3453
3455
if (info .nr_jited_line_info && ulen ) {
3454
- if (bpf_dump_raw_ok ()) {
3456
+ if (bpf_dump_raw_ok (file -> f_cred )) {
3455
3457
__u64 __user * user_linfo ;
3456
3458
u32 i ;
3457
3459
@@ -3497,7 +3499,8 @@ static int bpf_prog_get_info_by_fd(struct bpf_prog *prog,
3497
3499
return 0 ;
3498
3500
}
3499
3501
3500
- static int bpf_map_get_info_by_fd (struct bpf_map * map ,
3502
+ static int bpf_map_get_info_by_fd (struct file * file ,
3503
+ struct bpf_map * map ,
3501
3504
const union bpf_attr * attr ,
3502
3505
union bpf_attr __user * uattr )
3503
3506
{
@@ -3540,7 +3543,8 @@ static int bpf_map_get_info_by_fd(struct bpf_map *map,
3540
3543
return 0 ;
3541
3544
}
3542
3545
3543
- static int bpf_btf_get_info_by_fd (struct btf * btf ,
3546
+ static int bpf_btf_get_info_by_fd (struct file * file ,
3547
+ struct btf * btf ,
3544
3548
const union bpf_attr * attr ,
3545
3549
union bpf_attr __user * uattr )
3546
3550
{
@@ -3555,7 +3559,8 @@ static int bpf_btf_get_info_by_fd(struct btf *btf,
3555
3559
return btf_get_info_by_fd (btf , attr , uattr );
3556
3560
}
3557
3561
3558
- static int bpf_link_get_info_by_fd (struct bpf_link * link ,
3562
+ static int bpf_link_get_info_by_fd (struct file * file ,
3563
+ struct bpf_link * link ,
3559
3564
const union bpf_attr * attr ,
3560
3565
union bpf_attr __user * uattr )
3561
3566
{
@@ -3608,15 +3613,15 @@ static int bpf_obj_get_info_by_fd(const union bpf_attr *attr,
3608
3613
return - EBADFD ;
3609
3614
3610
3615
if (f .file -> f_op == & bpf_prog_fops )
3611
- err = bpf_prog_get_info_by_fd (f .file -> private_data , attr ,
3616
+ err = bpf_prog_get_info_by_fd (f .file , f . file -> private_data , attr ,
3612
3617
uattr );
3613
3618
else if (f .file -> f_op == & bpf_map_fops )
3614
- err = bpf_map_get_info_by_fd (f .file -> private_data , attr ,
3619
+ err = bpf_map_get_info_by_fd (f .file , f . file -> private_data , attr ,
3615
3620
uattr );
3616
3621
else if (f .file -> f_op == & btf_fops )
3617
- err = bpf_btf_get_info_by_fd (f .file -> private_data , attr , uattr );
3622
+ err = bpf_btf_get_info_by_fd (f .file , f . file -> private_data , attr , uattr );
3618
3623
else if (f .file -> f_op == & bpf_link_fops )
3619
- err = bpf_link_get_info_by_fd (f .file -> private_data ,
3624
+ err = bpf_link_get_info_by_fd (f .file , f . file -> private_data ,
3620
3625
attr , uattr );
3621
3626
else
3622
3627
err = - EINVAL ;
0 commit comments