Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1189844 > unrolled thread

Re: [PATCH v2] cgroup: net_cls: fix false-positive "suspicious RCU usage"

Started byDaniel Borkmann <daniel@iogearbox.net>
First post2015-07-22 14:00 +0200
Last post2015-07-22 14:10 +0200
Articles 3 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: [PATCH v2] cgroup: net_cls: fix false-positive "suspicious RCU  usage" Daniel Borkmann <daniel@iogearbox.net> - 2015-07-22 14:00 +0200
    Re: [PATCH v2] cgroup: net_cls: fix false-positive "suspicious RCU  usage" Daniel Borkmann <daniel@iogearbox.net> - 2015-07-22 14:10 +0200
    Re: [PATCH v2] cgroup: net_cls: fix false-positive "suspicious RCU  usage" Konstantin Khlebnikov <khlebnikov@yandex-team.ru> - 2015-07-22 14:10 +0200

#1189844 — Re: [PATCH v2] cgroup: net_cls: fix false-positive "suspicious RCU usage"

FromDaniel Borkmann <daniel@iogearbox.net>
Date2015-07-22 14:00 +0200
SubjectRe: [PATCH v2] cgroup: net_cls: fix false-positive "suspicious RCU usage"
Message-ID<pP0QN-5Wa-3@gated-at.bofh.it>
On 07/22/2015 11:23 AM, Konstantin Khlebnikov wrote:
> In dev_queue_xmit() net_cls protected with rcu-bh.
...
> Signed-off-by: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
> ---
>   net/core/netclassid_cgroup.c |    3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/net/core/netclassid_cgroup.c b/net/core/netclassid_cgroup.c
> index 1f2a126f4ffa..6441f47b1a8f 100644
> --- a/net/core/netclassid_cgroup.c
> +++ b/net/core/netclassid_cgroup.c
> @@ -23,7 +23,8 @@ static inline struct cgroup_cls_state *css_cls_state(struct cgroup_subsys_state
>
>   struct cgroup_cls_state *task_cls_state(struct task_struct *p)
>   {
> -	return css_cls_state(task_css(p, net_cls_cgrp_id));
> +	return css_cls_state(task_css_check(p, net_cls_cgrp_id,
> +					    rcu_read_lock_bh_held()));

Did you also check that after your patch this doesn't trigger on ingress
either? There, this code path could be invoked under rcu_read_lock(). So,
perhaps you need to check for both.

>   }
>   EXPORT_SYMBOL_GPL(task_cls_state);
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1189847

FromDaniel Borkmann <daniel@iogearbox.net>
Date2015-07-22 14:10 +0200
Message-ID<pP10t-6mP-1@gated-at.bofh.it>
In reply to#1189844
On 07/22/2015 02:03 PM, Konstantin Khlebnikov wrote:
> On 22.07.2015 14:56, Daniel Borkmann wrote:
>> On 07/22/2015 11:23 AM, Konstantin Khlebnikov wrote:
>>> In dev_queue_xmit() net_cls protected with rcu-bh.
>> ...
>>> Signed-off-by: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
>>> ---
>>>   net/core/netclassid_cgroup.c |    3 ++-
>>>   1 file changed, 2 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/net/core/netclassid_cgroup.c b/net/core/netclassid_cgroup.c
>>> index 1f2a126f4ffa..6441f47b1a8f 100644
>>> --- a/net/core/netclassid_cgroup.c
>>> +++ b/net/core/netclassid_cgroup.c
>>> @@ -23,7 +23,8 @@ static inline struct cgroup_cls_state
>>> *css_cls_state(struct cgroup_subsys_state
>>>
>>>   struct cgroup_cls_state *task_cls_state(struct task_struct *p)
>>>   {
>>> -    return css_cls_state(task_css(p, net_cls_cgrp_id));
>>> +    return css_cls_state(task_css_check(p, net_cls_cgrp_id,
>>> +                        rcu_read_lock_bh_held()));
>>
>> Did you also check that after your patch this doesn't trigger on ingress
>> either? There, this code path could be invoked under rcu_read_lock(). So,
>> perhaps you need to check for both.
>
> I haven't seen warnings with this patch. rcu_read_lock_held() is
> checked inside rcu_dereference_check() inside task_css_check().

Thanks, agreed.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1189848

FromKonstantin Khlebnikov <khlebnikov@yandex-team.ru>
Date2015-07-22 14:10 +0200
Message-ID<pP10t-6mP-3@gated-at.bofh.it>
In reply to#1189844
On 22.07.2015 14:56, Daniel Borkmann wrote:
> On 07/22/2015 11:23 AM, Konstantin Khlebnikov wrote:
>> In dev_queue_xmit() net_cls protected with rcu-bh.
> ...
>> Signed-off-by: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
>> ---
>>   net/core/netclassid_cgroup.c |    3 ++-
>>   1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/net/core/netclassid_cgroup.c b/net/core/netclassid_cgroup.c
>> index 1f2a126f4ffa..6441f47b1a8f 100644
>> --- a/net/core/netclassid_cgroup.c
>> +++ b/net/core/netclassid_cgroup.c
>> @@ -23,7 +23,8 @@ static inline struct cgroup_cls_state
>> *css_cls_state(struct cgroup_subsys_state
>>
>>   struct cgroup_cls_state *task_cls_state(struct task_struct *p)
>>   {
>> -    return css_cls_state(task_css(p, net_cls_cgrp_id));
>> +    return css_cls_state(task_css_check(p, net_cls_cgrp_id,
>> +                        rcu_read_lock_bh_held()));
>
> Did you also check that after your patch this doesn't trigger on ingress
> either? There, this code path could be invoked under rcu_read_lock(). So,
> perhaps you need to check for both.

I haven't seen warnings with this patch. rcu_read_lock_held() is
checked inside rcu_dereference_check() inside task_css_check().

So, overall check expression is:

lockdep_is_held(&cgroup_mutex) ||  <- in task_css_set_check
lockdep_is_held(&css_set_rwsem) ||
((task)->flags & PF_EXITING) ||
rcu_read_lock_bh_held() || <- mine
rcu_read_lock_held() <- in rcu_dereference_check

>
>>   }
>>   EXPORT_SYMBOL_GPL(task_cls_state);


-- 
Konstantin
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web