From: Christophe Leroy <christophe.leroy@csgroup.eu>
To: Vladimir Oltean <vladimir.oltean@nxp.com>, netdev@vger.kernel.org
Cc: "David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Breno Leitao <leitao@debian.org>,
Madalin Bucur <madalin.bucur@nxp.com>,
Ioana Ciornei <ioana.ciornei@nxp.com>,
Radu Bulie <radu-andrei.bulie@nxp.com>,
Sean Anderson <sean.anderson@linux.dev>,
linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH net-next 1/3] soc: fsl_qbman: use be16_to_cpu() in qm_sg_entry_get_off()
Date: Mon, 4 Nov 2024 15:33:03 +0100 [thread overview]
Message-ID: <34c972b7-ba53-46ba-ada9-df741bc21e47@csgroup.eu> (raw)
In-Reply-To: <20241029164317.50182-2-vladimir.oltean@nxp.com>
Le 29/10/2024 à 17:43, Vladimir Oltean a écrit :
> 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>
Acked-by: Christophe Leroy <christophe.leroy@csgroup.eu>
> ---
> include/soc/fsl/qman.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/include/soc/fsl/qman.h b/include/soc/fsl/qman.h
> index 0d3d6beb7fdb..7f7a4932d7f1 100644
> --- a/include/soc/fsl/qman.h
> +++ b/include/soc/fsl/qman.h
> @@ -242,7 +242,7 @@ static inline void qm_sg_entry_set_f(struct qm_sg_entry *sg, int len)
>
> static inline int qm_sg_entry_get_off(const struct qm_sg_entry *sg)
> {
> - return be32_to_cpu(sg->offset) & QM_SG_OFF_MASK;
> + return be16_to_cpu(sg->offset) & QM_SG_OFF_MASK;
> }
>
> /* "Frame Dequeue Response" */
next prev parent reply other threads:[~2024-11-04 14:50 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-29 16:43 [PATCH net-next 0/3] Fix sparse warnings in dpaa_eth driver Vladimir Oltean
2024-10-29 16:43 ` [PATCH net-next 1/3] soc: fsl_qbman: use be16_to_cpu() in qm_sg_entry_get_off() Vladimir Oltean
2024-10-30 10:39 ` Breno Leitao
2024-11-04 14:33 ` Christophe Leroy [this message]
2024-10-29 16:43 ` [PATCH net-next 2/3] net: dpaa_eth: add assertions about SGT entry offsets in sg_fd_to_skb() Vladimir Oltean
2024-10-30 14:27 ` Vladimir Oltean
2024-11-04 14:34 ` Christophe Leroy
2024-10-29 16:43 ` [PATCH net-next 3/3] net: dpaa_eth: extract hash using __be32 pointer in rx_default_dqrr() Vladimir Oltean
2024-10-30 10:35 ` Breno Leitao
2024-11-04 14:35 ` Christophe Leroy
2024-10-30 13:39 ` [PATCH net-next 0/3] Fix sparse warnings in dpaa_eth driver Madalin Bucur (OSS)
2024-11-05 3:10 ` patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=34c972b7-ba53-46ba-ada9-df741bc21e47@csgroup.eu \
--to=christophe.leroy@csgroup.eu \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=ioana.ciornei@nxp.com \
--cc=kuba@kernel.org \
--cc=leitao@debian.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=madalin.bucur@nxp.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=radu-andrei.bulie@nxp.com \
--cc=sean.anderson@linux.dev \
--cc=vladimir.oltean@nxp.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®