From nobody Sat Feb 28 11:36:25 2026 X-Original-To: dev-commits-src-main@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 4fNNST4lCkz6T3ZN for ; Sat, 28 Feb 2026 11:36:25 +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 4fNNST3zfwz4Pp1 for ; Sat, 28 Feb 2026 11:36:25 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1772278585; 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=PUq2ZSw6zOlRj0JTzReVJf6LbqLiH+tLv3pwwrC0WGg=; b=pKGA0Xhrs1wjyFdGA+UoAlIFvMi/DQ1MohgostuC4huDo0tkcII6mD2UZHuM9YR5biY4wu CxJPXnoKNAJQ9DDkoGxdqH0fn0jTlKqHUHLW+PUffQgBhzgaN+d25xEupnv+hAT6qrXZhF rrK4LSt2lfA96Ndws4OkYO/cI1/d0HCQgjRFUIxaj8XasL7RN4QcQftjmHGcMqGZ4/8k9f TCjjqnFpMVuEoB0pX/A3exft0pgPxea4zCZ6sV3nT9PkhtoqcXQ5tRvlN1/sBjHcvBCz/M BsjGtHYGFbUn7IwWnBTEcAYAOhdjNo8jIIkWQfLNk01vV4S/tswKGQgqqLuhhQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1772278585; a=rsa-sha256; cv=none; b=I6bK0GV3ssF5w+yVNNbhaFQS8+uJ84nlx4uT/ixlEOZhYpZjDhbv8rSt5F5vDQE6C+2dxj JXN8/rcpo/6tWfwzpp6VupGT+dUBADqOtll556jY5DYV2qbS+SFnXrEa0InwaFNwrBDNkT M9IC5bUsRRJ+WRnq5WrWScDwGqtuc6SNkgtcZ9KtFeGqxULw4ppCofKunRebGBcN+EbNil 1uhl64xJ0vvucQTklajQ6VrCFvPxq5zWieGIdZ5qTOmH+bcTb4jTvDeiXo9PkOkkFAlYen jeEIZc2ZEJ2ZUICvQptP0NUWcnQVWSy07/Ocy/fnmppebpMrwWFe7GAEPz8YIg== 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=1772278585; 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=PUq2ZSw6zOlRj0JTzReVJf6LbqLiH+tLv3pwwrC0WGg=; b=YsEf7cLRCwzr/lfCSaH880fqDS3gVNJh/8LwOm5sC/4hggIMs8CovCvzuSOpurm2toQO0R uVwpbI5k9wF/tC1shsFuCpr2k557+K0mZ37iwfPGFdtTJpMMHcP38+0ipCtrsxDlrGI91a pUie/VN1PmWGyv+EJORRimWJfYtO2ci0q6DLphkVYx97kMqfk2yDneYYpMKUzSMB0WqEd0 W8RNUM0EsW0Ni2pA93XwaHzWQDDwkUUcD8aRHQSCEJ5xefb6K4x94KD0lhQiASAiXfSQxK BD7MmPHLPd1ckUq2dFz8+TXhBqgklE/19yKgDx2EH5FkQqa8HrDI+xNiqZk2YQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4fNNST3ZSrz11sV for ; Sat, 28 Feb 2026 11:36:25 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 3a904 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Sat, 28 Feb 2026 11:36:25 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Zhenlei Huang Subject: git: 32beb3ae71cb - main - vnet: Ensure the space allocated by vnet_data_alloc() is sufficent aligned List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@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/main X-Git-Reftype: branch X-Git-Commit: 32beb3ae71cb320dbe4190a01c036943d99083b3 Auto-Submitted: auto-generated Date: Sat, 28 Feb 2026 11:36:25 +0000 Message-Id: <69a2d339.3a904.194fb5c8@gitrepo.freebsd.org> The branch main has been updated by zlei: URL: https://cgit.FreeBSD.org/src/commit/?id=32beb3ae71cb320dbe4190a01c036943d99083b3 commit 32beb3ae71cb320dbe4190a01c036943d99083b3 Author: Zhenlei Huang AuthorDate: 2026-02-28 11:35:42 +0000 Commit: Zhenlei Huang CommitDate: 2026-02-28 11:35:42 +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 --- 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; /*