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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:   Tue, 5 Jul 2022 17:09:20 +0800
From:   maqiao <mqaio@...ux.alibaba.com>
To:     Eric Dumazet <edumazet@...gle.com>
Cc:     David Miller <davem@...emloft.net>,
        Paolo Abeni <pabeni@...hat.com>,
        Jakub Kicinski <kuba@...nel.org>, gustavoars@...nel.org,
        cai.huoqing@...ux.dev, Aviad Krawczyk <aviad.krawczyk@...wei.com>,
        zhaochen6@...wei.com, netdev <netdev@...r.kernel.org>,
        LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH net-next v3 3/3] net: hinic: fix bug that u64_stats_sync
 is not initialized



在 2022/7/5 下午4:53, Eric Dumazet 写道:
> On Tue, Jul 5, 2022 at 8:26 AM Qiao Ma <mqaio@...ux.alibaba.com> wrote:
>>
>> In get_drv_queue_stats(), the local variable {txq|rxq}_stats
>> should be initialized first before calling into
>> hinic_{rxq|txq}_get_stats(), this patch fixes it.
>>
>> Fixes: edd384f682cc ("net-next/hinic: Add ethtool and stats")
>> Signed-off-by: Qiao Ma <mqaio@...ux.alibaba.com>
>> ---
>>   drivers/net/ethernet/huawei/hinic/hinic_ethtool.c | 3 +++
>>   1 file changed, 3 insertions(+)
>>
>> diff --git a/drivers/net/ethernet/huawei/hinic/hinic_ethtool.c b/drivers/net/ethernet/huawei/hinic/hinic_ethtool.c
>> index 93192f58ac88..75e9711bd2ba 100644
>> --- a/drivers/net/ethernet/huawei/hinic/hinic_ethtool.c
>> +++ b/drivers/net/ethernet/huawei/hinic/hinic_ethtool.c
>> @@ -1371,6 +1371,9 @@ static void get_drv_queue_stats(struct hinic_dev *nic_dev, u64 *data)
>>          u16 i = 0, j = 0, qid = 0;
>>          char *p;
>>
>> +       u64_stats_init(&txq_stats.syncp);
>> +       u64_stats_init(&rxq_stats.syncp);
>> +
> 
> This is wrong really.
> 
> txq_stats and rxq_stats are local variables in get_drv_queue_stats()
> 
> It makes little sense to use u64_stats infra on them, because they are
> not visible to other cpus/threads in the host.
> 
> Please remove this confusion, instead of consolidating it.
Thanks, I'll remove it in next version.
> 
> diff --git a/drivers/net/ethernet/huawei/hinic/hinic_main.c
> b/drivers/net/ethernet/huawei/hinic/hinic_main.c
> index 56a89793f47d4209b9e0dc3a122801d476e61381..edaac5a33458d51a3fb3e75c5fbe5bec8385f688
> 100644
> --- a/drivers/net/ethernet/huawei/hinic/hinic_main.c
> +++ b/drivers/net/ethernet/huawei/hinic/hinic_main.c
> @@ -85,8 +85,6 @@ static void update_rx_stats(struct hinic_dev
> *nic_dev, struct hinic_rxq *rxq)
>          struct hinic_rxq_stats *nic_rx_stats = &nic_dev->rx_stats;
>          struct hinic_rxq_stats rx_stats;
> 
> -       u64_stats_init(&rx_stats.syncp);
> -
>          hinic_rxq_get_stats(rxq, &rx_stats);
> 
>          u64_stats_update_begin(&nic_rx_stats->syncp);
> @@ -105,8 +103,6 @@ static void update_tx_stats(struct hinic_dev
> *nic_dev, struct hinic_txq *txq)
>          struct hinic_txq_stats *nic_tx_stats = &nic_dev->tx_stats;
>          struct hinic_txq_stats tx_stats;
> 
> -       u64_stats_init(&tx_stats.syncp);
> -
>          hinic_txq_get_stats(txq, &tx_stats);
> 
>          u64_stats_update_begin(&nic_tx_stats->syncp);
> diff --git a/drivers/net/ethernet/huawei/hinic/hinic_rx.c
> b/drivers/net/ethernet/huawei/hinic/hinic_rx.c
> index 24b7b819dbfbad1d64116ef54058ee4887d7a056..4edf4c52787051aebc512094741bda30de27e2f0
> 100644
> --- a/drivers/net/ethernet/huawei/hinic/hinic_rx.c
> +++ b/drivers/net/ethernet/huawei/hinic/hinic_rx.c
> @@ -66,14 +66,13 @@ void hinic_rxq_clean_stats(struct hinic_rxq *rxq)
>   /**
>    * hinic_rxq_get_stats - get statistics of Rx Queue
>    * @rxq: Logical Rx Queue
> - * @stats: return updated stats here
> + * @stats: return updated stats here (private to caller)
>    **/
>   void hinic_rxq_get_stats(struct hinic_rxq *rxq, struct hinic_rxq_stats *stats)
>   {
> -       struct hinic_rxq_stats *rxq_stats = &rxq->rxq_stats;
> +       const struct hinic_rxq_stats *rxq_stats = &rxq->rxq_stats;
>          unsigned int start;
> 
> -       u64_stats_update_begin(&stats->syncp);
>          do {
>                  start = u64_stats_fetch_begin(&rxq_stats->syncp);
>                  stats->pkts = rxq_stats->pkts;
> @@ -83,7 +82,6 @@ void hinic_rxq_get_stats(struct hinic_rxq *rxq,
> struct hinic_rxq_stats *stats)
>                  stats->csum_errors = rxq_stats->csum_errors;
>                  stats->other_errors = rxq_stats->other_errors;
>          } while (u64_stats_fetch_retry(&rxq_stats->syncp, start));
> -       u64_stats_update_end(&stats->syncp);
>   }
> 
>   /**
> diff --git a/drivers/net/ethernet/huawei/hinic/hinic_tx.c
> b/drivers/net/ethernet/huawei/hinic/hinic_tx.c
> index 87408e7bb8097de6fced7f0f2d170179b3fe93a9..2d97add1107f08f088b68a823767a92cbc6bbbdf
> 100644
> --- a/drivers/net/ethernet/huawei/hinic/hinic_tx.c
> +++ b/drivers/net/ethernet/huawei/hinic/hinic_tx.c
> @@ -91,14 +91,13 @@ void hinic_txq_clean_stats(struct hinic_txq *txq)
>   /**
>    * hinic_txq_get_stats - get statistics of Tx Queue
>    * @txq: Logical Tx Queue
> - * @stats: return updated stats here
> + * @stats: return updated stats here (private to caller)
>    **/
>   void hinic_txq_get_stats(struct hinic_txq *txq, struct hinic_txq_stats *stats)
>   {
> -       struct hinic_txq_stats *txq_stats = &txq->txq_stats;
> +       const struct hinic_txq_stats *txq_stats = &txq->txq_stats;
>          unsigned int start;
> 
> -       u64_stats_update_begin(&stats->syncp);
>          do {
>                  start = u64_stats_fetch_begin(&txq_stats->syncp);
>                  stats->pkts    = txq_stats->pkts;
> @@ -108,7 +107,6 @@ void hinic_txq_get_stats(struct hinic_txq *txq,
> struct hinic_txq_stats *stats)
>                  stats->tx_dropped = txq_stats->tx_dropped;
>                  stats->big_frags_pkts = txq_stats->big_frags_pkts;
>          } while (u64_stats_fetch_retry(&txq_stats->syncp, start));
> -       u64_stats_update_end(&stats->syncp);
>   }
> 
>   /**

Powered by blists - more mailing lists