Received: by 10.213.65.68 with SMTP id h4csp479407imn; Tue, 13 Mar 2018 10:20:14 -0700 (PDT) X-Google-Smtp-Source: AG47ELvbMhBd7miBvbWouB7aXKNI9SO95k4QxgDf+ja0JSvmkTTGyGapvp5bZd4okP1WtREYGgTY X-Received: by 2002:a17:902:1763:: with SMTP id i90-v6mr1194066pli.309.1520961614311; Tue, 13 Mar 2018 10:20:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520961614; cv=none; d=google.com; s=arc-20160816; b=ajhZHaZ7FVGKrBK5ZbhX2pCRjiGAaQi8Xlzx7Y1YFwzW8QHq+zuoeZlFXTWj+JA7Gq micOVbJflVrf/rJEMGzkAs9KjjqNNwoSkuk+L6yVwt3ECsBOrSYTX0QNjSI8qVMpX4B9 A9/M/2NPTppZi5U9cq2qUnDU2LtKXiFKF+EHpgYaWOcu88L80wX7kXG8jzQxgVDvAolZ 2bswuVmi3ZYJwxE5rw7f11/xc8JKY2WGU5ZyxEhMjs3P1GPwOPcEWH5y9S0s5sf2yC9d hPIQLumdhsIMXg/DxtnlZ6puM7ozyyazk8AXRUIfiPmGFoQu5lwVbWsDdoHIfeWISDD5 DALw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=YJgq4xnch1OPxXMyKxMxP8YbF/C9ViACSFvbEyN35wc=; b=kjLOD81RKoxxNf54b9cIZmlTkx/o6V3o68l/RBQdNicLG03lnZh+M1Xf+0EdgXKkub IzF0saoZEcH7M6QTckd7O6RhyrKsuyOdjpkFn0v9zNIzRfKrBABmW6AN8VVOZOcvhDqO unrCpsJL9M5xzrR5xcs3L9QsidRvoZ6YildicOjXW1V41j5BcE6WDfJYjS69sa3d8G7b NBUziMix0j7OWHOkZpqPQTKUmcDDucaY3XhJkjOHhzEZCU5/kzrgRFdefqrfdlOHxOZK cAurojhbsJiix6rqFtziPJz8/iVCEf9ugAFxU6iWMv0hiSB+mBWe+CJcf1/c3HT5y+dp Jf5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ECOiPFTo; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j1si305522pgt.317.2018.03.13.10.20.00; Tue, 13 Mar 2018 10:20:14 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ECOiPFTo; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752502AbeCMRSs (ORCPT + 99 others); Tue, 13 Mar 2018 13:18:48 -0400 Received: from mail-it0-f67.google.com ([209.85.214.67]:56075 "EHLO mail-it0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752263AbeCMRSq (ORCPT ); Tue, 13 Mar 2018 13:18:46 -0400 Received: by mail-it0-f67.google.com with SMTP id n136-v6so1031977itg.5 for ; Tue, 13 Mar 2018 10:18:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=YJgq4xnch1OPxXMyKxMxP8YbF/C9ViACSFvbEyN35wc=; b=ECOiPFToAvlkbbKEfwrFBz+R2DYZCY3ZPi/KV3uuy8PnWF4bTjaXG0ZcT/7Y296S8U zVcqYGoH1mcxAoCy0MkZ1+yWbyVHwSpQbmmw0YMfNsGzWQ5zfWCLokKSD4TppFX6LzKt XgmnDvqX5IkCkIphADKmriRR3qDRfbNWAH9Pg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=YJgq4xnch1OPxXMyKxMxP8YbF/C9ViACSFvbEyN35wc=; b=f3n9okzk/qRd+bC4W74oGjejLnYMywBZ+3u4a6eG/CKFfwVHcri7fQYXCGMI+WUsR7 y4AKpS4uRS6irpqILk+MDhVle5tzVHSzewlQezpj/WkfMHfXXoo5ygdReJAFeQQQVv5j mhSawAbgjPHSWV5Y5/IVXin+Yyp6vM5AJKybv/mBxiJ5TRPuBSzciVtUbBtnphAy+S/u 9J9NOL1Z8LSmQ1LpdbXs4S3Lb1zTe8MAy85WkvRUSkyP0Lj2NM5i8KIV7zwU6CwxlMr7 QYph6lD3v5YDhhY9ywmZoYap6Qjl0f3f9FZo7iGzjcqiZFiXl+44xwpyJd6egBIA8UdM gkdQ== X-Gm-Message-State: AElRT7GI1QbVaTXdckJ2dHra5QuGrU4/OMayKDey+kp6kv7H3/6818c7 OkxBoqJoOjB4W6YbS8rYUvImpFMEWNq+2Z/2eR0s9A== X-Received: by 10.36.60.216 with SMTP id m207mr1814532ita.68.1520961525372; Tue, 13 Mar 2018 10:18:45 -0700 (PDT) MIME-Version: 1.0 Received: by 10.107.138.209 with HTTP; Tue, 13 Mar 2018 10:18:44 -0700 (PDT) In-Reply-To: <5d3ae760-45bd-3588-500f-1b352e1722de@nokia.com> References: <20180313135314.18780-1-alexander.sverdlin@nokia.com> <20180313135314.18780-3-alexander.sverdlin@nokia.com> <5d3ae760-45bd-3588-500f-1b352e1722de@nokia.com> From: Ard Biesheuvel Date: Tue, 13 Mar 2018 17:18:44 +0000 Message-ID: Subject: Re: [PATCH v4 2/2] ARM: ftrace: Add MODULE_PLTS support To: Alexander Sverdlin Cc: linux-arm-kernel , Linux Kernel Mailing List , Russell King , Steven Rostedt , Ingo Molnar Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 13 March 2018 at 17:13, Alexander Sverdlin wrote: > Hello Ard, > > On 13/03/18 17:12, Ard Biesheuvel wrote: >>> u32 get_module_plt(struct module *mod, unsigned long loc, Elf32_Addr val) >>> { >>> struct mod_plt_sec *pltsec = !in_init(mod, loc) ? &mod->arch.core : >>> &mod->arch.init; >>> + struct plt_entries *plt; >>> + int idx; >>> >>> - struct plt_entries *plt = (struct plt_entries *)pltsec->plt->sh_addr; > ^^^^^^^^^^^ (*) > >>> - int idx = 0; >>> + /* cache the address, ELF header is available only during module load */ >>> + if (!pltsec->plt_ent) >>> + pltsec->plt_ent = (struct plt_entries *)pltsec->plt->sh_addr; >>> + plt = pltsec->plt_ent; >>> + >> Where is plt_ent ever used? > > Above is exactly the place it's used. > I need to cache it because after the module load is finished the ELF header is freed, > pltsec->plt pointer (*) is not valid any more. > With the above modification it's possible to call the function during the whole life > time of the module. > Right, ok. That's a problem. This means that you are relying on get_module_plt() being called at least once at module load time, which is not guaranteed. Instead, you should set this member (and perhaps the entire prealloc routine) in a module_finalize() implementation. >>> + if (!pltsec->plt_count) >>> + prealloc_fixed(pltsec, plt); > > I'll prepare v5 based on your other comments. > > -- > Best regards, > Alexander Sverdlin.