Article View: linux.kernel.netdev
Article #23228[PATCH bpf-next v3 3/4] bpf: Align devmap values to 8 bytes
From: Tobias Philipp
Date: Thu, 26 Nov 2026 19:43
Date: Thu, 26 Nov 2026 19:43
44 lines
13515 bytes
13515 bytes
dev_map_lookup_elem() and dev_map_hash_lookup_elem() return &obj->val
as the map value. In struct bpf_dtab_netdev, val follows
"unsigned int idx" and is at offset 52 on 64-bit and 28 on 32-bit
architectures, so it is only 4-byte aligned.
devmap is read-only for BPF programs, but the verifier assumes that map
values are 8-byte aligned and accepts a 64-bit load-acquire at offset 0
of a struct bpf_devmap_val value on 64-bit architectures. The arm64 JIT
emits LDAR for it, which raises an alignment fault on CPUs without
FEAT_LSE2. The fault is not fixed up.
Mark val as __aligned(8). On 64-bit it moves to offset 56 and the size
of struct bpf_dtab_netdev stays 64 bytes. On 32-bit the verifier
rejects 64-bit load-acquire, so the misaligned value is harmless there.
Aligning it anyway keeps all map values 8-byte aligned and grows the
struct from 36 to 40 bytes. Entries are allocated with kmalloc, which
provides at least 8-byte alignment.
This patch was written with the help of an AI coding assistant
(Claude Opus 5.5).
Fixes: 880442305a39 ("bpf: Introduce load-acquire and store-release instructions")
Signed-off-by: Tobias Philipp <tphilipp@gmail.com>
---
kernel/bpf/devmap.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/kernel/bpf/devmap.c b/kernel/bpf/devmap.c
index 1b8f0d7f8..c92aa81e4 100644
--- a/kernel/bpf/devmap.c
+++ b/kernel/bpf/devmap.c
@@ -70,7 +70,8 @@ struct bpf_dtab_netdev {
struct bpf_prog *xdp_prog;
struct rcu_head rcu;
unsigned int idx;
- struct bpf_devmap_val val;
+ /* The verifier assumes that map values are 8-byte aligned */
+ struct bpf_devmap_val val __aligned(8);
};
struct bpf_dtab {
--
2.54.0 (Apple Git-157)
Technical Details
Message-ID:
<20261126194347.42466-4-tphilipp@gmail.com>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-372311-linux-kernel-netdev=dewy.ruReferences:
<20261126194347.42466-1-tphilipp@gmail.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-372311-linux-kernel-netdev=dewy.ru
From: tphilipp@gmail.com (Tobias Philipp)
Newsgroups: linux.kernel.netdev
Subject: [PATCH bpf-next v3 3/4] bpf: Align devmap values to 8 bytes
Date: Thu, 26 Nov 2026 20:43:46 +0100
Organization: Usenet Network
Message-ID: <20261126194347.42466-4-tphilipp@gmail.com>
References: <20261126194347.42466-1-tphilipp@gmail.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
logging-data="549174"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:7LBYB+TDVaUWEr6qmI/McwPYHeY= sha256:DSyHjV6Q7GxxPNitytr/RxxSNkAGrynjLGc1q05j4Nw=
sha1:cQlmDkAfDAkGN2ZBg53y+k1hFMg= sha256:PjM6nCl5kyOFldW2Qo9JRBS2UXjd+xbu7oU91RsVuQI=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
by mail.dewy.ru (Postfix) with ESMTP id 7089C125EF4; Thu, 26 Nov 2026 22:44:30 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.049
X-Spam-Status: No, score=-3.049 tagged_above=-9999 required=6.31
tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
DKIM_VALID_AU=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001,
FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249,
MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
SPF_PASS=-0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
header.d=gmail.com
X-Received: from mail.dewy.ru ([127.0.0.1])
by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
with ESMTP id jYTcoLn-2_He;
Thu, 26 Nov 2026 22:44:27 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-372311-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN>
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=gmail.com
X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
by mail.dewy.ru (Postfix) with ESMTPS id 74BAF125EF7; Thu, 26 Nov 2026 22:44:19 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
by sea.lore.kernel.org (Postfix) with ESMTP id 3E0B0377FE; Thu, 26 Nov 2026 19:44:06 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
t=1795722240;
b=KZkF4aXyeVmndGtGUESi9DOF4o4uw6VUK4SuuzATyaVXcm1p/kD5ed0EFlwWQL3HBg6B
uSrig3nOjWUc6Hq5bTFDJ2AZjjiBOUpe4EfW0fqt21Qio6CWggEML3yjrRXoXtNy/Jy6L
JXnKOEKHcFvWMPHBWzbSu7perEZ7gR2rAEmJzwG+nMI/xhuiKXOEG7UYLM9mMa2Kqqz97
hq8t34oPsZulFtFyNmy53/TZRw9tLlAuzrwrukKU+UO4iF+ginKUoten/r8ozupYjEM1B
50wblMmSQq2lP0/kXM8V+aNvR7+AivA5WIB4vtE+ndt5XN5UpGMQwAaa8Z+LJtN7RVA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1795722240;
h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:
X-Google-DKIM-Signature:X-Forwarded-Encrypted:X-Gm-Message-State:
X-Gm-Gg:X-Received:Received:From:To:Cc:Subject:Date:Message-ID:
X-Mailer:In-Reply-To:References:X-Mailing-List:List-Id:List-Post:
List-Help:List-Subscribe:List-Unsubscribe:List-Owner:Precedence:
MIME-Version:Content-Transfer-Encoding;
bh=cTlGczEpqnTOct8RsrZ/gODErZ8owqpFldUbfmAHspI=;
b=i3Hqu6tr4Od1UVKLC07RzGeqXWFRmJmRMtOdUTYBuAjWGSEBy8TWw2XwUBeDYQRYGWLs
4m2DYEHF5xQew3P26LztuCclM/0IojKlZY48mhUDpUCbA+dqYiF7DC0fy5mfIEOpVsjF1
HGSVp5RyhezJQGk7wP+fjSjaVMFNUkE/nBJYq060pH5mSLF2yzREKM2lMSl2htkkbEESU
rqGAs5G2oq/0AtaH+PX5CyNnbrVUiSUaHJpszdvmwiQT31qS/kOIgx7kp0VOWvRq/dm6K
YtquZypCcJBkmamEKkEU8O2kkBmD3B4ZvbxADaPjHOVWgIVjFgJ1Bj+um0uDbiaQtVw==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org;
dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b="D/RCqXQS";
dmarc=pass header.from=gmail.com;
spf=pass smtp.mailfrom=gmail.com;
arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
by smtp.subspace.kernel.org (Postfix) with ESMTP id C6DA7606A6B3;
Thu, 26 Nov 2026 19:44:00 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=D/RCqXQS
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.221.51
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
t=1795722240;
b=vN8qPZL2t6kVe4W4OXOo5Nybuo33swCTns4tDhDdHa4AgayIN5baD2sNcJjlJW56ppHb
b9FFADmA0l6AbwlwRmQuuKDfZfqoWoDO8nZIwvp+bGT4912LvecxJKsBW6I8BtiRsNCpp
o9VwoiKtYm2UrXbhhOwfc4ep9JF/5GqEQqwV4sE6kDPFJO0QyO1J9MN1nKzEUxwA7cfA/
zlshrE3Ma3gU8bntIcyQKtYceg3aE/1Vtz3sYvgpfR4njiv2MhKFQtpGSiUq0sRLOgDsQ
CZBT89ranU2ZCK5w5wKG9zSS5b6UqBOrr+AsyIdMFZfwxVpumqMVHq15Vk8ls6G/Fhw==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1795722240;
h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature:
X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received:
From:To:Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To:References:
MIME-Version:Content-Transfer-Encoding;
bh=cTlGczEpqnTOct8RsrZ/gODErZ8owqpFldUbfmAHspI=;
b=ibeXlxAwPbKIb6Gkg2GHqyDGeBsCWMmqCoe40GyBljxVRBuRJcODULJIvF26Uhwv2J8I
dZZLXjUHZX9Y0oNvBba96E/IYbIvr6way82diFHvmEEN3KO6HOidH4OdOJiazQWHbsG2E
TC9VMTlySWZKFpuzATFJxZ4+yzhePbUh+zxessjGOYWbrUbnEC7wYAexTYciktBBROAsp
sKUjRMgp6L8anHKE4iZe89W3cN/jZ6nzWUHCoGoUYT/NB90AvGVGCB5j0j8R9LvejdIwS
yBRmc8aPH80MGyXmWdWgQ4zLLF/xjEgvG0jfsViBnsiriLyWk/HbdnEUIVS1t+ts5eA==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org;
dmarc=pass header.from=gmail.com;
spf=pass smtp.mailfrom=gmail.com;
dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b="D/RCqXQS";
arc=none smtp.remote-ip=209.85.221.51
X-Received: from mail-wr1-f51.google.com (mail-wr1-f51.google.com [209.85.221.51])
(using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)
key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
(No client certificate requested)
by smtp.subspace.kernel.org (Postfix) with ESMTPS id A24BF606A681
for <netdev@vger.kernel.org>; Thu, 26 Nov 2026 19:43:59 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org A24BF606A681
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com
X-Received: by mail-wr1-f51.google.com with SMTP id ffacd0b85a97d-4a3e706b5dfso4653526f8f.2
for <netdev@vger.kernel.org>; Thu, 26 Nov 2026 11:43:59 -0800 (PST)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20260707; t=1795722238; x=1796327038; darn=vger.kernel.org;
h=content-transfer-encoding:mime-version:references:in-reply-to
:message-id:date:subject:cc:to:from:from:to:cc:subject:date
:message-id:reply-to:content-type;
bh=cTlGczEpqnTOct8RsrZ/gODErZ8owqpFldUbfmAHspI=;
b=D/RCqXQS4UeN6v20Z+VlBVJK/ZZX/cCGhIw/ilwIJBaJwk1qthCZOB7Hg/2I7i+4b3
gXFQ4bI37t5xPPDFsxIZCp3undzL8liJl1dhk9x26M+SkiFQiV+7Vrud1K9saTD8x0sH
UQMiTIPG1dCkfQb0PxR6z9D5p8o7O1YzP64p0tMKDD4z4PSjcjwQijNF5MccAC+MyA1q
gLfW5lTkUooix1E3K7bTU9lw8/aq1xp6zPR8L2TbturBUIa7a3UOJhiI/2hrCU8Srmvz
xoxkVJVoMSNteiXv1w98CN7QNYMr+TYloJe8vE9eCeJR5FzLV7xl1p9CdamhuhxKADyZ
bRpQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20260707; t=1795722238; x=1796327038;
h=content-transfer-encoding:mime-version:references:in-reply-to
:message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from
:to:cc:subject:date:message-id:reply-to:content-type;
bh=cTlGczEpqnTOct8RsrZ/gODErZ8owqpFldUbfmAHspI=;
b=U6XrqriD/kg9Nb+8/9C9HwDsKb2y8Q+AEJfCPhppXTWSVBnCD+kcvp9fSC83TGhYVD
uoTeFUiqpo8ORS6PNazSNnyGCsfGZM5gkmg1E644yPH4ytVM4biVQwko8M+zbKmlAsNP
ak8ZZjo16Uc2SS0YBCHaQVIf4QwW341qa9c9y/JUINwLd3xCgP/ekM4NtfdZdzx82d0u
/7iI+lKec4l1+pnv2yDHJhiSymu6bO3NQvyCP6ISYwxtBAk9uSs17tx8skxF+sPUFd88
fmRR3t7xlwtKT5Tvh0BMN6BaFym5QjfUZtvY5EPXPied/aQl+lZRnqKXnjtMf7TnFhUX
I/gg==
X-Forwarded-Encrypted: i=1; AL+hErFYzTph/572ZBlkk8D0Wv5gOQ+pexW/CfyYvwTPznM+3vXMLA/lOCu7JIbdkIKuLdlw0H4BfYc=@vger.kernel.org
X-Gm-Message-State: APuU4Z8fFSuyt+J7gCylZnTuibJ8P4zLca3WhH1vdke4DL4I4e7HJ3hz
BZRbp81DimNmHfKa4XSBFdLVjVpy/3vV3Sw2hDHrD+TzSwlu7UI4xpM=
X-Gm-Gg: AZFdTZeZHCFOFXHwhaSSQOS6FwCWq59rSLc5x0S7EGoNRTnJXcrIDxAXyu94HtzGKfK
Khpuxh8/V+98iETKwRjsf7eMt7xYwKJOcFQYyt6fWSXyG6TWWiZrgIEVlybYo5nauzvPYCnTviR
4sy9+373wz6UGyQfpOelqVjq7vQiWvojpmcA+y2J+ETTbf+GPP1l8VMEEMfKqL3Ek5ufHzGL/Ag
dw9oycOZGVIFetq5yfxWOhGlJy1qS0nAKRfo8RZDdJEaxd6513BHpWDKU2Viauqf0kX4HkWMEt3
2OGXynphbrIYED2DC/uTxK1E2weFF+W8AyFQxJPQJ1loNIzmvUJwUfoHNZsd3EtJPEPh6WKcMmo
DiVFX7fL/39tIewz2mVd7mhYXnZDS/7mHVGiJwafh1nHwRQAUhZ1W+rG6iRVussk+zTWDl6C5UL
Pcu1TNH1yvXKiphzKKs6xscIkxsPNl3MVdfNj/3Whp7ar5IMgf8ZLREKVuwg7lzivYQ39nW/CY9
D9xshi/oj1tQ1uNyePzy33jVTVdOGtLOKHbBarAwJiydc4VlqwuzIeUywiOnwCIFBgNKq9gWEGj
SVgoXvtyylSeQqzSn5Y2TOK8xXm4b4LlqfRTUpv04z0hxL58Ug+CRBPqm8srCUo6rj6EyHtUK7H
dPH7Z+mleMj+Nvw3SIiu9xncZtMCs55jSK/vPSQ9ghB6JIvGlM8+GzakFIOKWJYmpJ4TuY+b1Q7
fqfmShunIHb+dJq5eOY1JFIZbjxEAXMYdl
X-Received: by 2002:a05:6000:25c2:b0:4a6:7781:b064 with SMTP id ffacd0b85a97d-4abb51457e8mr54433934f8f.31.1795722237966;
Thu, 26 Nov 2026 11:43:57 -0800 (PST)
X-Received: from localhost.localdomain (dynamic-2a02-3100-2317-a900-4811-d431-309f-6626.310.pool.telefonica.de. [2a02:3100:2317:a900:4811:d431:309f:6626])
by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4ab658e2d60sm43663924f8f.3.2026.11.26.11.43.56
(version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256);
Thu, 26 Nov 2026 11:43:57 -0800 (PST)
X-Cc: Tobias Philipp <tphilipp@gmail.com>,
Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Andrii Nakryiko <andrii@kernel.org>,
Martin KaFai Lau <martin.lau@linux.dev>,
Eduard Zingerman <eddyz87@gmail.com>,
Kumar Kartikeya Dwivedi <memxor@gmail.com>,
Song Liu <song@kernel.org>,
Yonghong Song <yonghong.song@linux.dev>,
Jiri Olsa <jolsa@kernel.org>,
John Fastabend <john.fastabend@gmail.com>,
Stanislav Fomichev <sdf@fomichev.me>,
Emil Tsalapatis <emil@etsalapatis.com>,
Ihor Solodrai <ihor.solodrai@linux.dev>,
Jesper Dangaard Brouer <hawk@kernel.org>,
"David S. Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>,
Shuah Khan <shuah@kernel.org>,
Felix Fietkau <nbd@nbd.name>,
Thibaut VARΓNE <hacks@slashdirt.org>,
Stijn Tintel <stijn@linux-ipv6.be>,
Daniel Mack <daniel@zonque.org>,
netdev@vger.kernel.org,
linux-kselftest@vger.kernel.org,
linux-kernel@vger.kernel.org
X-Mailer: git-send-email 2.54.0
X-In-Reply-To: <20261126194347.42466-1-tphilipp@gmail.com>
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list