From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 621F82E7F08; Tue, 15 Jul 2025 13:32:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752586375; cv=none; b=PCaEtzkpQzsawaztTr+anHIaBrDa9566humWovQlAfAcJasZq4P1xXi4cYaPkCOuRFfg/PKGMRsadTpRoVFXNwUn8e6c/Dthkz0kYtcmxXQaeCi7lUpuO7qMDtzNQiHVQ9/lSbAzCzdF7SaNoLaiwjFKiHimy4WjJ2E1MRGMZJ8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752586375; c=relaxed/simple; bh=E3G4eWJ8K+mtq6fjo5knmWRO1YYEvzwJVyURro6J1cg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WNKpyaopx0vlr5Q4ha5W9UoFzT/wAitUWQEP9NVzrxOHrkBDeKkS2GgfwZFta0UL+sGbkIKpMabuJ6AajkJD7bslsFt930HvTPQMFyIteOr79RYpYSOmeHnR7Ac9nnaFcMZjNhThB8KEraA1kvYWNz6Fy6JtzMKODdIzUdtvPvc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=ZKkrcKZy; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="ZKkrcKZy" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E9E3AC4CEE3; Tue, 15 Jul 2025 13:32:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1752586375; bh=E3G4eWJ8K+mtq6fjo5knmWRO1YYEvzwJVyURro6J1cg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZKkrcKZyHvCBV5lAmCWMYEpeY86tYi4I5d5YpkjF8pw49G8WkzmieIK9fId+7X735 rKvuw/hA3xpKwdLDHgRneB+gthazOiFHOc6JOCPl7eLjd6Hor1xvb/u33s2jRFscpP Z2dUujSTv9mSIL7xsBVXC64eEMPuw4o2Ozkz/99U= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Simon Horman , Wei Fang , Jakub Kicinski , Sasha Levin Subject: [PATCH 5.4 042/148] net: enetc: Correct endianness handling in _enetc_rd_reg64 Date: Tue, 15 Jul 2025 15:12:44 +0200 Message-ID: <20250715130802.000390010@linuxfoundation.org> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20250715130800.293690950@linuxfoundation.org> References: <20250715130800.293690950@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Simon Horman [ Upstream commit 7b515f35a911fdc31fbde6531828dcd6ae9803d3 ] enetc_hw.h provides two versions of _enetc_rd_reg64. One which simply calls ioread64() when available. And another that composes the 64-bit result from ioread32() calls. In the second case the code appears to assume that each ioread32() call returns a little-endian value. However both the shift and logical or used to compose the return value would not work correctly on big endian systems if this were the case. Moreover, this is inconsistent with the first case where the return value of ioread64() is assumed to be in host byte order. It appears that the correct approach is for both versions to treat the return value of ioread*() functions as being in host byte order. And this patch corrects the ioread32()-based version to do so. This is a bug but would only manifest on big endian systems that make use of the ioread32-based implementation of _enetc_rd_reg64. While all in-tree users of this driver are little endian and make use of the ioread64-based implementation of _enetc_rd_reg64. Thus, no in-tree user of this driver is affected by this bug. Flagged by Sparse. Compile tested only. Fixes: 16eb4c85c964 ("enetc: Add ethtool statistics") Closes: https://lore.kernel.org/all/AM9PR04MB850500D3FC24FE23DEFCEA158879A@AM9PR04MB8505.eurprd04.prod.outlook.com/ Signed-off-by: Simon Horman Reviewed-by: Wei Fang Link: https://patch.msgid.link/20250624-etnetc-le-v1-1-a73a95d96e4e@kernel.org Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- drivers/net/ethernet/freescale/enetc/enetc_hw.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/freescale/enetc/enetc_hw.h b/drivers/net/ethernet/freescale/enetc/enetc_hw.h index fac80831d5327..e99546b6a356c 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc_hw.h +++ b/drivers/net/ethernet/freescale/enetc/enetc_hw.h @@ -319,7 +319,7 @@ static inline u64 enetc_rd_reg64(void __iomem *reg) tmp = ioread32(reg + 4); } while (high != tmp); - return le64_to_cpu((__le64)high << 32 | low); + return (u64)high << 32 | low; } #endif -- 2.39.5