Received: by 2002:ac2:464d:0:0:0:0:0 with SMTP id s13csp3681511lfo; Mon, 23 May 2022 11:15:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzdgUNqNbVJToiysZpxZSh3LhNGm0wjDXWfGCfDltYUW/QOnXIyY6qpxQcMDGrHPmn3vIxw X-Received: by 2002:a05:6a00:24cf:b0:518:a44b:10d6 with SMTP id d15-20020a056a0024cf00b00518a44b10d6mr5640325pfv.57.1653329748864; Mon, 23 May 2022 11:15:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653329748; cv=none; d=google.com; s=arc-20160816; b=LcqljCe+IYdNJHag3Lla72oWLxjjaE5Nmu61WxPgQj3j8W9k6kA1oJcon7LyZBT8UG ydJnp8shIbWpHlOhYBMQab7vxVb8Mjt2VBymC9RZcQR/X9HqOsFI2aVhwY/UvV6IW5KV gPUdpmxXFvSRqeWXdtO0dj1C9S7Yr0678i7N3uQcJTBAY3ZpN32/j/NUaJzoHdQDVCw7 9JMiZTAFWQs1CPNllAuEvFtIz9ws0fpAIJ1jdJBDXWJBGKgyY0Sk2htlP0cg5Tvbtb8O OCoKRktOVemQcbbvEr0K5ttvKxGjS7hnzqsL7USTx7ZdM8J/oc4x1b+Qa37+FatEd6tZ tuVA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=4m3J/T9Ss83EsHT5umi2Sbm7bO81o3KtASMsVsMoAVg=; b=H/Eo5nPpsIF0HHsDzB9p4h7vPqJP0bDdbSOa7em+OklbEWYhNf/I94d+pXU/+AdFQP EYV7xHL7TftUZJYKuW/dHl/ldt9w3yK9e8ovq8QdeesVpejRwryZDaecnAOYGzN4k3yj l3Il23wqGHhwjF93bjRInCmRRaqXRATCNJhzAN9FxpYzHmfCUW7ADnDPmuhS7xsTz9C1 RsDLyqh+RcV6NQgQK1jAZkQfiVXfv9HwQyXn/e97biVhTppS/qfOWwJiJp/KrXxwSyo3 4gwgDFWB4dKUEyoyyNZN0c/x5mWbGClG3NEKnhddkiqAHxCy3QDC8tsXNZ3tfmXOYH9T cl3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=0tsayt+n; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id nu13-20020a17090b1b0d00b001d973c6d990si3867100pjb.169.2022.05.23.11.15.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 May 2022 11:15:48 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=0tsayt+n; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 599191611C0; Mon, 23 May 2022 11:14:06 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343847AbiEWSIm (ORCPT + 99 others); Mon, 23 May 2022 14:08:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42376 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243585AbiEWRiS (ORCPT ); Mon, 23 May 2022 13:38:18 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 528196EC49; Mon, 23 May 2022 10:32:30 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 2FC9AB811F8; Mon, 23 May 2022 17:31:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 55FA2C385AA; Mon, 23 May 2022 17:31:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1653327088; bh=Eh20xBib3bRTCPbaAVbjeIBlp5HWjm1Ir/G+4BMbClg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0tsayt+nyaLPV3jp5rnClqTUQspXnFPIrUGaV8FpgkHC8MztAI/QAFzb1c4hbJmEC J1WIqth+8+qMBKimxY7nGOl34K8/60KXpFesbLWPZUnqCV3EeZNUR5kMYoLjiLlPux Qw+ifNhoM+rH46TEMAJe9DiXUGSBAdpctnbjYFaE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Aashay Shringarpure , Yi Chou , Shervin Oloumi , Grant Grundler , "David S. Miller" , Sasha Levin Subject: [PATCH 5.17 152/158] net: atlantic: add check for MAX_SKB_FRAGS Date: Mon, 23 May 2022 19:05:09 +0200 Message-Id: <20220523165855.376317577@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220523165830.581652127@linuxfoundation.org> References: <20220523165830.581652127@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Grant Grundler [ Upstream commit 6aecbba12b5c90b26dc062af3b9de8c4b3a2f19f ] 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 Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- 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; } -- 2.35.1