From patchwork Mon Jan 13 16:30:00 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 13937763 X-Patchwork-Delegate: kuba@kernel.org Received: from out-182.mta1.migadu.com (out-182.mta1.migadu.com [95.215.58.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9B23D22BACE for ; Mon, 13 Jan 2025 16:30:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736785830; cv=none; b=odVd8JURacMcEFM2LlcA34V2vfSuVvPq0ML276ecRbNE0bviOfP3/dtyZr581PHTjQQAl2Erq63AcvGeEqRAo91pxpA97GLMbpRsNate3wxu/L0cE/8aDfHcenjyn2CVcG7FIkemL/wugAjbAxe2vgVSKD911PmKFbdujBTcjDA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736785830; c=relaxed/simple; bh=vn17tQTRifoU70IvEay/XlrsOY6DOtxSrwCeMLSZhpY=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=YWh5+Hh043nZTk17JsryRxkM7QkWRHUUVOn6iNx3L3zDWXAy3ilogEJaJ2ReYzO7e34pM+6Nnrhzx9jX7cuoj9avPN+Umuv5xpjRWG2Zhbsfkig8D091SfwRpcvtnULao544zO+cc3w6GglNr8nAvq5vJTBKlEk8bHZUo9PgW9M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=goFtUNsy; arc=none smtp.client-ip=95.215.58.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="goFtUNsy" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1736785815; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=pl+wZ2x+ZdqTG0lEglmVegKw0Hhj58CtH64CcDGmvHU=; b=goFtUNsyFKOML04zHS6B/aG6lQPGVAgvkHREkRd2ONO2kArsAR7tInmmevzqhWY7ZgLB0p qj2BwfUGVQtBR2KQBzOMycMYLcIVBaKzWuFp0SRU4pNkNUo3I2Fuefx9NpdXGEL+H6AWu3 TK6FoJ+cChKKcMoOIWi3B7rC1oB5+S4= From: Sean Anderson To: Radhey Shyam Pandey , Shannon Nelson , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, Simon Horman , Michal Simek , linux-kernel@vger.kernel.org, Daniel Borkmann , Sean Anderson Subject: [PATCH net v5] net: xilinx: axienet: Fix IRQ coalescing packet count overflow Date: Mon, 13 Jan 2025 11:30:00 -0500 Message-Id: <20250113163001.2335235-1-sean.anderson@linux.dev> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Patchwork-Delegate: kuba@kernel.org If coalesce_count is greater than 255 it will not fit in the register and will overflow. This can be reproduced by running # ethtool -C ethX rx-frames 256 which will result in a timeout of 0us instead. Fix this by checking for invalid values and reporting an error. Fixes: 8a3b7a252dca ("drivers/net/ethernet/xilinx: added Xilinx AXI Ethernet driver") Signed-off-by: Sean Anderson Reviewed-by: Shannon Nelson Reviewed-by: Radhey Shyam Pandey --- Changes in v5: - Fix typo in commit message Changes in v4: - Fix checking rx twice instead of rx and tx Changes in v3: - Validate and reject instead of silently clamping Changes in v2: - Use FIELD_MAX to extract the max value from the mask - Expand the commit message with an example on how to reproduce this issue drivers/net/ethernet/xilinx/xilinx_axienet_main.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c index 0f4b02fe6f85..ae743991117c 100644 --- a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c +++ b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c @@ -2056,6 +2056,12 @@ axienet_ethtools_set_coalesce(struct net_device *ndev, return -EBUSY; } + if (ecoalesce->rx_max_coalesced_frames > 255 || + ecoalesce->tx_max_coalesced_frames > 255) { + NL_SET_ERR_MSG(extack, "frames must be less than 256"); + return -EINVAL; + } + if (ecoalesce->rx_max_coalesced_frames) lp->coalesce_count_rx = ecoalesce->rx_max_coalesced_frames; if (ecoalesce->rx_coalesce_usecs)