Received: by 2002:ac0:cd04:0:0:0:0:0 with SMTP id w4csp164092imn; Fri, 1 Jul 2022 12:12:59 -0700 (PDT) X-Google-Smtp-Source: AGRyM1u2rWKxrlhDOYvtHRTOSnNSMi31ysxpw7FEZpzDT2js/Qb+ZOnGxD7qCt1c3G8vBaNn09sI X-Received: by 2002:a17:902:8b87:b0:169:5e5:43de with SMTP id ay7-20020a1709028b8700b0016905e543demr21823549plb.8.1656702779545; Fri, 01 Jul 2022 12:12:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656702779; cv=none; d=google.com; s=arc-20160816; b=OdV7o5g6MtWftnU+pelgGYfHtdicYxq1mEX3zQ0j8llJC9wThYDgOAo/VmMnqgA+QB dtyc9R9ZyL0ygLgofJ8gi9rPq0cWsD1Kg8UUavFymKDt+Kr4fvZiw+mYx2SHhvmGE2wb VwaGoJYbRQyhwp2ARp2esumjYHSiYugHd7ahVj8WvyIkpf5oOOGiB5dfyy9r1CGnuhpb abICrCIsrqf1JolzQ7YyO3Uzkk46dSvqYXXQ8eFbWeeksEnoCTe+n92OhFOm20domqWB cuI+7kxNQOjZ9tRWcXBIVpBjTL0/bIpqvA7S7/sWZaTr1cyHk3b5YGjYtgxv6bCbGpQh 8/NA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:to:from:date:dkim-signature; bh=LuxZukPpQVrhkpWVOW97hLY2oP1d/O+X0TtsDGLPqKQ=; b=WcXKPNBI5xsUhgN12e+avMhzWtz4THGfxr8q8XOm2x4KbjC74A0BCVhDHJKuofgG4C YB0B+Zn2v1g/Vjpjx9vssc49rnZMZdhO8HmliEzV7SaaZrfsFdydpDB9myn9kvtWuO4d MZCmpif/p7B9+CN1yyWgDXTpUBjJO7XsfVzWOMfRwLbdzTbaSAHCb7VmajjSQMRZl6UD KxcOB5yNhbAPVgJrTf0beloCmKjJ9e7u4Y41I8LNkxRZUYwfbrm1mWaBfq5UIrex4XPy exkTDteRyTjtVDuq+BNGCi8s3He9nN/lTXXy/amMzeK9ziDzrNZViLnoHysF1MZdEV4c IILQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmx.net header.s=badeba3b8450 header.b=ko5EUt6d; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=gmx.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l137-20020a633e8f000000b003fd7e2174c3si31941636pga.829.2022.07.01.12.12.47; Fri, 01 Jul 2022 12:12:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmx.net header.s=badeba3b8450 header.b=ko5EUt6d; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=gmx.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230388AbiGASkO (ORCPT + 99 others); Fri, 1 Jul 2022 14:40:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60866 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230272AbiGASkL (ORCPT ); Fri, 1 Jul 2022 14:40:11 -0400 Received: from mout.gmx.net (mout.gmx.net [212.227.17.22]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E7A0223152; Fri, 1 Jul 2022 11:40:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1656700803; bh=LQhKkVh7ERzHyd0XFztdkI4wYKz/OTZWu0gTeX+kc9k=; h=X-UI-Sender-Class:Date:From:To:Subject; b=ko5EUt6drjtBLxn8lnaa94mVfh3+4mSBNr/LUgwpUM+B2O+6IKrNQL8eXH1iqYe9l 2Md92OUhe8EeS5oZuBpn6GJcirljPxi7e0MXw5wIcUxTugrO0pXhElfMpqvjr3wMUR c83MbRGQXDH8NgYYCqSxSYgrcOUxu/ouICxPrsas= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from p100 ([92.116.182.192]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MDywu-1nxPPT2KrE-009xA4; Fri, 01 Jul 2022 20:40:03 +0200 Date: Fri, 1 Jul 2022 20:40:02 +0200 From: Helge Deller To: mcgrof@kernel.org, jeyu@kernel.org, linux-modules@vger.kernel.org, linux-kernel@vger.kernel.org, linux-parisc@vger.kernel.org Subject: [PATCH v2] modules: Ensure natural alignment for .altinstructions and __bug_table sections Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Provags-ID: V03:K1:V5gOQb0rPPCFwBpCuwfiHq/tFNJjfharij+9vL3FdnDAm2wBBWI 96O1pYHAyF7lCJE0O7tIdCP1OaKt85C7BcGhvPA6EKK11BRaxx4b1iFA2ETGkzSVFNH/yaF zdh3MMWwKgzlRY6Izzk6bXdtTXgUpN9FzUoH9iN9l7MKn+l8SxSMZh2lBQQb7aDzaYKg0bB 4NU+S7zkdJvhMeKF7adrw== X-UI-Out-Filterresults: notjunk:1;V03:K0:cylAGrI9jeY=:5FFRWh/zKj+pba37xv/oVO Tw+LQcfrmUWKF/l8f10i6zuTgxvnsKB0rK37i5rjJ+vZYpdz3HUwlywvKps/WI8vTuSvfdFfY Ivfjn9e9/ibOLgbWOmsNTThRfv1F8T6e8q8L/szeWlOM7djtf7DAcy04cpo/VVIKJwPCghA1U hdf+nAVSioCf9fq48tQSWG6ak4sqZekK3lNh5N8rHgVhcFs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SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In the kernel image vmlinux.lds.S linker scripts the .altinstructions and __bug_table sections are 32- or 64-bit aligned because they hold 32- and/or 64-bit values. But for modules the module.lds.S linker script doesn't define a default alignment yet, so the linker chooses the default byte alignment, which then leads to unnecessary unaligned memory accesses at runtime. Usually such unaligned accesses are unnoticed, because either the hardware (as on x86 CPUs) or in-kernel exception handlers (e.g. on hppa or sparc) emulate and fix them up at runtime. On hppa the 32-bit unalignment exception handler was temporarily broken due another bad commit, and as such wrong values were returned on unaligned accesses to the altinstructions table. This then led to undefined behaviour because wrong kernel addresses were patched and we suddenly faced lots of unrelated bugs, as can be seen in this mail thread: https://lore.kernel.org/all/07d91863-dacc-a503-aa2b-05c3b92a1e39@bell.net/T/#mab602dfa32be5e229d5e192ab012af196d04d75d This patch adds the missing natural alignment for kernel modules to avoid unnecessary (hard- or software-based) fixups. Signed-off-by: Helge Deller --- scripts/module.lds.S | 2 ++ 1 file changed, 2 insertions(+) -- v2: updated commit message diff --git a/scripts/module.lds.S b/scripts/module.lds.S index 1d0e1e4dc3d2..3a3aa2354ed8 100644 --- a/scripts/module.lds.S +++ b/scripts/module.lds.S @@ -27,6 +27,8 @@ SECTIONS { .ctors 0 : ALIGN(8) { *(SORT(.ctors.*)) *(.ctors) } .init_array 0 : ALIGN(8) { *(SORT(.init_array.*)) *(.init_array) } + .altinstructions 0 : ALIGN(8) { KEEP(*(.altinstructions)) } + __bug_table 0 : ALIGN(8) { KEEP(*(__bug_table)) } __jump_table 0 : ALIGN(8) { KEEP(*(__jump_table)) } __patchable_function_entries : { *(__patchable_function_entries) }