From patchwork Wed Nov 26 16:10:08 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 41543 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f71.google.com (mail-wg0-f71.google.com [74.125.82.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id BDC20203C2 for ; Wed, 26 Nov 2014 16:12:25 +0000 (UTC) Received: by mail-wg0-f71.google.com with SMTP id l18sf1979911wgh.2 for ; Wed, 26 Nov 2014 08:12:25 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:subject:date:message-id:cc :precedence:list-id:list-unsubscribe:list-archive:list-post :list-help:list-subscribe:mime-version:content-type :content-transfer-encoding:sender:errors-to:x-original-sender :x-original-authentication-results:mailing-list; bh=oHxZ7uhN4O8ndBZd3TRtzgtEKqRqbWRWkxPpbATuIxc=; b=hNif0UqfS/46gEGSOjkzqQnWtErtkAbLIpxGH2MpfB/e7gOdj5hJayzMctd65ajT32 XFoJ0znFCZAxZnefafxwis96HlGBXyxjBKdbI0VyAKjqK8BphY2x3CHG9Bfej7N4Bk+7 SCgDN1xB7wMt+2TELNohK5Gt1Xsr1X5dKVhtMcueC2s3CDlbj0trDPS/qPHsH/eENCzR 0vHKAspZBK6i/xy/qpEwzik1e24eFonM7fUvVNKKbqQYrOz+SLfJo6N1kqSOmSl5f5kw DDrB1T/4rbvWQAI4YVq3fG68jXeK93HyH6fDU60zJnLD+/aexCHfHXD0/h7PwfRHhSfk gqnA== X-Gm-Message-State: ALoCoQmdTmOiulcMwckX3mXuGx9dmsLNFn6Mma+MgofXRH1sIY/BW4NEWIaeZ7ColbmW8VaAqohH X-Received: by 10.181.13.147 with SMTP id ey19mr7251382wid.2.1417018345101; Wed, 26 Nov 2014 08:12:25 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.9.38 with SMTP id w6ls620450laa.49.gmail; Wed, 26 Nov 2014 08:12:24 -0800 (PST) X-Received: by 10.112.168.39 with SMTP id zt7mr34510191lbb.72.1417018344734; Wed, 26 Nov 2014 08:12:24 -0800 (PST) Received: from mail-la0-f50.google.com (mail-la0-f50.google.com. [209.85.215.50]) by mx.google.com with ESMTPS id ob4si4837688lbb.40.2014.11.26.08.12.24 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 26 Nov 2014 08:12:24 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.50 as permitted sender) client-ip=209.85.215.50; Received: by mail-la0-f50.google.com with SMTP id pn19so1985345lab.9 for ; Wed, 26 Nov 2014 08:12:24 -0800 (PST) X-Received: by 10.112.14.69 with SMTP id n5mr34684632lbc.34.1417018344595; Wed, 26 Nov 2014 08:12:24 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.184.201 with SMTP id ew9csp649057lbc; Wed, 26 Nov 2014 08:12:23 -0800 (PST) X-Received: by 10.66.246.130 with SMTP id xw2mr14636356pac.55.1417018342740; Wed, 26 Nov 2014 08:12:22 -0800 (PST) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id kg1si7418389pad.162.2014.11.26.08.12.22 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 26 Nov 2014 08:12:22 -0800 (PST) Received-SPF: none (google.com: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org does not designate permitted sender hosts) client-ip=2001:1868:205::9; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1XtfAr-0002nw-Ve; Wed, 26 Nov 2014 16:10:38 +0000 Received: from mail-wg0-f42.google.com ([74.125.82.42]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XtfAj-0001rY-8a for linux-arm-kernel@lists.infradead.org; Wed, 26 Nov 2014 16:10:30 +0000 Received: by mail-wg0-f42.google.com with SMTP id z12so4174794wgg.1 for ; Wed, 26 Nov 2014 08:10:06 -0800 (PST) X-Received: by 10.194.61.168 with SMTP id q8mr43010754wjr.53.1417018206255; Wed, 26 Nov 2014 08:10:06 -0800 (PST) Received: from ards-macbook-pro.local (cag06-7-83-153-85-71.fbx.proxad.net. [83.153.85.71]) by mx.google.com with ESMTPSA id cz3sm6924303wjb.23.2014.11.26.08.10.04 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 26 Nov 2014 08:10:05 -0800 (PST) From: Ard Biesheuvel To: nico@linaro.org, linux@arm.linux.org.uk, dave.martin@arm.com, linux-arm-kernel@lists.infradead.org Subject: [PATCH 1/2] ARM: Thumb-2: infer function annotation for external ksyms Date: Wed, 26 Nov 2014 17:10:08 +0100 Message-Id: <1417018209-14078-1-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 1.8.3.2 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20141126_081029_488478_47485068 X-CRM114-Status: GOOD ( 12.28 ) X-Spam-Score: -0.7 (/) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-0.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [74.125.82.42 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [74.125.82.42 listed in wl.mailspike.net] -0.0 SPF_PASS SPF: sender matches SPF record -0.0 RCVD_IN_MSPIKE_WL Mailspike good senders Cc: Ard Biesheuvel X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: ard.biesheuvel@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.50 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 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(), this will result in A32 symbols that do require an interworking mode switch to 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(-) diff --git a/arch/arm/kernel/module.c b/arch/arm/kernel/module.c index a68040989143..6c08b2188992 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);