lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 2 Jun 2021 09:21:01 +0800
From:   Yunsheng Lin <linyunsheng@...wei.com>
To:     Jakub Kicinski <kuba@...nel.org>
CC:     Yunsheng Lin <yunshenglin0825@...il.com>, <davem@...emloft.net>,
        <olteanv@...il.com>, <ast@...nel.org>, <daniel@...earbox.net>,
        <andriin@...com>, <edumazet@...gle.com>, <weiwan@...gle.com>,
        <cong.wang@...edance.com>, <ap420073@...il.com>,
        <netdev@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
        <linuxarm@...neuler.org>, <mkl@...gutronix.de>,
        <linux-can@...r.kernel.org>, <jhs@...atatu.com>,
        <xiyou.wangcong@...il.com>, <jiri@...nulli.us>,
        <andrii@...nel.org>, <kafai@...com>, <songliubraving@...com>,
        <yhs@...com>, <john.fastabend@...il.com>, <kpsingh@...nel.org>,
        <bpf@...r.kernel.org>, <jonas.bonn@...rounds.com>,
        <pabeni@...hat.com>, <mzhivich@...mai.com>, <johunt@...mai.com>,
        <albcamus@...il.com>, <kehuan.feng@...il.com>,
        <a.fatoum@...gutronix.de>, <atenart@...nel.org>,
        <alexander.duyck@...il.com>, <hdanton@...a.com>, <jgross@...e.com>,
        <JKosina@...e.com>, <mkubecek@...e.cz>, <bjorn@...nel.org>,
        <alobakin@...me>
Subject: Re: [Linuxarm] Re: [PATCH net-next 2/3] net: sched: implement
 TCQ_F_CAN_BYPASS for lockless qdisc

On 2021/6/2 4:48, Jakub Kicinski wrote:
> On Tue, 1 Jun 2021 16:18:54 +0800 Yunsheng Lin wrote:
>>> I see, thanks! That explains the need. Perhaps we can rephrase the
>>> comment? Maybe:
>>>
>>> +			/* Retest nolock_qdisc_is_empty() within the protection
>>> +			 * of q->seqlock to protect from racing with requeuing.
>>> +			 */  
>>
>> Yes if we still decide to preserve the nolock_qdisc_is_empty() rechecking
>> under q->seqlock.
> 
> Sounds good.
> 
>>>> --- a/net/sched/sch_generic.c
>>>> +++ b/net/sched/sch_generic.c
>>>> @@ -38,6 +38,15 @@ EXPORT_SYMBOL(default_qdisc_ops);
>>>>  static void qdisc_maybe_clear_missed(struct Qdisc *q,
>>>>                                      const struct netdev_queue *txq)
>>>>  {
>>>> +       set_bit(__QDISC_STATE_DRAINING, &q->state);
>>>> +
>>>> +       /* Make sure DRAINING is set before clearing MISSED
>>>> +        * to make sure nolock_qdisc_is_empty() always return
>>>> +        * false for aoviding transmitting a packet directly
>>>> +        * bypassing the requeued packet.
>>>> +        */
>>>> +       smp_mb__after_atomic();
>>>> +
>>>>         clear_bit(__QDISC_STATE_MISSED, &q->state);
>>>>
>>>>         /* Make sure the below netif_xmit_frozen_or_stopped()
>>>> @@ -52,8 +61,6 @@ static void qdisc_maybe_clear_missed(struct Qdisc *q,
>>>>          */
>>>>         if (!netif_xmit_frozen_or_stopped(txq))
>>>>                 set_bit(__QDISC_STATE_MISSED, &q->state);
>>>> -       else
>>>> -               set_bit(__QDISC_STATE_DRAINING, &q->state);
>>>>  }  
>>>
>>> But this would not be enough because we may also clear MISSING 
>>> in pfifo_fast_dequeue()?  
>>
>> For the MISSING clearing in pfifo_fast_dequeue(), it seems it
>> looks like the data race described in RFC v3 too?
>>
>>       CPU1                 CPU2               CPU3
>> qdisc_run_begin(q)          .                  .
>>         .              MISSED is set           .
>>   MISSED is cleared         .                  .
>>     q->dequeue()            .                  .
>>         .              enqueue skb1     check MISSED # true
>> qdisc_run_end(q)            .                  .
>>         .                   .         qdisc_run_begin(q) # true
>>         .            MISSED is set      send skb2 directly
> 
> Not sure what you mean.

       CPU1                 CPU2               CPU3
 qdisc_run_begin(q)          .                  .
         .              MISSED is set           .
   MISSED is cleared         .                  .
   another dequeuing         .                  .
         .                   .                  .
         .              enqueue skb1  nolock_qdisc_is_empty() # true
 qdisc_run_end(q)            .                  .
         .                   .         qdisc_run_begin(q) # true
         .                   .          send skb2 directly
         .               MISSED is set          .

As qdisc is indeed empty at the point when MISSED is clear and
another dequeue is retried by CPU1, MISSED setting is not under
q->seqlock, so it seems retesting MISSED under q->seqlock does not
seem to make any difference? and it seems like the case that does
not need handling as we agreed previously?


> 
> .
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ