@@ -430,10 +430,10 @@ static struct bpf_prog_list *find_attach_entry(struct list_head *progs,
430
430
* Exactly one of @prog or @link can be non-null.
431
431
* Must be called with cgroup_mutex held.
432
432
*/
433
- int __cgroup_bpf_attach (struct cgroup * cgrp ,
434
- struct bpf_prog * prog , struct bpf_prog * replace_prog ,
435
- struct bpf_cgroup_link * link ,
436
- enum bpf_attach_type type , u32 flags )
433
+ static int __cgroup_bpf_attach (struct cgroup * cgrp ,
434
+ struct bpf_prog * prog , struct bpf_prog * replace_prog ,
435
+ struct bpf_cgroup_link * link ,
436
+ enum bpf_attach_type type , u32 flags )
437
437
{
438
438
u32 saved_flags = (flags & (BPF_F_ALLOW_OVERRIDE | BPF_F_ALLOW_MULTI ));
439
439
struct bpf_prog * old_prog = NULL ;
@@ -523,6 +523,20 @@ int __cgroup_bpf_attach(struct cgroup *cgrp,
523
523
return err ;
524
524
}
525
525
526
+ static int cgroup_bpf_attach (struct cgroup * cgrp ,
527
+ struct bpf_prog * prog , struct bpf_prog * replace_prog ,
528
+ struct bpf_cgroup_link * link ,
529
+ enum bpf_attach_type type ,
530
+ u32 flags )
531
+ {
532
+ int ret ;
533
+
534
+ mutex_lock (& cgroup_mutex );
535
+ ret = __cgroup_bpf_attach (cgrp , prog , replace_prog , link , type , flags );
536
+ mutex_unlock (& cgroup_mutex );
537
+ return ret ;
538
+ }
539
+
526
540
/* Swap updated BPF program for given link in effective program arrays across
527
541
* all descendant cgroups. This function is guaranteed to succeed.
528
542
*/
@@ -672,14 +686,14 @@ static struct bpf_prog_list *find_detach_entry(struct list_head *progs,
672
686
* propagate the change to descendants
673
687
* @cgrp: The cgroup which descendants to traverse
674
688
* @prog: A program to detach or NULL
675
- * @prog : A link to detach or NULL
689
+ * @link : A link to detach or NULL
676
690
* @type: Type of detach operation
677
691
*
678
692
* At most one of @prog or @link can be non-NULL.
679
693
* Must be called with cgroup_mutex held.
680
694
*/
681
- int __cgroup_bpf_detach (struct cgroup * cgrp , struct bpf_prog * prog ,
682
- struct bpf_cgroup_link * link , enum bpf_attach_type type )
695
+ static int __cgroup_bpf_detach (struct cgroup * cgrp , struct bpf_prog * prog ,
696
+ struct bpf_cgroup_link * link , enum bpf_attach_type type )
683
697
{
684
698
enum cgroup_bpf_attach_type atype ;
685
699
struct bpf_prog * old_prog ;
@@ -730,9 +744,20 @@ int __cgroup_bpf_detach(struct cgroup *cgrp, struct bpf_prog *prog,
730
744
return err ;
731
745
}
732
746
747
+ static int cgroup_bpf_detach (struct cgroup * cgrp , struct bpf_prog * prog ,
748
+ enum bpf_attach_type type )
749
+ {
750
+ int ret ;
751
+
752
+ mutex_lock (& cgroup_mutex );
753
+ ret = __cgroup_bpf_detach (cgrp , prog , NULL , type );
754
+ mutex_unlock (& cgroup_mutex );
755
+ return ret ;
756
+ }
757
+
733
758
/* Must be called with cgroup_mutex held to avoid races. */
734
- int __cgroup_bpf_query (struct cgroup * cgrp , const union bpf_attr * attr ,
735
- union bpf_attr __user * uattr )
759
+ static int __cgroup_bpf_query (struct cgroup * cgrp , const union bpf_attr * attr ,
760
+ union bpf_attr __user * uattr )
736
761
{
737
762
__u32 __user * prog_ids = u64_to_user_ptr (attr -> query .prog_ids );
738
763
enum bpf_attach_type type = attr -> query .attach_type ;
@@ -789,6 +814,17 @@ int __cgroup_bpf_query(struct cgroup *cgrp, const union bpf_attr *attr,
789
814
return ret ;
790
815
}
791
816
817
+ static int cgroup_bpf_query (struct cgroup * cgrp , const union bpf_attr * attr ,
818
+ union bpf_attr __user * uattr )
819
+ {
820
+ int ret ;
821
+
822
+ mutex_lock (& cgroup_mutex );
823
+ ret = __cgroup_bpf_query (cgrp , attr , uattr );
824
+ mutex_unlock (& cgroup_mutex );
825
+ return ret ;
826
+ }
827
+
792
828
int cgroup_bpf_prog_attach (const union bpf_attr * attr ,
793
829
enum bpf_prog_type ptype , struct bpf_prog * prog )
794
830
{
0 commit comments