Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp1140187ybg; Thu, 4 Jun 2020 02:00:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxFNgDeH8i+3peg4CRRUM1/hq+ZjLrX70MWV5B6aJ5ptJiv7mfTn7ojZCjmub8jGMaiUzll X-Received: by 2002:a17:906:9254:: with SMTP id c20mr3119990ejx.540.1591261203852; Thu, 04 Jun 2020 02:00:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591261203; cv=none; d=google.com; s=arc-20160816; b=KMJALVBbv7og1Es0elZKw3qKjLS9FLiW6IpTpWcMrUEuMbLHhWlyqlYWZiWqvVowlP I5jBLS2UjtfBGBbIquS3bXmJWIBdQVExWsq4wJyyPARTrxgpOwjy386z0u1Q1uh4rVGw b/tBLRIoC3KtI0NJG7MZCbQFIulIk68kpgiox/WLSfhLZxT4w1Kje8cHL6+FWi5S9Yaz vElEk0q0L779nnqC4X5oWX9aA/HHqBjXgnu+kU8n1U5PMl+aZ1cYbeGPLy8vEbaIzUFp zxIOdJvfnfrPLxcjMZMAinRriXDGL3+CvG0OeJS4n0CEXX4L9BqnPANexqj1mCf7ci6O ToaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=SYYqDWw5vHQ6DonQMxeBgV3yX0QRJPd1xWEoZM2Z4ts=; b=idNcRwhurBjp6McGEiEI+9mG8mlddoNlU5Ms03lsYpc/YJ3+W2B4S1bvwjAQ6hZUvj lKgr/Z26Z0aXkNGyt0SoUKaOLIzovtl2PDxKyc/qVgyV1z0w2xWzeTF27A+o2PKh4WHV F3sASDVwulVvaX+y5o42ejV5qJdUyseo7go5PZhRM93CaN0CMwTzxQxxeAxKfiLIcumb fWDNl26u25lKOgfS2JKb4EsFKYfQOAfED36m/VNL1oLyWxKD9shjaA64Jj1LycrSL/EK 2VLmytEC5QQvhTBkeM3AZHlZJWPZ+QfR8HNRZJSoE6SHQWVo2w6PVPnrCVFzVmMhWMUQ yXDw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s20si1238851edw.254.2020.06.04.01.59.41; Thu, 04 Jun 2020 02:00:03 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728413AbgFDI5P (ORCPT + 99 others); Thu, 4 Jun 2020 04:57:15 -0400 Received: from mx2.suse.de ([195.135.220.15]:40638 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728089AbgFDI5P (ORCPT ); Thu, 4 Jun 2020 04:57:15 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id D93B1ACF1; Thu, 4 Jun 2020 08:57:16 +0000 (UTC) Date: Thu, 4 Jun 2020 10:57:12 +0200 From: Petr Mladek To: Cheng Jian Cc: linux-kernel@vger.kernel.org, live-patching@vger.kernel.org, chenwandun@huawei.com, xiexiuqi@huawei.com, bobo.shaobowang@huawei.com, huawei.libin@huawei.com, jeyu@kernel.org, jikos@kernel.org Subject: Re: [PATCH] module: make module symbols visible after init Message-ID: <20200604085712.GD22497@linux-b0ei> References: <20200603141200.17745-1-cj.chengjian@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200603141200.17745-1-cj.chengjian@huawei.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed 2020-06-03 14:12:00, Cheng Jian wrote: > When lookup the symbols of module by module_kallsyms_lookup_name(), > the symbols address is visible only if the module's status isn't > MODULE_STATE_UNFORMED, This is problematic. > > When complete_formation is done, the state of the module is modified > to MODULE_STATE_COMING, and the symbol of module is visible to the > outside. > > At this time, the init function of the module has not been called, > so if the address of the function symbol has been found and called, > it may cause some exceptions. It is really handful that module symbols can be found already when the module is MODULE_STATE_COMING state. It is used by livepatching, ftrace, and maybe some other subsystems. The problem is that nobody is allowed to use (call) module symbols before mod->init() is called and the module is moved to MODULE_STATE_LIVE. By other words. Any code that calls module symbols before the module is fully initialized is buggy. The caller should get fixed, not the kallsyms side. Have you seen such a problem in the real life, please? Best Regards, Petr