From patchwork Mon Apr 18 23:17:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grant Grundler X-Patchwork-Id: 12817156 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 EF74EC433EF for ; Mon, 18 Apr 2022 23:18:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234834AbiDRXUw (ORCPT ); Mon, 18 Apr 2022 19:20:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39566 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234785AbiDRXUt (ORCPT ); Mon, 18 Apr 2022 19:20:49 -0400 Received: from mail-qt1-x835.google.com (mail-qt1-x835.google.com [IPv6:2607:f8b0:4864:20::835]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 091FA24080 for ; Mon, 18 Apr 2022 16:18:09 -0700 (PDT) Received: by mail-qt1-x835.google.com with SMTP id fu34so2406043qtb.8 for ; Mon, 18 Apr 2022 16:18:08 -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=NlRd4j5md/1GciWxxdILk90+l0dQrFXO0akgvKuGKys=; b=hOG03vLUq3iZ50ueHjZVfyhoguvGmU1Wah3UxbLvRBUMDP7zKkkkBuYjd7CwcdDpmd wvvPtX/TM+hZxbHCcAAw7kNp7MW8z7+1X6+Xn1Ap+JnbWmme+Uhk6SUloc93MCqSiBSy dPQSoaoWybf/RQ5HVgmoPZD+Gdyrau6flv0MU= 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=NlRd4j5md/1GciWxxdILk90+l0dQrFXO0akgvKuGKys=; b=XnUStgDRhXexnk2igQP4GA1yjAnmse49WAvf/iw0Y+ntabxJmEQd+U2fBQPWOfz7Ik axT9CEEljD05dQljI/80PQ8sCpSKMRS+KBJwp0weHXF3Wp4T3QfbOaUv+tm/T8VcK9C9 pwyRklfxB/e46O4NtBpo1GyXkQN2PkVuuxSXd1VJQDVieGsc0UtyARj41mz7XPnHaqwL 9sMDLneYl9ar/Woh52jiIhfURzr7anT4Bttfa54OHsuAKiK/jU9C4W7OUyQusDyy3eeT qQQ5Q0Vki/zub8xOZclRh/bhtsAZoPCWgvu3HKTn8OKxjs23QAObJWLbsMyoa1HY9AF5 174A== X-Gm-Message-State: AOAM532JAyV35AryayaxjV98Bi+c06WwCTTJP0aqk4VlvReHFoa9fHxX FFgzjYoOkwtCrTVsKW14S/xK1AUyQ1mPPA== X-Google-Smtp-Source: ABdhPJz4CCSb9zYc5fCCMVLbVMjPO5dyAl5MissvY4yDiiQdYIkuU7OrNjGBrPyf5pI+AKWPBQ6/zw== X-Received: by 2002:a05:622a:40f:b0:2f1:f97b:7519 with SMTP id n15-20020a05622a040f00b002f1f97b7519mr6638240qtx.391.1650323888201; Mon, 18 Apr 2022 16:18:08 -0700 (PDT) Received: from grundler-glapstation.lan ([70.134.62.80]) by smtp.gmail.com with ESMTPSA id a1-20020a05622a02c100b002f17cba4930sm8214048qtx.85.2022.04.18.16.18.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Apr 2022 16:18:07 -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/5] net: atlantic: add check for MAX_SKB_FRAGS Date: Mon, 18 Apr 2022 16:17:45 -0700 Message-Id: <20220418231746.2464800-5-grundler@chromium.org> X-Mailer: git-send-email 2.36.0.rc0.470.gd361397f0d-goog In-Reply-To: <20220418231746.2464800-1-grundler@chromium.org> References: <20220418231746.2464800-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; }