From patchwork Tue May 10 02:28:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grant Grundler X-Patchwork-Id: 12844405 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3E44EC433EF for ; Tue, 10 May 2022 02:28:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234671AbiEJCco (ORCPT ); Mon, 9 May 2022 22:32:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40730 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234687AbiEJCcf (ORCPT ); Mon, 9 May 2022 22:32:35 -0400 Received: from mail-qk1-x733.google.com (mail-qk1-x733.google.com [IPv6:2607:f8b0:4864:20::733]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 467E21A90CC for ; Mon, 9 May 2022 19:28:39 -0700 (PDT) Received: by mail-qk1-x733.google.com with SMTP id v11so1912382qkf.1 for ; Mon, 09 May 2022 19:28:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=8rinvUkerUnBV1oCCsJspInjXAj8u20lqkKc2zXtN9k=; b=YSvcgAJmFkKTvstDHxNY7NSKlk4XIGhWHKxe1SPdH1m/1xkfacghSFkGsFBcHkwRN8 Hb8hp1lKChVAL/ja5FTS/V1oCZvrrlRYRO73z3pkrl9jv75dH3p+qn2Vv3DQ/h6TW1Zv LnW8RqqND7Rumoaid9OuYYJIbUfBQIvfPp1Ls= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=8rinvUkerUnBV1oCCsJspInjXAj8u20lqkKc2zXtN9k=; b=B16WFunwHsd0EB3g5NrsqTqTwjf+3RYegV+fUzFav0p/op87LbvZEV+TSDwL6jeWrv dMqBcUE3yhxFeY1v6fGXoJ0gbg2RM7+jh/tN4DogdhGdY4mbuSXkSV2a6H0kfWdGK399 ycMfz2LJfJTH0Xv8DHE+kUdDs6UoBXeaEkofnXvTr5GkoBvKc+Ng/MD4zMVyGc9oFeBt CDAu0eyGxwFztJPI5QiOZlDZaiEHiWltAKGv8evZUqFpi2YXCaRxApA0GUzpUOm0hihp 4dogLXgljLzVrleGyLokmhJbByeGlcGBPdRg6O5xjUZZeUyckOqNIB3mBQR3DxlSmygv sfkg== X-Gm-Message-State: AOAM530MQSjD8GRy0q7CXpRR1QiCa+HeZu+i/7y3vSvXPuG2BaFaE84X ZWb9NVmC15V2SQoBeoJPuxn8eg== X-Google-Smtp-Source: ABdhPJztevCzT89DbElfTEsOF0uoMW79/1vD5zhMlvLX7s2o06sJ/SCCOBfQbN6I0wISEmd3EJHFCw== X-Received: by 2002:a05:620a:4481:b0:6a0:1dd3:d210 with SMTP id x1-20020a05620a448100b006a01dd3d210mr14496664qkp.137.1652149718427; Mon, 09 May 2022 19:28:38 -0700 (PDT) Received: from grundler-glapstation.lan ([70.134.62.80]) by smtp.gmail.com with ESMTPSA id 18-20020a05620a06d200b0069fc13ce213sm7742375qky.68.2022.05.09.19.28.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 May 2022 19:28:37 -0700 (PDT) From: Grant Grundler To: Igor Russkikh Cc: Jakub Kicinski , Paolo Abeni , netdev , "David S . Miller" , LKML , Aashay Shringarpure , Yi Chou , Shervin Oloumi , Grant Grundler Subject: [PATCH 1/4] net: atlantic: fix "frag[0] not initialized" Date: Mon, 9 May 2022 19:28:23 -0700 Message-Id: <20220510022826.2388423-2-grundler@chromium.org> X-Mailer: git-send-email 2.36.0.512.ge40c2bad7a-goog In-Reply-To: <20220510022826.2388423-1-grundler@chromium.org> References: <20220510022826.2388423-1-grundler@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org In aq_ring_rx_clean(), if buff->is_eop is not set AND buff->len < AQ_CFG_RX_HDR_SIZE, then hdr_len remains equal to buff->len and skb_add_rx_frag(xxx, *0*, ...) is not called. The loop following this code starts calling skb_add_rx_frag() starting with i=1 and thus frag[0] is never initialized. Since i is initialized to zero at the top of the primary loop, we can just reference and post-increment i instead of hardcoding the 0 when calling skb_add_rx_frag() the first time. Reported-by: Aashay Shringarpure Reported-by: Yi Chou Reported-by: Shervin Oloumi Signed-off-by: Grant Grundler --- drivers/net/ethernet/aquantia/atlantic/aq_ring.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/net/ethernet/aquantia/atlantic/aq_ring.c b/drivers/net/ethernet/aquantia/atlantic/aq_ring.c index 77e76c9efd32..440423b0e8ea 100644 --- a/drivers/net/ethernet/aquantia/atlantic/aq_ring.c +++ b/drivers/net/ethernet/aquantia/atlantic/aq_ring.c @@ -446,7 +446,7 @@ int aq_ring_rx_clean(struct aq_ring_s *self, ALIGN(hdr_len, sizeof(long))); if (buff->len - hdr_len > 0) { - skb_add_rx_frag(skb, 0, buff->rxdata.page, + skb_add_rx_frag(skb, i++, buff->rxdata.page, buff->rxdata.pg_off + hdr_len, buff->len - hdr_len, AQ_CFG_RX_FRAME_MAX); @@ -455,7 +455,6 @@ int aq_ring_rx_clean(struct aq_ring_s *self, if (!buff->is_eop) { buff_ = buff; - i = 1U; do { next_ = buff_->next; buff_ = &self->buff_ring[next_]; From patchwork Tue May 10 02:28:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grant Grundler X-Patchwork-Id: 12844406 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 82F25C4332F for ; Tue, 10 May 2022 02:28:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234748AbiEJCcp (ORCPT ); Mon, 9 May 2022 22:32:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40730 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234696AbiEJCcn (ORCPT ); Mon, 9 May 2022 22:32:43 -0400 Received: from mail-qk1-x735.google.com (mail-qk1-x735.google.com [IPv6:2607:f8b0:4864:20::735]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BFB141B0907 for ; Mon, 9 May 2022 19:28:40 -0700 (PDT) Received: by mail-qk1-x735.google.com with SMTP id j6so12321617qkp.9 for ; Mon, 09 May 2022 19:28:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=bUbzj8GLC4jvUsYc0bHNPk/HK3W9TD3sIIfgXJoJyIY=; b=dKUkWB+BSsBV4LJQJgQQIGHHcr10pdJCgyB/PC3+Cizv5Xr6ZwuJgcoHpdJ2pIR7ca owKpDe8+vRmPfqytZ8SrTCheO3wx3rNEzMuzhhjeDJufu5ljhytYQOPTCL1SqPwOIbNT kAl0rEzPB3Kvxaw3Q0EXAUIly+pN51YVIZ6dI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=bUbzj8GLC4jvUsYc0bHNPk/HK3W9TD3sIIfgXJoJyIY=; b=Xm6pLcVn5ACY58iPLXGfTYiAmoCxJsWvM1gf79+zq5Swf4HcWJPrmljUA5FI1LeP9V 7O9itBWAcWOa/CB495oCR92zCDBZvBwbbIJvOyosrmgDxt4S6tcaNam689tomOONN7Ld zWIzE7/VmAms00I8uAxvWhjDPryHgPpduU6Wr6RRsikLKkAB3vfNLPa2lnomczzmQ1rL 5wkPFurjtDXhgMWbvuceid6tkbZDeK/cSqMwa7UDwI0BRVUeVfCCFkvY9w8CJOXQW+9z MctqrWzuRSas9ZmUgIFBHJnSTU1KaHqiaWfLBBL2ju4J648ffwAFWrRn/8jj7Wzw0Ryz r2WA== X-Gm-Message-State: AOAM5322PU/BrFrQxqO4GVQOnGiVplWoFpABDv89Y9YkyiIJjhf/MuYI z02yZt3lyvVKooWkywMIBVBdgQ== X-Google-Smtp-Source: ABdhPJw8tInFnILG7NEA+kbxqihBOLVsR4MN4pD697DeaRfAj4WTH5Sbi9DVb3wLh49+sUea6CnPaA== X-Received: by 2002:a37:a28d:0:b0:6a0:a446:703b with SMTP id l135-20020a37a28d000000b006a0a446703bmr4661918qke.661.1652149719908; Mon, 09 May 2022 19:28:39 -0700 (PDT) Received: from grundler-glapstation.lan ([70.134.62.80]) by smtp.gmail.com with ESMTPSA id 18-20020a05620a06d200b0069fc13ce213sm7742375qky.68.2022.05.09.19.28.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 May 2022 19:28:39 -0700 (PDT) From: Grant Grundler To: Igor Russkikh Cc: Jakub Kicinski , Paolo Abeni , netdev , "David S . Miller" , LKML , Aashay Shringarpure , Yi Chou , Shervin Oloumi , Grant Grundler Subject: [PATCH 2/4] net: atlantic: reduce scope of is_rsc_complete Date: Mon, 9 May 2022 19:28:24 -0700 Message-Id: <20220510022826.2388423-3-grundler@chromium.org> X-Mailer: git-send-email 2.36.0.512.ge40c2bad7a-goog In-Reply-To: <20220510022826.2388423-1-grundler@chromium.org> References: <20220510022826.2388423-1-grundler@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Don't defer handling the err case outside the loop. That's pointless. And since is_rsc_complete is only used inside this loop, declare it inside the loop to reduce it's scope. Signed-off-by: Grant Grundler --- drivers/net/ethernet/aquantia/atlantic/aq_ring.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/net/ethernet/aquantia/atlantic/aq_ring.c b/drivers/net/ethernet/aquantia/atlantic/aq_ring.c index 440423b0e8ea..bc1952131799 100644 --- a/drivers/net/ethernet/aquantia/atlantic/aq_ring.c +++ b/drivers/net/ethernet/aquantia/atlantic/aq_ring.c @@ -346,7 +346,6 @@ int aq_ring_rx_clean(struct aq_ring_s *self, int budget) { struct net_device *ndev = aq_nic_get_ndev(self->aq_nic); - bool is_rsc_completed = true; int err = 0; for (; (self->sw_head != self->hw_head) && budget; @@ -366,6 +365,8 @@ int aq_ring_rx_clean(struct aq_ring_s *self, if (!buff->is_eop) { buff_ = buff; do { + bool is_rsc_completed = true; + if (buff_->next >= self->size) { err = -EIO; goto err_exit; @@ -377,18 +378,16 @@ int aq_ring_rx_clean(struct aq_ring_s *self, next_, self->hw_head); - if (unlikely(!is_rsc_completed)) - break; + if (unlikely(!is_rsc_completed)) { + err = 0; + goto err_exit; + } buff->is_error |= buff_->is_error; buff->is_cso_err |= buff_->is_cso_err; } while (!buff_->is_eop); - if (!is_rsc_completed) { - err = 0; - goto err_exit; - } if (buff->is_error || (buff->is_lro && buff->is_cso_err)) { buff_ = buff; From patchwork Tue May 10 02:28:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grant Grundler X-Patchwork-Id: 12844407 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 92335C433F5 for ; Tue, 10 May 2022 02:28:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234775AbiEJCcr (ORCPT ); Mon, 9 May 2022 22:32:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40732 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234683AbiEJCcn (ORCPT ); Mon, 9 May 2022 22:32:43 -0400 Received: from mail-qt1-x831.google.com (mail-qt1-x831.google.com [IPv6:2607:f8b0:4864:20::831]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 787FD1B54AE for ; Mon, 9 May 2022 19:28:42 -0700 (PDT) Received: by mail-qt1-x831.google.com with SMTP id hh4so12635713qtb.10 for ; Mon, 09 May 2022 19:28:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=4EWw5JGDEHsMse3xSXgMpkF6wSSyJrohxFDmx4Uh7Y8=; b=SU4uW3pGecsbPcp0Kv09VMxlJlYHU5q6PWtTuzMCPY/ZfhDyY8oc/4TlbA+OEF5Qop jYot5V3KkZDNg0omlWj2/dOPS7t8ORwIXyq08+Vn+1YHQDQ62dCCCm4CwE/bijZofjl3 1mi7+08Gi2drCbHG9Baktf2sAwbolyZMKRCpo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=4EWw5JGDEHsMse3xSXgMpkF6wSSyJrohxFDmx4Uh7Y8=; b=ekCFAdg2OB6IQsYQZNYB3/gduQAaWocKEHzfOhKyf2tMcFLWDjlphxl8S4WSkieKX9 9ZuOWV8NbldgiaUk9B/vAHiNsJa7XPAWbYwr0FwOHzy3HPIF0DAuAFabebIs4UP4Smrh OFzvsCHcUqmeSvvHNhSUHxN+d5qGivtNPyWBKC8OxnMJfFjC2/F+VTzniB0TOSBUgXTA B/fd7VtGPkXWeQv45RBA6Y9qsiRYUvNxkQakuoGbkj0YFjuyXhtQYSFwSJsx5NV9MBK9 YY/cvMCJAQDx4oeFywCusdSodQvc+Wx2/KOWHGZBAefzLdmZegyXhG0ztUkmHreaX9HD BIuw== X-Gm-Message-State: AOAM533CgSxtfOdDSTwZTY23OBUu2/PcO264N54Y+6IRXAmaSkTUAJEL uP1vtSEcjd7TrDadQkHqJ89xhf8CAdZcpg== X-Google-Smtp-Source: ABdhPJxarJEk/ID5VphXnrFWpgEyqqSeuMq9yhKZqIDkr+eRQakSbG0CkYNJ1HoDIjV6KF5zy6aFmA== X-Received: by 2002:ac8:5e0c:0:b0:2f3:adfd:bd30 with SMTP id h12-20020ac85e0c000000b002f3adfdbd30mr17775658qtx.277.1652149721349; Mon, 09 May 2022 19:28:41 -0700 (PDT) Received: from grundler-glapstation.lan ([70.134.62.80]) by smtp.gmail.com with ESMTPSA id 18-20020a05620a06d200b0069fc13ce213sm7742375qky.68.2022.05.09.19.28.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 May 2022 19:28:40 -0700 (PDT) From: Grant Grundler To: Igor Russkikh Cc: Jakub Kicinski , Paolo Abeni , netdev , "David S . Miller" , LKML , Aashay Shringarpure , Yi Chou , Shervin Oloumi , Grant Grundler Subject: [PATCH 3/4] net: atlantic: add check for MAX_SKB_FRAGS Date: Mon, 9 May 2022 19:28:25 -0700 Message-Id: <20220510022826.2388423-4-grundler@chromium.org> X-Mailer: git-send-email 2.36.0.512.ge40c2bad7a-goog In-Reply-To: <20220510022826.2388423-1-grundler@chromium.org> References: <20220510022826.2388423-1-grundler@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Enforce that the CPU can not get stuck in an infinite loop. Reported-by: Aashay Shringarpure Reported-by: Yi Chou Reported-by: Shervin Oloumi Signed-off-by: Grant Grundler --- drivers/net/ethernet/aquantia/atlantic/aq_ring.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/aquantia/atlantic/aq_ring.c b/drivers/net/ethernet/aquantia/atlantic/aq_ring.c index bc1952131799..8201ce7adb77 100644 --- a/drivers/net/ethernet/aquantia/atlantic/aq_ring.c +++ b/drivers/net/ethernet/aquantia/atlantic/aq_ring.c @@ -363,6 +363,7 @@ int aq_ring_rx_clean(struct aq_ring_s *self, continue; if (!buff->is_eop) { + unsigned int frag_cnt = 0U; buff_ = buff; do { bool is_rsc_completed = true; @@ -371,6 +372,8 @@ int aq_ring_rx_clean(struct aq_ring_s *self, err = -EIO; goto err_exit; } + + frag_cnt++; next_ = buff_->next, buff_ = &self->buff_ring[next_]; is_rsc_completed = @@ -378,7 +381,8 @@ int aq_ring_rx_clean(struct aq_ring_s *self, next_, self->hw_head); - if (unlikely(!is_rsc_completed)) { + if (unlikely(!is_rsc_completed) || + frag_cnt > MAX_SKB_FRAGS) { err = 0; goto err_exit; } From patchwork Tue May 10 02:28:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grant Grundler X-Patchwork-Id: 12844408 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CAAE9C433F5 for ; Tue, 10 May 2022 02:29:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234724AbiEJCdD (ORCPT ); Mon, 9 May 2022 22:33:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41862 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234731AbiEJCcn (ORCPT ); Mon, 9 May 2022 22:32:43 -0400 Received: from mail-qk1-x72d.google.com (mail-qk1-x72d.google.com [IPv6:2607:f8b0:4864:20::72d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 092D71BA8F2 for ; Mon, 9 May 2022 19:28:43 -0700 (PDT) Received: by mail-qk1-x72d.google.com with SMTP id c1so12306193qkf.13 for ; Mon, 09 May 2022 19:28:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=KR84+H+bN0lQo4wWubc5nvH3kSUJYfq+QmRNV3y6a0k=; b=kg3DV5xvIdwvYnB14NNn+iQhe6oRv5KYGtp/uGfNnwIcUuEQOwRv6v/onYNXQ9Sd2v KdEFfE3V8nwxy/na6sSsFtDkU7IdIw14mjkawCvFJ9xUiYDd68MUKwlKBYL6BY4A7+Gt Sx76KKlsjVvMB1VpPr19zJ86eeXgUdZofordQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=KR84+H+bN0lQo4wWubc5nvH3kSUJYfq+QmRNV3y6a0k=; b=QtOLLWSEDuqClxZIfsbybyPlXcan736UCH/vWeGhTOBUxnzPyS6VGpMUnVkJILw3dG be7FFs/YUBPofoiWTl06v3EsqH13ec2npBTrMyJYD98bCTbVsE8AZOqclIi0wL2n54Go O9F3W0CEKmaEc25EFjXqkmaXBsjT8jNa+ne8WJYmIfy3juHk2M8POksiIS5aDYn1gWVC 2EerdMbK7iRvDzQVh5XZ/GoSsB9wccpSQCr4EMEZl/Ucme7v9OE5WylaqXFGcwV12dYP v55q9+jQWPs1dWQm3+A9Tv7MCmXICmUtiRfPL10wujhQHKNv+EmJAilmPjhvVP4awcfm IUiQ== X-Gm-Message-State: AOAM531UF9Acw+/UisETfUiKNQcy0BpKbb8vy9Q8zRFMS8O9EalZWdCJ XZA3X5tSQycaKWeg4vcCJWHjUA== X-Google-Smtp-Source: ABdhPJzsl0mRS8xiFI417lv8qxMM9KcSjMR34xbPd3Ea7e886h9IDUa9Cnp6DYeSvRK6lpcHhDRbvQ== X-Received: by 2002:a37:745:0:b0:69f:c741:105d with SMTP id 66-20020a370745000000b0069fc741105dmr14074522qkh.774.1652149722733; Mon, 09 May 2022 19:28:42 -0700 (PDT) Received: from grundler-glapstation.lan ([70.134.62.80]) by smtp.gmail.com with ESMTPSA id 18-20020a05620a06d200b0069fc13ce213sm7742375qky.68.2022.05.09.19.28.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 May 2022 19:28:42 -0700 (PDT) From: Grant Grundler To: Igor Russkikh Cc: Jakub Kicinski , Paolo Abeni , netdev , "David S . Miller" , LKML , Aashay Shringarpure , Yi Chou , Shervin Oloumi , Grant Grundler Subject: [PATCH 4/4] net: atlantic: verify hw_head_ lies within TX buffer ring Date: Mon, 9 May 2022 19:28:26 -0700 Message-Id: <20220510022826.2388423-5-grundler@chromium.org> X-Mailer: git-send-email 2.36.0.512.ge40c2bad7a-goog In-Reply-To: <20220510022826.2388423-1-grundler@chromium.org> References: <20220510022826.2388423-1-grundler@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Bounds check hw_head index provided by NIC to verify it lies within the TX buffer ring. Reported-by: Aashay Shringarpure Reported-by: Yi Chou Reported-by: Shervin Oloumi Signed-off-by: Grant Grundler --- drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_b0.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_b0.c b/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_b0.c index d875ce3ec759..15ede7285fb5 100644 --- a/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_b0.c +++ b/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_b0.c @@ -889,6 +889,13 @@ int hw_atl_b0_hw_ring_tx_head_update(struct aq_hw_s *self, err = -ENXIO; goto err_exit; } + + /* Validate that the new hw_head_ is reasonable. */ + if (hw_head_ >= ring->size) { + err = -ENXIO; + goto err_exit; + } + ring->hw_head = hw_head_; err = aq_hw_err_from_flags(self);