From patchwork Mon Jan 22 21:27:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Helge Deller X-Patchwork-Id: 190412 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:805:b0:101:a8e8:374 with SMTP id e5csp12670dyi; Mon, 22 Jan 2024 13:27:43 -0800 (PST) X-Google-Smtp-Source: AGHT+IEWWk7AvgMPKgrUNnCtSpmwD9/b8xew3GCSBt67HLDE6+SQTACJRLfpoCD9SHinFCZn2cAn X-Received: by 2002:a05:600c:45c9:b0:40e:a255:8f53 with SMTP id s9-20020a05600c45c900b0040ea2558f53mr3109355wmo.13.1705958863423; Mon, 22 Jan 2024 13:27:43 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705958863; cv=pass; d=google.com; s=arc-20160816; b=XJsHWUt3PwWquPNoYmnJjnJr7Hgkd5Uuhnw0yx4VxKgFBgYjFw5LFeDyuXyrYJZHbL T1T/ulhsDX5wbS8GF3+5XOd1VCrEhpdJS03cAxkSCfdQaHLVwZOJt6urH15KIW/w4w0k IeGGn7d3iTSZfDpxiEd4bjRZMVpkg+aUNeZKIs+oixCiBd6A1AzVE9Azu4o6e9gWdC1s orCiZAXnmDrqYhrEd6lTM6755C+o4hohLlZRq2f1YEVia0CywMlEtswTeg7yo1EukFcm uifjwYNqQB1vU4u/senbt7oq7f39Ce2MYzNtSu6Qt8za8LPyNkjRSgebqeI6H0fLhiEq CtWA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-disposition:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:message-id:subject:to:from:date:dkim-signature; bh=/Irlxbbeszo3ZqK/+Z586NQ3iiv83b42qjUFO1tQZ44=; fh=N98mG7ovqyotQz/g0IorhsRXlnkw1HKtEsuqB8v0Uwk=; b=05MYSEAXOLRnvEcZmnCf10Xsi69KoJjlxDN7bL7jUiom+fgz1Yjhs3jmiV1xoU5O1E u2w4LWN7e5FT06d6GEUl9vFGYyJfDwVuj8H8rA9+DoE2nIEQmiQQT811Ompy6spiEIWP mlFCmvCyZN3Q90B5nPA6+4ZXOGVJe2fCPRV738vYju7hrGujcGpZbfinL0GC9y4hImER 5xsiryspIoV2ObK5gJT77navDR/UXBoj5h0R+i84Rb9Zz3scqlRcd0LWrbAkppllLKzf 04m5SRcC9EXApxpbtgYp/zqPk3t1QU5CU6TPxuPpjMb5v68GJu5AIE/t6lyeWDHYoCRh 93Vg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=B6FPeoic; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-34178-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-34178-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id hk16-20020a170906c9d000b00a2cce00b0eesi9917620ejb.934.2024.01.22.13.27.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jan 2024 13:27:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-34178-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=B6FPeoic; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-34178-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-34178-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 0EDA81F27C11 for ; Mon, 22 Jan 2024 21:27:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4D250481A5; Mon, 22 Jan 2024 21:27:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="B6FPeoic" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8480A481A8; Mon, 22 Jan 2024 21:27:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705958841; cv=none; b=MZkMjfq0yd/ga8Ztvl62laukDgLlEbF1f3uDHId0lehy/C7lr3FBJQZdmaji2BjVLcEP5fF4HjavebMCypzV6kW5LK3Ol3U9YgyUQoI4AfMbJWwbagHyxcqtJ0WfjGoijd2icGmb0URfDeG9gjPzBodCg84oIuCqOJ4zuoPzysI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705958841; c=relaxed/simple; bh=B4jg+wknI7bWQTo4YGuAgpR6c3hqlIFCNIfSJVyzWpI=; h=Date:From:To:Subject:Message-ID:MIME-Version:Content-Type: Content-Disposition; b=hi5y9yOB7YoZUygU7Q1l3ey/5rxG4Tm4NVmsFGFL+dsnJepIhW9w0MZUNH5xunoUuolw3AYzwn3A/hY9XirgiWVArQk6NefCbU0WfnfkgQRNZsVxbyDfJfByeGXgFtmVzSRcyqNOz+3iW2edI+jVjz/LWRis7syhBIKxE5lics0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=B6FPeoic; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id B0185C433F1; Mon, 22 Jan 2024 21:27:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705958840; bh=B4jg+wknI7bWQTo4YGuAgpR6c3hqlIFCNIfSJVyzWpI=; h=Date:From:To:Subject:From; b=B6FPeoic5mAklseNc8DVinZekJCs3gm2yeVq1FZiWEKQ8OhD4vCTm7Z26KO1F6vSP UCp0UeCrMc7gtYKPXcgFB36tWYBTWLfECX5vNKW3/no/3J1peECVFU6t4c93a9WSQr y4BtWUo83y6Ync0kgxA9L3e+ryczFPMIHZ0ACw1yg02oB3pAjXUib6a13Kgmi2xfns JsFFnzZmB500h5sX1+0GnLXmIWFKjAHK5iA6+4SJ7IqsPQgObcr0dsq2JeyR2TwPOj OfIkrsMAlrI/H7jA6aj7QuOtro/2If44RZ+u9NTtbxBtoRZMYKiNvIourW9jLFsmUA FTJ9QMJkq/0Sg== Date: Mon, 22 Jan 2024 22:27:15 +0100 From: Helge Deller To: "David S. Miller" , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-parisc@vger.kernel.org Subject: [PATCH] ipv6: Ensure natural alignment of const ipv6 loopback and router addresses Message-ID: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1788827521116694323 X-GMAIL-MSGID: 1788827521116694323 On a parisc64 kernel I notice sometimes this kernel warning: Kernel unaligned access to 0x40ff8814 at ndisc_send_skb+0xc0/0x4d8 The address 0x40ff8814 points to the in6addr_linklocal_allrouters variable and the warning simply means that some ipv6 function tries to read a 64-bit word directly from the not-64-bit aligned in6addr_linklocal_allrouters variable. The patch below ensures that those ipv6 loopback and router addresses always will be naturally aligned and as such prevents unaligned accesses for all architectures. Signed-off-by: Helge Deller diff --git a/net/ipv6/addrconf_core.c b/net/ipv6/addrconf_core.c index 507a8353a6bd..813e009b4d0e 100644 --- a/net/ipv6/addrconf_core.c +++ b/net/ipv6/addrconf_core.c @@ -220,19 +220,26 @@ const struct ipv6_stub *ipv6_stub __read_mostly = &(struct ipv6_stub) { EXPORT_SYMBOL_GPL(ipv6_stub); /* IPv6 Wildcard Address and Loopback Address defined by RFC2553 */ -const struct in6_addr in6addr_loopback = IN6ADDR_LOOPBACK_INIT; +const struct in6_addr in6addr_loopback __aligned(BITS_PER_LONG/8) + = IN6ADDR_LOOPBACK_INIT; EXPORT_SYMBOL(in6addr_loopback); -const struct in6_addr in6addr_any = IN6ADDR_ANY_INIT; +const struct in6_addr in6addr_any __aligned(BITS_PER_LONG/8) + = IN6ADDR_ANY_INIT; EXPORT_SYMBOL(in6addr_any); -const struct in6_addr in6addr_linklocal_allnodes = IN6ADDR_LINKLOCAL_ALLNODES_INIT; +const struct in6_addr in6addr_linklocal_allnodes __aligned(BITS_PER_LONG/8) + = IN6ADDR_LINKLOCAL_ALLNODES_INIT; EXPORT_SYMBOL(in6addr_linklocal_allnodes); -const struct in6_addr in6addr_linklocal_allrouters = IN6ADDR_LINKLOCAL_ALLROUTERS_INIT; +const struct in6_addr in6addr_linklocal_allrouters __aligned(BITS_PER_LONG/8) + = IN6ADDR_LINKLOCAL_ALLROUTERS_INIT; EXPORT_SYMBOL(in6addr_linklocal_allrouters); -const struct in6_addr in6addr_interfacelocal_allnodes = IN6ADDR_INTERFACELOCAL_ALLNODES_INIT; +const struct in6_addr in6addr_interfacelocal_allnodes __aligned(BITS_PER_LONG/8) + = IN6ADDR_INTERFACELOCAL_ALLNODES_INIT; EXPORT_SYMBOL(in6addr_interfacelocal_allnodes); -const struct in6_addr in6addr_interfacelocal_allrouters = IN6ADDR_INTERFACELOCAL_ALLROUTERS_INIT; +const struct in6_addr in6addr_interfacelocal_allrouters __aligned(BITS_PER_LONG/8) + = IN6ADDR_INTERFACELOCAL_ALLROUTERS_INIT; EXPORT_SYMBOL(in6addr_interfacelocal_allrouters); -const struct in6_addr in6addr_sitelocal_allrouters = IN6ADDR_SITELOCAL_ALLROUTERS_INIT; +const struct in6_addr in6addr_sitelocal_allrouters __aligned(BITS_PER_LONG/8) + = IN6ADDR_SITELOCAL_ALLROUTERS_INIT; EXPORT_SYMBOL(in6addr_sitelocal_allrouters); static void snmp6_free_dev(struct inet6_dev *idev)