File tree Expand file tree Collapse file tree 1 file changed +20
-14
lines changed Expand file tree Collapse file tree 1 file changed +20
-14
lines changed Original file line number Diff line number Diff line change @@ -3295,6 +3295,25 @@ static void bpf_raw_tp_link_show_fdinfo(const struct bpf_link *link,
3295
3295
raw_tp_link -> btp -> tp -> name );
3296
3296
}
3297
3297
3298
+ static int bpf_copy_to_user (char __user * ubuf , const char * buf , u32 ulen ,
3299
+ u32 len )
3300
+ {
3301
+ if (ulen >= len + 1 ) {
3302
+ if (copy_to_user (ubuf , buf , len + 1 ))
3303
+ return - EFAULT ;
3304
+ } else {
3305
+ char zero = '\0' ;
3306
+
3307
+ if (copy_to_user (ubuf , buf , ulen - 1 ))
3308
+ return - EFAULT ;
3309
+ if (put_user (zero , ubuf + ulen - 1 ))
3310
+ return - EFAULT ;
3311
+ return - ENOSPC ;
3312
+ }
3313
+
3314
+ return 0 ;
3315
+ }
3316
+
3298
3317
static int bpf_raw_tp_link_fill_link_info (const struct bpf_link * link ,
3299
3318
struct bpf_link_info * info )
3300
3319
{
@@ -3313,20 +3332,7 @@ static int bpf_raw_tp_link_fill_link_info(const struct bpf_link *link,
3313
3332
if (!ubuf )
3314
3333
return 0 ;
3315
3334
3316
- if (ulen >= tp_len + 1 ) {
3317
- if (copy_to_user (ubuf , tp_name , tp_len + 1 ))
3318
- return - EFAULT ;
3319
- } else {
3320
- char zero = '\0' ;
3321
-
3322
- if (copy_to_user (ubuf , tp_name , ulen - 1 ))
3323
- return - EFAULT ;
3324
- if (put_user (zero , ubuf + ulen - 1 ))
3325
- return - EFAULT ;
3326
- return - ENOSPC ;
3327
- }
3328
-
3329
- return 0 ;
3335
+ return bpf_copy_to_user (ubuf , tp_name , ulen , tp_len );
3330
3336
}
3331
3337
3332
3338
static const struct bpf_link_ops bpf_raw_tp_link_lops = {
You can’t perform that action at this time.
0 commit comments