Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp369667ybt; Wed, 8 Jul 2020 01:52:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzYU8UzLxkobEBqsEcM2wFuRXWy0J9u5K+zNcNcFsauXD3HDSyvB6FNQZ/Fd7Dcu3rpKeiw X-Received: by 2002:a17:906:4acc:: with SMTP id u12mr26665592ejt.358.1594198346398; Wed, 08 Jul 2020 01:52:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594198346; cv=none; d=google.com; s=arc-20160816; b=eoAvp1BeI42RY71rqtM3Aqh3qHRVkfeYS1/r0Lbqm1UiqlDDZbFK9AUa4dkz1VKdWp NgQa4FimnI06u71yt2P4prmxejvTyciJ70tTg8gazGAxNZA3qxD/RG54rzhH9J1gzBuE 4XreX6SCkHfQH0n+6NrLt0wXBHFXNqF2H3wqqfvrLDypUTXlJzTKXRgT0krePg9m4l/l AbNW6wziwBJpWHOCnBr6kqwNxsqVP+Gyp2iVFagB3qugW3qdazRAZcQ2lebAiFYC+9zJ yoWedIwiO8WWJKlJ1LXFLEFFzOSSgBQNkFeSiMRkVMGRmqklkHrt7mXP5ha6s/ONKPVx J3Dw== 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 :in-reply-to:references:mime-version:dkim-signature; bh=qeeI/Eq9sHHEEqV5brhocusvwHFqubxpND3w4Isw/3M=; b=taRSdrjj6a74WDTaJqN4q4vxyh+JmQcSQ5/kIuoM3I8OYs149H6AlGcCMQXRJFlkUN LtXJ0n/SepKioFeTo9HxnmoYnRAVWE6v/rejq/3KDxKqyTaljOaV/jA9DIIo3qIz3buv NG0Py3ey/kOpB7WqYQfw3YgRXSoebB7/N7JQfs40HuXBgtucZNYW6VGW0ADHSRc15nIE 8FGAsdjM9W+VbjSSH6LV0CAUW+Ljp0FpNneClvgN0jL25E0sWqfDiBeDRF6gZyC0zG9E pSZDWgZQOwbDYOOfz4ejIt7OqpnieaUEthsQ0+9V5BYp+sc6l27Yroyi3p5in9zBmxHI rOmQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=cvomhAG0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r8si17619813edl.19.2020.07.08.01.52.02; Wed, 08 Jul 2020 01:52:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=cvomhAG0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728350AbgGHIst (ORCPT + 99 others); Wed, 8 Jul 2020 04:48:49 -0400 Received: from mail.kernel.org ([198.145.29.99]:49898 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728346AbgGHIst (ORCPT ); Wed, 8 Jul 2020 04:48:49 -0400 Received: from mail-ot1-f48.google.com (mail-ot1-f48.google.com [209.85.210.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 8FFA42220F for ; Wed, 8 Jul 2020 08:48:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1594198128; bh=v5b+eRpJRjTUvJpoBew9P5DOQzMsw60wsZb0UX7sXXA=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=cvomhAG0GZfWJanHzzFwzJkezudt5a8yhvVMvUHCAtpPvdULl4qnaVApUqvFRgpSC YeqzgExHoFs0wagB65hJRUaQNYJ54thqnWZrOgh1+Als4gwTjgtB3hnIT2XnA6JIkh mVbX/DyWB5Vz5+EbNshT19F1R/4fpcwzC0f8oRl0= Received: by mail-ot1-f48.google.com with SMTP id t18so23566860otq.5 for ; Wed, 08 Jul 2020 01:48:48 -0700 (PDT) X-Gm-Message-State: AOAM5301o5KmTtlA1zZxDH/GvckUdU1kTaG77poDbtzs2FQc91gr32MY a9WNYRXt6JsB5Wakkj7jScvL/SVTDEOqHD1Qh2g= X-Received: by 2002:a9d:6e85:: with SMTP id a5mr8243417otr.90.1594198127882; Wed, 08 Jul 2020 01:48:47 -0700 (PDT) MIME-Version: 1.0 References: <20200707114608.24197-1-richard.peng@oppo.com> <20200708082519.GA25634@willie-the-truck> In-Reply-To: <20200708082519.GA25634@willie-the-truck> From: Ard Biesheuvel Date: Wed, 8 Jul 2020 11:48:36 +0300 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] arm64/module-plts: Consider the special case where plt_max_entries is 0 To: Will Deacon Cc: Peng Hao , Catalin Marinas , Linux ARM , Linux Kernel Mailing List 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 Wed, 8 Jul 2020 at 11:25, Will Deacon wrote: > > [+Ard] > > On Tue, Jul 07, 2020 at 07:46:08AM -0400, Peng Hao wrote: > > If plt_max_entries is 0, a warning is triggered. > > WARNING: CPU: 200 PID: 3000 at arch/arm64/kernel/module-plts.c:97 module_emit_plt_entry+0xa4/0x150 > > Which kernel are you seeing this with? There is a PLT-related change in > for-next/core, and I'd like to rule if out if possible. > > > Signed-off-by: Peng Hao > > --- > > arch/arm64/kernel/module-plts.c | 3 ++- > > 1 file changed, 2 insertions(+), 1 deletion(-) > > > > diff --git a/arch/arm64/kernel/module-plts.c b/arch/arm64/kernel/module-plts.c > > index 65b08a74aec6..1868c9ac13f2 100644 > > --- a/arch/arm64/kernel/module-plts.c > > +++ b/arch/arm64/kernel/module-plts.c > > @@ -79,7 +79,8 @@ u64 module_emit_plt_entry(struct module *mod, Elf64_Shdr *sechdrs, > > int i = pltsec->plt_num_entries; > > int j = i - 1; > > u64 val = sym->st_value + rela->r_addend; > > - > > + if (pltsec->plt_max_entries == 0) > > + return 0; > > Hmm, but if there aren't any PLTs then how do we end up here? > Indeed. module_emit_plt_entry() is only invoked if we encounter a call or jump relocation that is out of range, and so we failed to allocate enough PLT entries in module_frob_arch_sections() if you are entering module_emit_plt_entry() with max_entries set to 0x0. The only other way to trigger this is when the .text section of your module is so large that branches go out of range, but PLTs won't help there.