From patchwork Sat Jan 31 19:49:18 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 44091 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f199.google.com (mail-wi0-f199.google.com [209.85.212.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 82EFE2359E for ; Sat, 31 Jan 2015 19:52:34 +0000 (UTC) Received: by mail-wi0-f199.google.com with SMTP id r20sf8445904wiv.2 for ; Sat, 31 Jan 2015 11:52:33 -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 :in-reply-to:references: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=uOzIizbvOI5hmwIk6gF4vQtyTD6ArfneUpUcgTp4YxM=; b=gh4dztdai6humHoOtvNydfmECRWDWDo74o2HgA+RYFmkLKWw2xp/goTpSfshc6f4JY /RNnh2KQpxwwE1qvl/JQ6T5T1pKsJeXn5wlbkw7lenHDFtq7LJ7YzPsgYltSkg7mpwnh sZhatVvGeZG4zn5xQJUj0UkJyGqtEemLiE6p1hty/jLza5IVWW8Qdd/YHG+6UnyfytH8 LgK6OJR2i9RSqRDWKFlQ+7hztYM3pG4eiADHpbSyNY08eeldd7Ln7JB04YznkvVCCznb gPjn97vOYgwdwnDszd6k668pnGRnll24EUtJfrUt21agW/frQT39lHuWuP4uvAxEFWV9 tgqw== X-Gm-Message-State: ALoCoQmP5Hv7EuNWzjqVimghzG6lkpMDOnoqhXPdQDBacrT9uGaRXcrNYa0sDooDp6qfLm9lkRgI X-Received: by 10.180.37.107 with SMTP id x11mr362082wij.5.1422733953811; Sat, 31 Jan 2015 11:52:33 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.5.135 with SMTP id s7ls551814las.39.gmail; Sat, 31 Jan 2015 11:52:33 -0800 (PST) X-Received: by 10.112.235.194 with SMTP id uo2mr11999508lbc.57.1422733953590; Sat, 31 Jan 2015 11:52:33 -0800 (PST) Received: from mail-la0-f49.google.com (mail-la0-f49.google.com. [209.85.215.49]) by mx.google.com with ESMTPS id m1si13038233lam.44.2015.01.31.11.52.33 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 31 Jan 2015 11:52:33 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.49 as permitted sender) client-ip=209.85.215.49; Received: by mail-la0-f49.google.com with SMTP id gf13so30257127lab.8 for ; Sat, 31 Jan 2015 11:52:33 -0800 (PST) X-Received: by 10.152.245.44 with SMTP id xl12mr12124543lac.81.1422733953378; Sat, 31 Jan 2015 11:52:33 -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.35.133 with SMTP id h5csp432099lbj; Sat, 31 Jan 2015 11:52:32 -0800 (PST) X-Received: by 10.70.95.166 with SMTP id dl6mr17898854pdb.140.1422733951592; Sat, 31 Jan 2015 11:52:31 -0800 (PST) Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id co2si18180342pbb.74.2015.01.31.11.52.30 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 31 Jan 2015 11:52:31 -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 1YHe3v-0001Cg-CR; Sat, 31 Jan 2015 19:50:35 +0000 Received: from mail-wg0-f50.google.com ([74.125.82.50]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YHe3h-0000u4-Hi for linux-arm-kernel@lists.infradead.org; Sat, 31 Jan 2015 19:50:22 +0000 Received: by mail-wg0-f50.google.com with SMTP id b13so32185872wgh.9 for ; Sat, 31 Jan 2015 11:50:04 -0800 (PST) X-Received: by 10.194.2.240 with SMTP id 16mr26637691wjx.108.1422733802475; Sat, 31 Jan 2015 11:50:02 -0800 (PST) Received: from ards-macbook-pro.local ([197.130.213.20]) by mx.google.com with ESMTPSA id p6sm12474256wia.14.2015.01.31.11.49.58 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 31 Jan 2015 11:50:01 -0800 (PST) From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org, linux@arm.linux.org.uk, nico@linaro.org, dave.martin@linaro.org Subject: [PATCH resend 3/4] ARM: Thumb-2: infer function annotation for external ksyms Date: Sat, 31 Jan 2015 19:49:18 +0000 Message-Id: <1422733759-27236-4-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1422733759-27236-1-git-send-email-ard.biesheuvel@linaro.org> References: <1422733759-27236-1-git-send-email-ard.biesheuvel@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150131_115021_769383_F3DD3492 X-CRM114-Status: GOOD ( 10.84 ) 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.50 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [74.125.82.50 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.49 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(), 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(-) 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);