@@ -107,10 +107,11 @@ struct notification {
107
107
/**
108
108
* struct seccomp_filter - container for seccomp BPF programs
109
109
*
110
- * @usage: reference count to manage the object lifetime.
111
- * get/put helpers should be used when accessing an instance
112
- * outside of a lifetime-guarded section. In general, this
113
- * is only needed for handling filters shared across tasks.
110
+ * @refs: Reference count to manage the object lifetime.
111
+ * A filter's reference count is incremented for each directly
112
+ * attached task, once for the dependent filter, and if
113
+ * requested for the user notifier. When @refs reaches zero,
114
+ * the filter can be freed.
114
115
* @log: true if all actions except for SECCOMP_RET_ALLOW should be logged
115
116
* @prev: points to a previously installed, or inherited, filter
116
117
* @prog: the BPF program to evaluate
@@ -125,10 +126,10 @@ struct notification {
125
126
* how namespaces work.
126
127
*
127
128
* seccomp_filter objects should never be modified after being attached
128
- * to a task_struct (other than @usage ).
129
+ * to a task_struct (other than @refs ).
129
130
*/
130
131
struct seccomp_filter {
131
- refcount_t usage ;
132
+ refcount_t refs ;
132
133
bool log ;
133
134
struct seccomp_filter * prev ;
134
135
struct bpf_prog * prog ;
@@ -464,7 +465,7 @@ static struct seccomp_filter *seccomp_prepare_filter(struct sock_fprog *fprog)
464
465
return ERR_PTR (ret );
465
466
}
466
467
467
- refcount_set (& sfilter -> usage , 1 );
468
+ refcount_set (& sfilter -> refs , 1 );
468
469
469
470
return sfilter ;
470
471
}
@@ -558,7 +559,7 @@ static long seccomp_attach_filter(unsigned int flags,
558
559
559
560
static void __get_seccomp_filter (struct seccomp_filter * filter )
560
561
{
561
- refcount_inc (& filter -> usage );
562
+ refcount_inc (& filter -> refs );
562
563
}
563
564
564
565
/* get_seccomp_filter - increments the reference count of the filter on @tsk */
@@ -581,7 +582,7 @@ static inline void seccomp_filter_free(struct seccomp_filter *filter)
581
582
static void __put_seccomp_filter (struct seccomp_filter * orig )
582
583
{
583
584
/* Clean up single-reference branches iteratively. */
584
- while (orig && refcount_dec_and_test (& orig -> usage )) {
585
+ while (orig && refcount_dec_and_test (& orig -> refs )) {
585
586
struct seccomp_filter * freeme = orig ;
586
587
orig = orig -> prev ;
587
588
seccomp_filter_free (freeme );
0 commit comments