From nobody Thu Mar 5 10:52:28 2026 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4fRRFS5Cf7z6SnjR for ; Thu, 05 Mar 2026 10:52:28 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R12" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4fRRFS3qR6z3w8Y for ; Thu, 05 Mar 2026 10:52:28 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1772707948; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=P1z8RyX/1o9lJGVXNvkGvh3Idm5JgmVL28p6hW/AMOw=; b=cIVh4Pzd8u8N3EUqev1odeOS9nK1p4erm8bcUhMzOjMNq4fLWPlIP3d9Ji4f4hxMQBdtW3 EK8nwdEBugeUlORYytFknBy8/aLLojjzs1bDwbUUS6TZQ7QtsWv6Ts1Ld53o5gisxy6aX6 cv94nf9pioEZA+cwI4gN05IacL4qOjhQTjYW73pD0bVJKvJaAgVM4j198Xm9/Wiq/Q7Cz6 wh/q407z9lxaMHEU5WLRxolxJ9ofxxFfL5LaLRJRPIywI0BiVYxkFwuXOYTdqZs+1lWp0T lCQeuLy0WeDR3SCFCASeFKxR9t2YGH9y+0H1XRoIzbuPj68s16UxLq8hrvhx7A== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1772707948; a=rsa-sha256; cv=none; b=GDa3Qm9QZiBd0V/kHl73E2KOvN1klScqpFatt0wjFPLl9lmwJ6WQmUlLsAK/jJ3bCgmXXb T2lfvBaJHJ4dD0UDMZf7KORoI5LMuWRcA1wfqD8cLi1D4cCbsJJgUxbBUnEHq+vNDirK3r w36ngdn3SZFiSe0apvRFn2c0VZfID40crZhquG0UEn8OnMgWEXjpMwZ+fg+Ep0oyFaIaZO bH2YRiE5YAHAB/t6igZcUA9qAARkxjqcgaxLO48U4JHLTEzj6HrKwi7f9VEIWskeWA+lgP tcsappA3bz5aEkeJzNy9CTj/GUNVJiM//2Cf+EmQCaydqwm6QNtui+3hQrmPWw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1772707948; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=P1z8RyX/1o9lJGVXNvkGvh3Idm5JgmVL28p6hW/AMOw=; b=fyCWS8XZqd7IjYoHmrtvJ1FgmUB20Xz78yH4fM6nniKLV9ojKGJhZm0dhgSKZcaFWL1Bir F5zKBSjBJIJMC0Kc5/jRwCHDtwoXVoQEP6DXXFUPN+OhC/U9lAr5GoIDA0s6Mpkgvk1pG6 xeMPoZSbv3AqVekRrlTkPnxMddOPd9LniqbsVYd8WvVU/iOEE2lG+PlbvkaiCTojUAWdA8 PoK0mZsrMoM9e3JpmD+nVrWMq9SW9w+DslMKx43cwcTKpHILwpiAakrUs/CWLg9Cj/p+gx MbIkca4eX5R2BS5CrAhQEliPujlRfmPNUzQzzcTOPYyH+XwdvKo+gnBs7zYXyQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4fRRFS3JfvzZT8 for ; Thu, 05 Mar 2026 10:52:28 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 3e230 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Thu, 05 Mar 2026 10:52:28 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Zhenlei Huang Subject: git: 973d607b284b - stable/15 - vnet: Ensure the space allocated by vnet_data_alloc() is sufficent aligned List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: zlei X-Git-Repository: src X-Git-Refname: refs/heads/stable/15 X-Git-Reftype: branch X-Git-Commit: 973d607b284ba68e63f0386af44c28bfde15add2 Auto-Submitted: auto-generated Date: Thu, 05 Mar 2026 10:52:28 +0000 Message-Id: <69a9606c.3e230.3cba27dc@gitrepo.freebsd.org> The branch stable/15 has been updated by zlei: URL: https://cgit.FreeBSD.org/src/commit/?id=973d607b284ba68e63f0386af44c28bfde15add2 commit 973d607b284ba68e63f0386af44c28bfde15add2 Author: Zhenlei Huang AuthorDate: 2026-02-28 11:35:42 +0000 Commit: Zhenlei Huang CommitDate: 2026-03-05 10:51:20 +0000 vnet: Ensure the space allocated by vnet_data_alloc() is sufficent aligned Some 32-bit architectures, e.g., armv7, require strict 8-byte alignment while doing atomic 64-bit access. Hence aligning to the pointer type (4-byte alignment) does not meet the requirement on those architectures. Make the space allocated by vnet_data_alloc() sufficent aligned to avoid unaligned access. PR: 265639 Diagnosed by: markj Reviewed by: jhb, markj Co-authored-by: jhb MFC after: 5 days Differential Revision: https://reviews.freebsd.org/D55560 (cherry picked from commit 32beb3ae71cb320dbe4190a01c036943d99083b3) --- sys/net/vnet.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/sys/net/vnet.c b/sys/net/vnet.c index a2b827052dd3..5ef68d11227a 100644 --- a/sys/net/vnet.c +++ b/sys/net/vnet.c @@ -171,11 +171,17 @@ static MALLOC_DEFINE(M_VNET_DATA, "vnet_data", "VNET data"); #define VNET_MODMIN (8 * PAGE_SIZE) #define VNET_SIZE roundup2(VNET_BYTES, PAGE_SIZE) +/* + * Ensure space allocated by vnet_data_alloc() is suitably aligned for any + * object. + */ +#define VNET_DATAALIGN _Alignof(__max_align_t) + /* * Space to store virtualized global variables from loadable kernel modules, * and the free list to manage it. */ -VNET_DEFINE_STATIC(char, modspace[VNET_MODMIN] __aligned(__alignof(void *))); +VNET_DEFINE_STATIC(char, modspace[VNET_MODMIN] __aligned(VNET_DATAALIGN)); /* * A copy of the initial values of all virtualized global variables. @@ -385,7 +391,7 @@ vnet_data_alloc(int size) void *s; s = NULL; - size = roundup2(size, sizeof(void *)); + size = roundup2(size, VNET_DATAALIGN); sx_xlock(&vnet_data_free_lock); TAILQ_FOREACH(df, &vnet_data_free_head, vnd_link) { if (df->vnd_len < size) @@ -403,6 +409,8 @@ vnet_data_alloc(int size) } sx_xunlock(&vnet_data_free_lock); + KASSERT(((uintptr_t)s & (VNET_DATAALIGN - 1)) == 0, + ("unaligned vnet alloc %p", s)); return (s); } @@ -417,7 +425,7 @@ vnet_data_free(void *start_arg, int size) uintptr_t start; uintptr_t end; - size = roundup2(size, sizeof(void *)); + size = roundup2(size, VNET_DATAALIGN); start = (uintptr_t)start_arg; end = start + size; /*