From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D1D20C10F11 for ; Sat, 13 Apr 2019 06:59:41 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 993062084E for ; Sat, 13 Apr 2019 06:59:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="ERBzBjHW"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="vM7AYXJn" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 993062084E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=lL3dwPvZgpYVSJI8aPPrytz4Anch2MPknfATrjuCKc0=; b=ERB zBjHWYL+XJcx3HQnGvrZBX5nCmSImVc/ItIw7FNBplSrtOhREvilqb5AnY3evRE8hRdN+aTu9FINJ HO4AvFLV7Y+vVgkd2ZV4diw6yx48Xb5M3xuKIiEtQx1lMCLhg0Xv5yiHuwVxwtVNve9ATmw5ZW25F d9jzmgQGbhm+zQvo2DrZmO4SUaKc8WVKO/HAG2g9Jpfyymns3GKUqyBZYfBCWzXEyoDMjWip7/hiq 5EBqpmL5IWm7Z+yJztjaMPoNVq1YY+Pnzv5R+PxYRhGG9E/sydhjZN5EmoHszHF3XnflSShEWDPk2 HKAvLbnODJz2GKlknjtgfIcV/MvE4Zw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hFCdW-0001wr-8T; Sat, 13 Apr 2019 06:59:38 +0000 Received: from mail-oi1-x243.google.com ([2607:f8b0:4864:20::243]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hFCdS-0001wD-Rw for linux-arm-kernel@lists.infradead.org; Sat, 13 Apr 2019 06:59:36 +0000 Received: by mail-oi1-x243.google.com with SMTP id i21so9810583oib.11 for ; Fri, 12 Apr 2019 23:59:31 -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; bh=oQFYxk0KVp66EW/wsEnrNWr9MQA6nZnrBh0evkW3E0M=; b=vM7AYXJndNtDhBp1dYxE/Pdlvdnzck/6iRBms8kBJiJ8gHVwhIaphttiGjVhEpuRMf XlHTZcN8d0tAJ+JxJVWqGFtCbPt4jiHRzBFoCao5NhcmlzwW/TlMe9Cdg60L9MYMjvM6 eusGznXz0hn+BXSjuZDjHtEOOM/SVX4O+T+fW+dx7tY3qNsX8XutRmY1ygmhcr7J4m6R WPNi94jeUhsLaU8jfilzzaFLUjkNVUkq2x8EWqIyCTnlUnPGagKJAnKAmFVFVgGyRS77 idy6GC55xy9hmBGd3emQSE/68WqVgp/m12ZFgJtUQr9miutM606+GOOEyAYDwRs2qEv5 FIsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=oQFYxk0KVp66EW/wsEnrNWr9MQA6nZnrBh0evkW3E0M=; b=RfEFH7SmHnV5WwxpXn2uEW2XaLHa4XkA+13E5LUWXn6F/5M5AndQrNVOOMm9bmclxs eMHxObTA4iUsHKPlKaPS/eItuAFirJE13BZctbosO58XG4itNqyuu++TIJ/9pRKKsim+ 2t81Hpr+7CJ2joDQpQNWmVmUKRxHcr67Sm0q0b7e6K9it7AJ+G5ljIWNt3j3NQrjvMLW B+ZnEHeXGe0tJOm77gJrpSrtDSCRbzvbmX0G1N5e5nVJWCWtpkfUoOHiqSUtnHNN8pE5 x+3Vg/lATkg7EIL4cW/6S7vk6rMUd0Kmdau+tU4KRaDfO7beD5i2QLOP/LGaZ8UlQ7we 0DIA== X-Gm-Message-State: APjAAAWxJSh39caQe+uOOUfQmShWFCPlE79UTopRp1B2bkJGrT+r4IHk ccqsct+o8xP9wsvaM8CoZgwV31OgKRoISTg9 X-Google-Smtp-Source: APXvYqxIQQD4NRPLO6XY6+36qyIpq/XizDlKazGyFj6sYYUUZRUl84yC2M+y6PTH7lS6qVqj0MfpCQ== X-Received: by 2002:aca:6288:: with SMTP id w130mr11868190oib.116.1555138769994; Fri, 12 Apr 2019 23:59:29 -0700 (PDT) Received: from localhost.localdomain ([50.236.184.206]) by smtp.gmail.com with ESMTPSA id 131sm16647834oib.51.2019.04.12.23.59.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 Apr 2019 23:59:28 -0700 (PDT) From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org Subject: [PATCH] arm64/module: ftrace: deal with place relative nature of PLTs Date: Fri, 12 Apr 2019 23:59:25 -0700 Message-Id: <20190413065925.6981-1-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190412_235934_968847_6C587581 X-CRM114-Status: GOOD ( 13.26 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, Ard Biesheuvel , catalin.marinas@arm.com, will.deacon@arm.com, duwe@lst.de, dann.frazier@canonical.com MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org Another bodge for the ftrace PLT code: plt_entries_equal() now takes the place relative nature of the ADRP/ADD based PLT entries into account, which means that a struct trampoline instance on the stack is no longer equal to the same set of opcodes in the module struct, given that they don't point to the same place in memory anymore. Work around this by using memcmp() in the ftrace PLT handling code. Signed-off-by: Ard Biesheuvel --- arch/arm64/kernel/ftrace.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/arch/arm64/kernel/ftrace.c b/arch/arm64/kernel/ftrace.c index 07b298120182..65a51331088e 100644 --- a/arch/arm64/kernel/ftrace.c +++ b/arch/arm64/kernel/ftrace.c @@ -103,10 +103,15 @@ int ftrace_make_call(struct dyn_ftrace *rec, unsigned long addr) * to be revisited if support for multiple ftrace entry points * is added in the future, but for now, the pr_err() below * deals with a theoretical issue only. + * + * Note that PLTs are place relative, and plt_entries_equal() + * checks whether they point to the same target. Here, we need + * to check if the actual opcodes are in fact identical, + * regardless of the offset in memory so use memcmp() instead. */ trampoline = get_plt_entry(addr, mod->arch.ftrace_trampoline); - if (!plt_entries_equal(mod->arch.ftrace_trampoline, - &trampoline)) { + if (memcmp(mod->arch.ftrace_trampoline, &trampoline, + sizeof(trampoline))) { if (plt_entry_is_initialized(mod->arch.ftrace_trampoline)) { pr_err("ftrace: far branches to multiple entry points unsupported inside a single module\n"); return -EINVAL; -- 2.17.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel