linux/include/soc/fsl
Vladimir Oltean a12fcef429 soc: fsl_qbman: use be16_to_cpu() in qm_sg_entry_get_off()
struct qm_sg_entry :: offset is a 13-bit field, declared as __be16.

When using be32_to_cpu(), a wrong value will be calculated on little
endian systems (Arm), because type promotion from 16-bit to 32-bit,
which is done before the byte swap and always in the CPU native
endianness, changes the value of the scatter/gather list entry offset in
big-endian interpretation (adds two zero bytes in the LSB interpretation).
The result of the byte swap is ANDed with GENMASK(12, 0), so the result
is always zero, because only those bytes added by type promotion remain
after the application of the bit mask.

The impact of the bug is that scatter/gather frames with a non-zero
offset into the buffer are treated by the driver as if they had a zero
offset. This is all in theory, because in practice, qm_sg_entry_get_off()
has a single caller, where the bug is inconsequential, because at that
call site the buffer offset will always be zero, as will be explained in
the subsequent change.

Flagged by sparse:

warning: cast to restricted __be32
warning: cast from restricted __be16

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Reviewed-by: Breno Leitao <leitao@debian.org>
Acked-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Acked-by: Madalin Bucur <madalin.bucur@oss.nxp.com>
Link: https://patch.msgid.link/20241029164317.50182-2-vladimir.oltean@nxp.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2024-11-04 18:44:43 -08:00
..
qe soc: fsl: qe: Add missing PUSHSCHED command 2024-09-03 07:49:20 +02:00
bman.h soc: fsl: qbman_portals: add APIs to retrieve the probing status 2019-05-20 14:28:16 -05:00
caam-blob.h crypto: caam - add in-kernel interface for blob generator 2022-05-23 18:47:50 +03:00
cpm.h soc: fsl: move cpm.h from powerpc/include/asm to include/soc/fsl 2019-12-09 13:54:34 -06:00
dcp.h crypto: mxs-dcp: Add support for hardware-bound keys 2024-05-09 18:29:03 +03:00
dpaa2-fd.h soc: fsl: Replace kernel.h with the necessary inclusions 2022-02-18 17:11:17 -06:00
dpaa2-global.h soc: fsl: dpio: add congestion notification support 2018-09-21 13:24:50 +08:00
dpaa2-io.h soc: fsl: dpio: add Net DIM integration 2021-10-15 14:32:41 +01:00
qman.h soc: fsl_qbman: use be16_to_cpu() in qm_sg_entry_get_off() 2024-11-04 18:44:43 -08:00