Re: [PATCH 1/2] device_cgroup: add lockdep asserts

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Quoting Tejun Heo (tj@xxxxxxxxxx):
> device_cgroup uses RCU safe ->exceptions list which is write-protected
> by devcgroup_mutex and has had some issues using locking correctly.
> Add lockdep asserts to utility functions so that future errors can be
> easily detected.
> 
> Signed-off-by: Tejun Heo <tj@xxxxxxxxxx>
> Cc: stable@xxxxxxxxxxxxxxx
> Cc: Aristeu Rozanski <aris@xxxxxxxxxx>
> Cc: Li Zefan <lizefan@xxxxxxxxxx>
> Cc: Serge E. Hallyn <serge.hallyn@xxxxxxxxxx>

Acked-by: Serge E. Hallyn <serge.hallyn@xxxxxxxxxx>

> ---
> If this looks good, I'll route it with Aristeu's earlier patch through
> cgroup/for-3.7-fixes.  Thanks.
> 
>  security/device_cgroup.c |   12 ++++++++++++
>  1 file changed, 12 insertions(+)
> 
> --- a/security/device_cgroup.c
> +++ b/security/device_cgroup.c
> @@ -82,6 +82,8 @@ static int dev_exceptions_copy(struct li
>  {
>  	struct dev_exception_item *ex, *tmp, *new;
>  
> +	lockdep_assert_held(&devcgroup_mutex);
> +
>  	list_for_each_entry(ex, orig, list) {
>  		new = kmemdup(ex, sizeof(*ex), GFP_KERNEL);
>  		if (!new)
> @@ -107,6 +109,8 @@ static int dev_exception_add(struct dev_
>  {
>  	struct dev_exception_item *excopy, *walk;
>  
> +	lockdep_assert_held(&devcgroup_mutex);
> +
>  	excopy = kmemdup(ex, sizeof(*ex), GFP_KERNEL);
>  	if (!excopy)
>  		return -ENOMEM;
> @@ -137,6 +141,8 @@ static void dev_exception_rm(struct dev_
>  {
>  	struct dev_exception_item *walk, *tmp;
>  
> +	lockdep_assert_held(&devcgroup_mutex);
> +
>  	list_for_each_entry_safe(walk, tmp, &dev_cgroup->exceptions, list) {
>  		if (walk->type != ex->type)
>  			continue;
> @@ -163,6 +169,8 @@ static void dev_exception_clean(struct d
>  {
>  	struct dev_exception_item *ex, *tmp;
>  
> +	lockdep_assert_held(&devcgroup_mutex);
> +
>  	list_for_each_entry_safe(ex, tmp, &dev_cgroup->exceptions, list) {
>  		list_del_rcu(&ex->list);
>  		kfree_rcu(ex, rcu);
> @@ -298,6 +306,10 @@ static int may_access(struct dev_cgroup
>  	struct dev_exception_item *ex;
>  	bool match = false;
>  
> +	rcu_lockdep_assert(rcu_read_lock_held() ||
> +			   lockdep_is_held(&devcgroup_mutex),
> +			   "device_cgroup::may_access() called without proper synchronization");
> +
>  	list_for_each_entry_rcu(ex, &dev_cgroup->exceptions, list) {
>  		if ((refex->type & DEV_BLOCK) && !(ex->type & DEV_BLOCK))
>  			continue;
_______________________________________________
Containers mailing list
Containers@xxxxxxxxxxxxxxxxxxxxxxxxxx
https://lists.linuxfoundation.org/mailman/listinfo/containers


[Index of Archives]     [Cgroups]     [Netdev]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux