All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jason Wang <jasowang@redhat.com>
To: qemu-devel@nongnu.org, peter.maydell@linaro.org
Cc: Nick Briggs <nicholas.h.briggs@gmail.com>,
	Jason Wang <jasowang@redhat.com>
Subject: [PULL 3/8] Avoid unaligned fetch in ladr_match()
Date: Tue, 12 Mar 2024 19:36:37 +0800	[thread overview]
Message-ID: <20240312113642.36862-4-jasowang@redhat.com> (raw)
In-Reply-To: <20240312113642.36862-1-jasowang@redhat.com>

From: Nick Briggs <nicholas.h.briggs@gmail.com>

There is no guarantee that the PCNetState is allocated such that
csr[8] is allocated on an 8-byte boundary.  Since not all hosts are
capable of unaligned fetches the 16-bit elements need to be fetched
individually to avoid a potential fault.  Closes issue #2143

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2143
Signed-off-by: Nick Briggs <nicholas.h.briggs@gmail.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Jason Wang <jasowang@redhat.com>
---
 hw/net/pcnet.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/net/pcnet.c b/hw/net/pcnet.c
index 494eab8479..ad675ab29d 100644
--- a/hw/net/pcnet.c
+++ b/hw/net/pcnet.c
@@ -632,7 +632,7 @@ static inline int ladr_match(PCNetState *s, const uint8_t *buf, int size)
 {
     struct qemu_ether_header *hdr = (void *)buf;
     if ((*(hdr->ether_dhost)&0x01) &&
-        ((uint64_t *)&s->csr[8])[0] != 0LL) {
+        (s->csr[8] | s->csr[9] | s->csr[10] | s->csr[11]) != 0) {
         uint8_t ladr[8] = {
             s->csr[8] & 0xff, s->csr[8] >> 8,
             s->csr[9] & 0xff, s->csr[9] >> 8,
-- 
2.42.0



  parent reply	other threads:[~2024-03-12 11:38 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-12 11:36 [PULL 0/8] Net patches Jason Wang
2024-03-12 11:36 ` [PULL 1/8] igb: fix link state on resume Jason Wang
2024-03-12 11:36 ` [PULL 2/8] e1000e: " Jason Wang
2024-03-12 11:36 ` Jason Wang [this message]
2024-03-12 11:36 ` [PULL 4/8] ebpf: Added eBPF map update through mmap Jason Wang
2024-03-12 11:36 ` [PULL 5/8] ebpf: Added eBPF initialization by fds Jason Wang
2024-03-12 11:36 ` [PULL 6/8] virtio-net: Added property to load eBPF RSS with fds Jason Wang
2024-03-12 11:36 ` [PULL 7/8] qmp: Added new command to retrieve eBPF blob Jason Wang
2024-03-12 11:36 ` [PULL 8/8] ebpf: Updated eBPF program and skeleton Jason Wang
2024-03-12 16:29 ` [PULL 0/8] Net patches Peter Maydell
2024-03-12 17:56 ` Michael Tokarev
2024-03-13  6:43   ` Jason Wang

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=20240312113642.36862-4-jasowang@redhat.com \
    --to=jasowang@redhat.com \
    --cc=nicholas.h.briggs@gmail.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.