From patchwork Sat Aug 20 07:45:30 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 74357 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp659343qga; Sat, 20 Aug 2016 00:47:21 -0700 (PDT) X-Received: by 10.66.161.195 with SMTP id xu3mr21275931pab.68.1471679241833; Sat, 20 Aug 2016 00:47:21 -0700 (PDT) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id h184si9550979pfb.176.2016.08.20.00.47.21 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 20 Aug 2016 00:47:21 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) client-ip=2001:1868:205::9; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) smtp.mailfrom=linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bb0yx-00047h-9R; Sat, 20 Aug 2016 07:46:19 +0000 Received: from mail-wm0-x22d.google.com ([2a00:1450:400c:c09::22d]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bb0yf-000450-3C for linux-arm-kernel@lists.infradead.org; Sat, 20 Aug 2016 07:46:02 +0000 Received: by mail-wm0-x22d.google.com with SMTP id q128so59243141wma.1 for ; Sat, 20 Aug 2016 00:45:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=tqEiE9fzgftFPc/bx5CaMkdSUMdThnGv14ER81UWljc=; b=Iy1Xt0dAlMexjIIa50RX7Ac1KLIGXo/ATUopxmtPFY+ivCxFer0FovEoxuwQRNUNEp u2JIFh2G4+woxd4l7/9+qMoaKydqkO8+tfpHSaWamaH6rNnqOX5iosp8gk66K8W6sM+n qCe/IycNd2DlZeJ0KXbrN8Fp/0FkqEpMhRlqA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=tqEiE9fzgftFPc/bx5CaMkdSUMdThnGv14ER81UWljc=; b=ijbfHZvBIRU5hwYZ2EWCh52ut09eLZWeL3OmPZi1eqklqXhtoLaaoet445+2MhnMuR Pss1PDpPW/k81AcuY3CHTndREI2dg5F8uyyRmUg3V+0GtY6VGfu+JTQr/7JtB+Adi/vM c/9HWoVTYQCdVmDv7bu3tKs4E50PxetT9XS+636h6DIF2Vz9Vr0gofBZvUbr4ITULrXA qRol8mkIjdMKhSbGzvccdPDCaUmUo0VmN1tbLJ1XOPCwSyyuqfqWCmQThr9pRURFnsVt In6MbONtgm8km1kHFRXbISUsQ886087sBxmU8J9c1xHWDL35GTsxuj9HI66T1NNMPNQM GWxg== X-Gm-Message-State: AEkoouuyQZTm5t6GEykMINbIry4CQPayamfoen96v/lKAI0AwI+XrFLKiRw0i0QIaBW9CfKG X-Received: by 10.194.70.165 with SMTP id n5mr9383897wju.135.1471679139043; Sat, 20 Aug 2016 00:45:39 -0700 (PDT) Received: from localhost.localdomain (46.red-81-37-107.dynamicip.rima-tde.net. [81.37.107.46]) by smtp.gmail.com with ESMTPSA id va3sm10619944wjb.18.2016.08.20.00.45.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 20 Aug 2016 00:45:37 -0700 (PDT) From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org, linux@arm.linux.org.uk, dave.martin@arm.com Subject: [PATCH 1/2] ARM: Thumb-2: infer function annotation for external ksyms Date: Sat, 20 Aug 2016 09:45:30 +0200 Message-Id: <1471679131-3570-2-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1471679131-3570-1-git-send-email-ard.biesheuvel@linaro.org> References: <1471679131-3570-1-git-send-email-ard.biesheuvel@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160820_004601_332900_2EE60823 X-CRM114-Status: GOOD ( 12.57 ) X-Spam-Score: -2.7 (--) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-2.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [2a00:1450:400c:c09:0:0:0:22d listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ard Biesheuvel MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org Commit 9a00318eadbb ("Thumb-2: Relax relocation requirements for non-function symbols") updated the Thumb-2 jump and call relocation handling so that non-function symbols with the Thumb bit (bit 0) cleared are not treated as A32 symbols requiring an interworking mode switch. However, since ksyms are stripped of their function annotation by EXPORT_SYMBOL(), A32 symbols that do require an interworking mode switch will be called in the wrong mode if the relocation is resolved across a module boundary. This patch enhances the function symbol check by including untyped symbols that resolve to external ksyms. Signed-off-by: Ard Biesheuvel --- arch/arm/kernel/module.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) -- 2.7.4 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel diff --git a/arch/arm/kernel/module.c b/arch/arm/kernel/module.c index 4f14b5ce6535..6c22b13cbd12 100644 --- a/arch/arm/kernel/module.c +++ b/arch/arm/kernel/module.c @@ -182,13 +182,20 @@ apply_relocate(Elf32_Shdr *sechdrs, const char *strtab, unsigned int symindex, /* * For function symbols, only Thumb addresses are * allowed (no interworking). + * This applies equally to untyped symbols that + * resolve to external ksyms: EXPORT_SYMBOL() + * strips the function annotation, but we can + * infer from the relocation type that the target + * must be a function. * * For non-function symbols, the destination * has no specific ARM/Thumb disposition, so * the branch is resolved under the assumption * that interworking is not required. */ - if (ELF32_ST_TYPE(sym->st_info) == STT_FUNC && + if ((ELF32_ST_TYPE(sym->st_info) == STT_FUNC || + (ELF32_ST_TYPE(sym->st_info) == STT_NOTYPE && + sym->st_shndx == SHN_UNDEF)) && !(sym->st_value & 1)) { pr_err("%s: section %u reloc %u sym '%s': unsupported interworking call (Thumb -> ARM)\n", module->name, relindex, i, symname);