Linux PARISC architecture development
 help / color / mirror / Atom feed
From: Mikulas Patocka <mpatocka@redhat.com>
To: John David Anglin <dave.anglin@bell.net>,
	 John David Anglin <dave@parisc-linux.org>,
	 James Bottomley <James.Bottomley@HansenPartnership.com>,
	 Helge Deller <deller@gmx.de>
Cc: linux-parisc@vger.kernel.org
Subject: [PATCH] parisc: fix unaligned accesses in BPF
Date: Sat, 27 Jul 2024 12:11:02 +0200 (CEST)	[thread overview]
Message-ID: <1e96c3f-d45c-b128-907b-ca2fba5f6a2d@redhat.com> (raw)

There were spurious unaligned access warnings when calling BPF code.
Sometimes, the warnings were triggered with any incoming packet, making
the machine hard to use.

The reason for the warnings is this: on parisc64, pointers to functions
are not really pointers to functions, they are pointers to 16-byte
descriptor. The first 8 bytes of the descriptor is a pointer to the
function and the next 8 bytes of the descriptor is the content of the
"dp" register. This descriptor is generated in the function
bpf_jit_build_prologue.

The problem is that the function bpf_int_jit_compile advertises 4-byte
alignment when calling bpf_jit_binary_alloc, bpf_jit_binary_alloc
randomizes the returned array and if the array happens to be not aligned
on 8-byte boundary, the descriptor generated in bpf_jit_build_prologue is
also not aligned and this triggers the unaligned access warning.

Fix this by advertising 8-byte alignment on parisc64 when calling
bpf_jit_binary_alloc.

Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Cc: stable@vger.kernel.org

---
 arch/parisc/net/bpf_jit_core.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Index: linux-6.10/arch/parisc/net/bpf_jit_core.c
===================================================================
--- linux-6.10.orig/arch/parisc/net/bpf_jit_core.c	2024-07-23 20:35:34.000000000 +0200
+++ linux-6.10/arch/parisc/net/bpf_jit_core.c	2024-07-27 11:40:17.000000000 +0200
@@ -114,7 +114,7 @@ struct bpf_prog *bpf_int_jit_compile(str
 			jit_data->header =
 				bpf_jit_binary_alloc(prog_size + extable_size,
 						     &jit_data->image,
-						     sizeof(u32),
+						     sizeof(long),
 						     bpf_fill_ill_insns);
 			if (!jit_data->header) {
 				prog = orig_prog;


             reply	other threads:[~2024-07-27 10:11 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-27 10:11 Mikulas Patocka [this message]
2024-07-28 13:26 ` [PATCH] parisc: fix unaligned accesses in BPF Helge Deller

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=1e96c3f-d45c-b128-907b-ca2fba5f6a2d@redhat.com \
    --to=mpatocka@redhat.com \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=dave.anglin@bell.net \
    --cc=dave@parisc-linux.org \
    --cc=deller@gmx.de \
    --cc=linux-parisc@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox