* [PATCH] net: ravb: Fix dma_addr_t truncation in error case
@ 2024-01-13 4:22 Nikita Yushchenko
2024-01-13 8:31 ` Niklas Söderlund
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Nikita Yushchenko @ 2024-01-13 4:22 UTC (permalink / raw)
To: David S. Miller, Jakub Kicinski, Paolo Abeni
Cc: Sergey Shtylyov, Claudiu Beznea, Yoshihiro Shimoda, Wolfram Sang,
Uwe Kleine-König, netdev, linux-renesas-soc, linux-kernel,
Nikita Yushchenko
In ravb_start_xmit(), ravb driver uses u32 variable to store result of
dma_map_single() call. Since ravb hardware has 32-bit address fields in
descriptors, this works properly when mapping is successful - it is
platform's job to provide mapping addresses that fit into hardware
limitations.
However, in failure case dma_map_single() returns DMA_MAPPING_ERROR
constant that is 64-bit when dma_addr_t is 64-bit. Storing this constant
in u32 leads to truncation, and further call to dma_mapping_error()
fails to notice the error.
Fix that by storing result of dma_map_single() in a dma_addr_t
variable.
Fixes: c156633f1353 ("Renesas Ethernet AVB driver proper")
Signed-off-by: Nikita Yushchenko <nikita.yoush@cogentembedded.com>
---
drivers/net/ethernet/renesas/ravb_main.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
index 8649b3e90edb..0e3731f50fc2 100644
--- a/drivers/net/ethernet/renesas/ravb_main.c
+++ b/drivers/net/ethernet/renesas/ravb_main.c
@@ -1949,7 +1949,7 @@ static netdev_tx_t ravb_start_xmit(struct sk_buff *skb, struct net_device *ndev)
struct ravb_tstamp_skb *ts_skb;
struct ravb_tx_desc *desc;
unsigned long flags;
- u32 dma_addr;
+ dma_addr_t dma_addr;
void *buffer;
u32 entry;
u32 len;
--
2.39.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] net: ravb: Fix dma_addr_t truncation in error case
2024-01-13 4:22 [PATCH] net: ravb: Fix dma_addr_t truncation in error case Nikita Yushchenko
@ 2024-01-13 8:31 ` Niklas Söderlund
2024-01-13 9:43 ` Sergey Shtylyov
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Niklas Söderlund @ 2024-01-13 8:31 UTC (permalink / raw)
To: Nikita Yushchenko
Cc: David S. Miller, Jakub Kicinski, Paolo Abeni, Sergey Shtylyov,
Claudiu Beznea, Yoshihiro Shimoda, Wolfram Sang,
Uwe Kleine-König, netdev, linux-renesas-soc, linux-kernel
Hello Nikita,
Thanks for your patch.
On 2024-01-13 10:22:21 +0600, Nikita Yushchenko wrote:
> In ravb_start_xmit(), ravb driver uses u32 variable to store result of
> dma_map_single() call. Since ravb hardware has 32-bit address fields in
> descriptors, this works properly when mapping is successful - it is
> platform's job to provide mapping addresses that fit into hardware
> limitations.
>
> However, in failure case dma_map_single() returns DMA_MAPPING_ERROR
> constant that is 64-bit when dma_addr_t is 64-bit. Storing this constant
> in u32 leads to truncation, and further call to dma_mapping_error()
> fails to notice the error.
>
> Fix that by storing result of dma_map_single() in a dma_addr_t
> variable.
>
> Fixes: c156633f1353 ("Renesas Ethernet AVB driver proper")
> Signed-off-by: Nikita Yushchenko <nikita.yoush@cogentembedded.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
> ---
> drivers/net/ethernet/renesas/ravb_main.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
> index 8649b3e90edb..0e3731f50fc2 100644
> --- a/drivers/net/ethernet/renesas/ravb_main.c
> +++ b/drivers/net/ethernet/renesas/ravb_main.c
> @@ -1949,7 +1949,7 @@ static netdev_tx_t ravb_start_xmit(struct sk_buff *skb, struct net_device *ndev)
> struct ravb_tstamp_skb *ts_skb;
> struct ravb_tx_desc *desc;
> unsigned long flags;
> - u32 dma_addr;
> + dma_addr_t dma_addr;
> void *buffer;
> u32 entry;
> u32 len;
> --
> 2.39.2
>
>
--
Kind Regards,
Niklas Söderlund
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] net: ravb: Fix dma_addr_t truncation in error case
2024-01-13 4:22 [PATCH] net: ravb: Fix dma_addr_t truncation in error case Nikita Yushchenko
2024-01-13 8:31 ` Niklas Söderlund
@ 2024-01-13 9:43 ` Sergey Shtylyov
2024-01-13 21:03 ` Florian Fainelli
2024-01-14 16:50 ` patchwork-bot+netdevbpf
3 siblings, 0 replies; 5+ messages in thread
From: Sergey Shtylyov @ 2024-01-13 9:43 UTC (permalink / raw)
To: Nikita Yushchenko, David S. Miller, Jakub Kicinski, Paolo Abeni
Cc: Claudiu Beznea, Yoshihiro Shimoda, Wolfram Sang,
Uwe Kleine-König, netdev, linux-renesas-soc, linux-kernel
On 1/13/24 7:22 AM, Nikita Yushchenko wrote:
> In ravb_start_xmit(), ravb driver uses u32 variable to store result of
> dma_map_single() call. Since ravb hardware has 32-bit address fields in
> descriptors, this works properly when mapping is successful - it is
> platform's job to provide mapping addresses that fit into hardware
> limitations.
>
> However, in failure case dma_map_single() returns DMA_MAPPING_ERROR
> constant that is 64-bit when dma_addr_t is 64-bit. Storing this constant
> in u32 leads to truncation, and further call to dma_mapping_error()
> fails to notice the error.
>
> Fix that by storing result of dma_map_single() in a dma_addr_t
> variable.
>
> Fixes: c156633f1353 ("Renesas Ethernet AVB driver proper")
> Signed-off-by: Nikita Yushchenko <nikita.yoush@cogentembedded.com>
Reviewed-by: Sergey Shtylyov <s.shtylyov@omp.ru>
[...]
MBR, Sergey
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] net: ravb: Fix dma_addr_t truncation in error case
2024-01-13 4:22 [PATCH] net: ravb: Fix dma_addr_t truncation in error case Nikita Yushchenko
2024-01-13 8:31 ` Niklas Söderlund
2024-01-13 9:43 ` Sergey Shtylyov
@ 2024-01-13 21:03 ` Florian Fainelli
2024-01-14 16:50 ` patchwork-bot+netdevbpf
3 siblings, 0 replies; 5+ messages in thread
From: Florian Fainelli @ 2024-01-13 21:03 UTC (permalink / raw)
To: Nikita Yushchenko, David S. Miller, Jakub Kicinski, Paolo Abeni
Cc: Sergey Shtylyov, Claudiu Beznea, Yoshihiro Shimoda, Wolfram Sang,
Uwe Kleine-König, netdev, linux-renesas-soc, linux-kernel
On 1/12/2024 8:22 PM, Nikita Yushchenko wrote:
> In ravb_start_xmit(), ravb driver uses u32 variable to store result of
> dma_map_single() call. Since ravb hardware has 32-bit address fields in
> descriptors, this works properly when mapping is successful - it is
> platform's job to provide mapping addresses that fit into hardware
> limitations.
>
> However, in failure case dma_map_single() returns DMA_MAPPING_ERROR
> constant that is 64-bit when dma_addr_t is 64-bit. Storing this constant
> in u32 leads to truncation, and further call to dma_mapping_error()
> fails to notice the error.
>
> Fix that by storing result of dma_map_single() in a dma_addr_t
> variable.
>
> Fixes: c156633f1353 ("Renesas Ethernet AVB driver proper")
> Signed-off-by: Nikita Yushchenko <nikita.yoush@cogentembedded.com>
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
Nit: since this is a bug fix you should prefix your patches with "[PATCH
net]", see:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/maintainer-netdev.rst#n62
--
Florian
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] net: ravb: Fix dma_addr_t truncation in error case
2024-01-13 4:22 [PATCH] net: ravb: Fix dma_addr_t truncation in error case Nikita Yushchenko
` (2 preceding siblings ...)
2024-01-13 21:03 ` Florian Fainelli
@ 2024-01-14 16:50 ` patchwork-bot+netdevbpf
3 siblings, 0 replies; 5+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-01-14 16:50 UTC (permalink / raw)
To: Nikita Yushchenko
Cc: davem, kuba, pabeni, s.shtylyov, claudiu.beznea.uj,
yoshihiro.shimoda.uh, wsa+renesas, u.kleine-koenig, netdev,
linux-renesas-soc, linux-kernel
Hello:
This patch was applied to netdev/net.git (main)
by David S. Miller <davem@davemloft.net>:
On Sat, 13 Jan 2024 10:22:21 +0600 you wrote:
> In ravb_start_xmit(), ravb driver uses u32 variable to store result of
> dma_map_single() call. Since ravb hardware has 32-bit address fields in
> descriptors, this works properly when mapping is successful - it is
> platform's job to provide mapping addresses that fit into hardware
> limitations.
>
> However, in failure case dma_map_single() returns DMA_MAPPING_ERROR
> constant that is 64-bit when dma_addr_t is 64-bit. Storing this constant
> in u32 leads to truncation, and further call to dma_mapping_error()
> fails to notice the error.
>
> [...]
Here is the summary with links:
- net: ravb: Fix dma_addr_t truncation in error case
https://git.kernel.org/netdev/net/c/e327b2372bc0
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-01-14 16:50 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-13 4:22 [PATCH] net: ravb: Fix dma_addr_t truncation in error case Nikita Yushchenko
2024-01-13 8:31 ` Niklas Söderlund
2024-01-13 9:43 ` Sergey Shtylyov
2024-01-13 21:03 ` Florian Fainelli
2024-01-14 16:50 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).