* [PULL] Net patches
@ 2022-08-09 9:08 Jason Wang
2022-08-09 9:08 ` [PULL] hw/net/rocker: Avoid undefined shifts with more than 31 ports Jason Wang
2022-08-09 16:43 ` [PULL] Net patches Richard Henderson
0 siblings, 2 replies; 3+ messages in thread
From: Jason Wang @ 2022-08-09 9:08 UTC (permalink / raw)
To: peter.maydell, qemu-devel; +Cc: Jason Wang
The following changes since commit ca5f3d4df1b47d7f66a109cdb504e83dfd7ec433:
Merge tag 'pull-la-20220808' of https://gitlab.com/rth7680/qemu into staging (2022-08-08 19:51:12 -0700)
are available in the git repository at:
https://github.com/jasowang/qemu.git tags/net-pull-request
for you to fetch changes up to 7cf745dd9c25f0740dc1009598b58dd8dd989876:
hw/net/rocker: Avoid undefined shifts with more than 31 ports (2022-08-09 17:02:18 +0800)
----------------------------------------------------------------
----------------------------------------------------------------
Peter Maydell (1):
hw/net/rocker: Avoid undefined shifts with more than 31 ports
hw/net/rocker/rocker.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PULL] hw/net/rocker: Avoid undefined shifts with more than 31 ports
2022-08-09 9:08 [PULL] Net patches Jason Wang
@ 2022-08-09 9:08 ` Jason Wang
2022-08-09 16:43 ` [PULL] Net patches Richard Henderson
1 sibling, 0 replies; 3+ messages in thread
From: Jason Wang @ 2022-08-09 9:08 UTC (permalink / raw)
To: peter.maydell, qemu-devel; +Cc: Richard Henderson, Jason Wang
From: Peter Maydell <peter.maydell@linaro.org>
In rocker_port_phys_link_status() and rocker_port_phys_enable_read()
we construct a 64-bit value with one bit per front-panel port.
However we accidentally do the shift as 32-bit arithmetic, which
means that if there are more than 31 front-panel ports this is
undefined behaviour.
Fix the problem by ensuring we use 64-bit arithmetic for the whole
calculation. (We won't ever shift off the 64-bit value because
ROCKER_FP_PORTS_MAX is 62.)
Resolves: Coverity CID 1487121, 1487160
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Jason Wang <jasowang@redhat.com>
---
hw/net/rocker/rocker.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/hw/net/rocker/rocker.c b/hw/net/rocker/rocker.c
index 31f2340..d8f3f16 100644
--- a/hw/net/rocker/rocker.c
+++ b/hw/net/rocker/rocker.c
@@ -1010,7 +1010,7 @@ static uint64_t rocker_port_phys_link_status(Rocker *r)
FpPort *port = r->fp_port[i];
if (fp_port_get_link_up(port)) {
- status |= 1 << (i + 1);
+ status |= 1ULL << (i + 1);
}
}
return status;
@@ -1025,7 +1025,7 @@ static uint64_t rocker_port_phys_enable_read(Rocker *r)
FpPort *port = r->fp_port[i];
if (fp_port_enabled(port)) {
- ret |= 1 << (i + 1);
+ ret |= 1ULL << (i + 1);
}
}
return ret;
--
2.7.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PULL] Net patches
2022-08-09 9:08 [PULL] Net patches Jason Wang
2022-08-09 9:08 ` [PULL] hw/net/rocker: Avoid undefined shifts with more than 31 ports Jason Wang
@ 2022-08-09 16:43 ` Richard Henderson
1 sibling, 0 replies; 3+ messages in thread
From: Richard Henderson @ 2022-08-09 16:43 UTC (permalink / raw)
To: Jason Wang, peter.maydell, qemu-devel
On 8/9/22 02:08, Jason Wang wrote:
> The following changes since commit ca5f3d4df1b47d7f66a109cdb504e83dfd7ec433:
>
> Merge tag 'pull-la-20220808' of https://gitlab.com/rth7680/qemu into staging (2022-08-08 19:51:12 -0700)
>
> are available in the git repository at:
>
> https://github.com/jasowang/qemu.git tags/net-pull-request
>
> for you to fetch changes up to 7cf745dd9c25f0740dc1009598b58dd8dd989876:
>
> hw/net/rocker: Avoid undefined shifts with more than 31 ports (2022-08-09 17:02:18 +0800)
>
> ----------------------------------------------------------------
>
> ----------------------------------------------------------------
> Peter Maydell (1):
> hw/net/rocker: Avoid undefined shifts with more than 31 ports
Applied, thanks. Please update https://wiki.qemu.org/ChangeLog/7.1 as appropriate.
r~
>
> hw/net/rocker/rocker.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-08-09 16:44 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-08-09 9:08 [PULL] Net patches Jason Wang
2022-08-09 9:08 ` [PULL] hw/net/rocker: Avoid undefined shifts with more than 31 ports Jason Wang
2022-08-09 16:43 ` [PULL] Net patches Richard Henderson
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).