Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3920648pxj; Mon, 21 Jun 2021 09:23:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz6RfU/4yejVAEFmqjTMftzhIsIRW/XYHi08xNpUTbWJNMF2og27BhCmBepwoKDhXQiNvu3 X-Received: by 2002:a6b:590e:: with SMTP id n14mr13777479iob.186.1624292638308; Mon, 21 Jun 2021 09:23:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624292638; cv=none; d=google.com; s=arc-20160816; b=rYwOX7Ez5GqID85MWDRQWP4PzvNVO2GjoPLYOva4UL3HjXfSV+w8ZZEavE+z4MQRgc wM51o3mDlMP2Sddj/zeey1s3UqQ94wdwK161RS8IWx62Clq7q+UgzHSGGltCLeqKmSTU 1Bhkikd0Tv6e91WuwS9bMtUYf51zBUViN3N4TIPMXkNFYgiimLuB+VIue0pEiC+1gPSL XmD6xmwt5zNE3ZIE3+90qByAzVWVzXtEXfRX83rPtlE752VWK4duK0BE3f8oF+KtvOTk y2cbv8S+M53aM7inEG5OUOifl3M3g9euUYZgWhBb13osFGPEwyZm2Bmbt0s2FzTc4ZKM egjA== 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=AoyINBlcBATN8ISNNdF7XWl8Kg+mC3nGeYBXN+CBA14=; b=JbtAgDM2nZNjTjbgkBZcz1iWJvF0sUJymovZZxlcbfvKDXQmYs1dRdTyjwgMCQjck1 Flv+Kq7H309V4JVSK9eHNN50z2Yh+lBZcBX+7CH8hJZ/12MvNA0vbBDv4NinZRR2mi6+ +X2T5vQQ7rPiL+5o7kdqqfLeLgZJV/Vbw06mQB3z0D1CkVLx95BQLU+aRGpAF0HXBP3Q Usccq8IlcSC7EuWHCx2oREWG1m2CvvCW0ajUu0k05TE7gSm5oBgn8Lnzf960TWFSRNar 2xO3Bpvt2cOCe09DtZUTxszVQuT1awv8XYnwRqTG8fIHg1sQ9GQ/ulqLEzUB6NPeyUZN rz1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=HOiZ5idR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c4si7834543ilk.14.2021.06.21.09.23.45; Mon, 21 Jun 2021 09:23:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=HOiZ5idR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231492AbhFUQZJ (ORCPT + 99 others); Mon, 21 Jun 2021 12:25:09 -0400 Received: from mail.kernel.org ([198.145.29.99]:42142 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230205AbhFUQX0 (ORCPT ); Mon, 21 Jun 2021 12:23:26 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2B923613B4; Mon, 21 Jun 2021 16:20:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1624292442; bh=gzDejNICy4bQYydZ8dUtj9LevACs+31+dQ4Og9AmULY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HOiZ5idR4p3ZcwgoIKkfZlswjYA97rW6o6rh71zyddk/a9i5vrqPDsIycbCh7tQcR DeQhMcFKH+axvWy+lk0x1feWSRxYseC1YNu453fy89dd5gcyevGL+WR/tj2tmvuDgq 8fpJqeDHMJTtcjAwXygsZ73DbVUZ4UWpbdB+A2Fs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Esben Haabendal , "David S. Miller" Subject: [PATCH 5.4 75/90] net: ll_temac: Fix TX BD buffer overwrite Date: Mon, 21 Jun 2021 18:15:50 +0200 Message-Id: <20210621154906.695309818@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210621154904.159672728@linuxfoundation.org> References: <20210621154904.159672728@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Esben Haabendal commit c364df2489b8ef2f5e3159b1dff1ff1fdb16040d upstream. Just as the initial check, we need to ensure num_frag+1 buffers available, as that is the number of buffers we are going to use. This fixes a buffer overflow, which might be seen during heavy network load. Complete lockup of TEMAC was reproducible within about 10 minutes of a particular load. Fixes: 84823ff80f74 ("net: ll_temac: Fix race condition causing TX hang") Cc: stable@vger.kernel.org # v5.4+ Signed-off-by: Esben Haabendal Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/xilinx/ll_temac_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/net/ethernet/xilinx/ll_temac_main.c +++ b/drivers/net/ethernet/xilinx/ll_temac_main.c @@ -846,7 +846,7 @@ temac_start_xmit(struct sk_buff *skb, st smp_mb(); /* Space might have just been freed - check again */ - if (temac_check_tx_bd_space(lp, num_frag)) + if (temac_check_tx_bd_space(lp, num_frag + 1)) return NETDEV_TX_BUSY; netif_wake_queue(ndev);