Message ID | 20231012101706.2291551-1-srasheed@marvell.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp1114829vqb; Thu, 12 Oct 2023 03:17:35 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH9fV8waSyh5mexyw6VESy1lvsNIwjDJ1G6+9UrTmGEZcocJR24rWaaoQa7aCfjvOSkvPk9 X-Received: by 2002:a17:90b:1bce:b0:27c:ebab:5c60 with SMTP id oa14-20020a17090b1bce00b0027cebab5c60mr6939697pjb.2.1697105855145; Thu, 12 Oct 2023 03:17:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697105855; cv=none; d=google.com; s=arc-20160816; b=fqtLX16R8LGMT7bqj/R/2dYdhkIF2p7y+o0keVQmhqWENml1ZW+28ICdLXQtQq/D5T XhVn0erbvNHNRh+AhWbbMqb+FfQP5Jv727bRVVVfMPnSZFDWmNEboej7rBp2WLCumyxD TOb+MOotgfAclnz+BP0jUCthfrivXSsKrrBFF0Kf109fRwmymv8+q5+uEuj6XPSQVsum ++3dR5AI+aHhCGYhcz8/xba2UVzo3WLmjNWAbKQrmkQaNQoYXvabwgdwI5YKthQXyeV8 nf8fFwxbr0E5rynMj3QCxI4+PmL4dtEi82f465EIuzSYLG7XroHqWYCT1FaE3QEEIx37 8YTw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=d+djpV289X90GjGTImlyzR3rGGKFxtvJnllV5lv1v8M=; fh=WE7+wdqvx4NMxDJRoFxI6qqK6pRC0TSSnoy3QcJhtFI=; b=MDu9pP5Ujn6xbEKPZzOIrRylAyG/Ma/ax4hW9+qzox1GyhEczAT6jQD3wLqCGwOeOu S01fLU7o6/K36UuqOSiXfJu1vLRN4h8GcjLXmuP8I1y+mKxPvP36cqbIsJKJ1HUZY0dx VhtK044pka3HRSY3W5L0ToD2cHCh1ovSvr/DscIhKfjEto3VjSU6ZDKI/dH49B1AJQI/ oE2fI74wbnrQV7hJAVFwlJhxf7COeomylZ4QSylj6C4QkZwld0lbRQ4hp4EotN3fpbhZ 1xeZVnSHr9AGmPCPtHzZG0+I8nJnEsR0nQ2zpOOdL9ZnLgyxKEhSWlY8QIjacufC3+Vp syqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@marvell.com header.s=pfpt0220 header.b=k6JFntva; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=REJECT dis=NONE) header.from=marvell.com Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id oj7-20020a17090b4d8700b002791edaee33si2183611pjb.77.2023.10.12.03.17.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 03:17:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@marvell.com header.s=pfpt0220 header.b=k6JFntva; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=REJECT dis=NONE) header.from=marvell.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 0C3068062375; Thu, 12 Oct 2023 03:17:33 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343713AbjJLKR0 (ORCPT <rfc822;rua109.linux@gmail.com> + 19 others); Thu, 12 Oct 2023 06:17:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51442 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235644AbjJLKRZ (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 12 Oct 2023 06:17:25 -0400 Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DF1FBA9; Thu, 12 Oct 2023 03:17:23 -0700 (PDT) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 39C7bZTp017956; Thu, 12 Oct 2023 03:17:12 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=d+djpV289X90GjGTImlyzR3rGGKFxtvJnllV5lv1v8M=; b=k6JFntva6WFn24kjphD5nkC99GQjwno96LU2hXXwicvzLPJQXVDBvX3sS2jobt318uo+ BE4KzyPuIgZl1ZC1WPDFkeNc0PEEb5yWGk6OhrmPPlDJ5xIgGKR/fyJlFNgv+cWq8Ldm /yuc1td3yPf5+TF2iFL8QBHXGI1ANl8FflFrpe6tF35vYzcc1XBVGtTz+6Gn60WE8w98 ab7QFDyvjBT9J8pCWFYjfS8PHLAjR1uaY4a4LpLiF5XEQjXowNIDkWECRi8If1xqAfAZ c47tDTcmURoWtu1KdyjCMZJZ0DiSY4WW372N6gFVRkbTctN3Ylob5pNovUUgc43CFYav Bg== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3tp2pajs97-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Thu, 12 Oct 2023 03:17:12 -0700 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Thu, 12 Oct 2023 03:17:10 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.48 via Frontend Transport; Thu, 12 Oct 2023 03:17:10 -0700 Received: from ubuntu-PowerEdge-T110-II.sclab.marvell.com (unknown [10.106.27.86]) by maili.marvell.com (Postfix) with ESMTP id 629AA3F7089; Thu, 12 Oct 2023 03:17:10 -0700 (PDT) From: Shinas Rasheed <srasheed@marvell.com> To: <pabeni@redhat.com>, <linux-kernel@vger.kernel.org> CC: <davem@davemloft.net>, <edumazet@google.com>, <egallen@redhat.com>, <hgani@marvell.com>, <kuba@kernel.org>, <mschmidt@redhat.com>, <netdev@vger.kernel.org>, <srasheed@marvell.com>, <sedara@marvell.com>, <vburru@marvell.com>, <vimleshk@marvell.com> Subject: [net PATCH v2] octeon_ep: update BQL sent bytes before ringing doorbell Date: Thu, 12 Oct 2023 03:17:06 -0700 Message-ID: <20231012101706.2291551-1-srasheed@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <PH0PR18MB47342FEB8D57162EE5765E3CC7D3A@PH0PR18MB4734.namprd18.prod.outlook.com> References: <PH0PR18MB47342FEB8D57162EE5765E3CC7D3A@PH0PR18MB4734.namprd18.prod.outlook.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-GUID: o_Q5_OqbUIffA3x3swIX-MUTG36zW6eh X-Proofpoint-ORIG-GUID: o_Q5_OqbUIffA3x3swIX-MUTG36zW6eh X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.980,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-10-12_05,2023-10-12_01,2023-05-22_02 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Thu, 12 Oct 2023 03:17:33 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779369150089185586 X-GMAIL-MSGID: 1779544468991008363 |
Series |
[net,v2] octeon_ep: update BQL sent bytes before ringing doorbell
|
|
Commit Message
Shinas Rasheed
Oct. 12, 2023, 10:17 a.m. UTC
Sometimes Tx is completed immediately after doorbell is updated, which
causes Tx completion routing to update completion bytes before the
same packet bytes are updated in sent bytes in transmit function, hence
hitting BUG_ON() in dql_completed(). To avoid this, update BQL
sent bytes before ringing doorbell.
Fixes: 37d79d059606 ("octeon_ep: add Tx/Rx processing and interrupt support")
Signed-off-by: Shinas Rasheed <srasheed@marvell.com>
---
V1 -> V2: Call netdev_tx_sent_queue before memory barrier
drivers/net/ethernet/marvell/octeon_ep/octep_main.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
On Thu, 12 Oct 2023 03:17:06 -0700 Shinas Rasheed wrote: > Sometimes Tx is completed immediately after doorbell is updated, which > causes Tx completion routing to update completion bytes before the > same packet bytes are updated in sent bytes in transmit function, hence > hitting BUG_ON() in dql_completed(). To avoid this, update BQL > sent bytes before ringing doorbell. Please read this: https://www.kernel.org/doc/html/next/process/maintainer-netdev.html#resending-after-review And also when you reply to people please use sane quoting. This: >>> is used to indicate three levels of quoting.
Hi Jakub, Apologizing for the format errors on my part. Should I send the v2 patch again separately in a new thread, or will this be enough for now to avoid the clutter?
On Fri, 13 Oct 2023 09:04:07 +0000 Shinas Rasheed wrote: > Apologizing for the format errors on my part. Should I send the v2 > patch again separately in a new thread, or will this be enough for > now to avoid the clutter? Sorry, I meant to get to this on Friday but run out of hours. No need to repost, my comments were just for future reference since you have sent multiple patches already and will likely send more :)
On Thu, 12 Oct 2023 03:17:06 -0700 Shinas Rasheed wrote: > - netdev_tx_sent_queue(iq->netdev_q, skb->len); > iq->stats.instr_posted++; > skb_tx_timestamp(skb); The skb_tx_timestamp() here will do the same exact UAF, no? I think you should move them both.
diff --git a/drivers/net/ethernet/marvell/octeon_ep/octep_main.c b/drivers/net/ethernet/marvell/octeon_ep/octep_main.c index dbc518ff8276..15420325aef3 100644 --- a/drivers/net/ethernet/marvell/octeon_ep/octep_main.c +++ b/drivers/net/ethernet/marvell/octeon_ep/octep_main.c @@ -715,6 +715,7 @@ static netdev_tx_t octep_start_xmit(struct sk_buff *skb, hw_desc->dptr = tx_buffer->sglist_dma; } + netdev_tx_sent_queue(iq->netdev_q, skb->len); /* Flush the hw descriptor before writing to doorbell */ wmb(); @@ -726,7 +727,6 @@ static netdev_tx_t octep_start_xmit(struct sk_buff *skb, wi = 0; iq->host_write_index = wi; - netdev_tx_sent_queue(iq->netdev_q, skb->len); iq->stats.instr_posted++; skb_tx_timestamp(skb); return NETDEV_TX_OK;