Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp3944198ybv; Tue, 25 Feb 2020 10:07:43 -0800 (PST) X-Google-Smtp-Source: APXvYqwLuq5+DWpWWyBS5snvNglLNpRoPNqqNvNEBs5iLfHZvK0YuAKzn5UxclAyuYB4bq+d3qck X-Received: by 2002:aca:b483:: with SMTP id d125mr128352oif.167.1582654062988; Tue, 25 Feb 2020 10:07:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582654062; cv=none; d=google.com; s=arc-20160816; b=PC4LVyKq9f98f6GOWSBdR8n5hZVgDtaxq2YmsPVzg/sd3LXwnPgoADn1fIHJFc7MD2 T1I33E4RHGm94HlSU7bEepuexh4zHE3P7Uh7eTgIX+MWcBMsEffJKhaCDASVJS4ntcZi c9+BEm0Zfzz+H3GQ0LTqN0b1A7UNWjwT+QCr8yBuyPNjeWWg/h9MXgBqHWpimjsCG7dp JlNKn2NBX7fqNIxB5UgOU8O+doDmsKQ0VWwQEiJ68rYQtBqiHme6UMHIGPCm/mpsqMez xinp2lUV/HD5Io2bhkX18FTi9drTxsJRuWechMSh22Ub92yAm33XS4tmemP0H2hkeXN+ muiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date; bh=5uV2Msqf9C4/8TOq7aq4hEbP4lcbljt9+JS7qWRj25M=; b=j0BjWq465TVWHJZmGyEFmxlbMgiBSXTrRDrgY/IAD0JHou69W+EJm/82EJYobvtkIA y17XWuIAldwk8lBQva6ZtMyk9Pdn5gepaxKzoo/FvjK30SDgAhm34lw4QX+en2DxhcJU 3B5A8m+lKZiuuO8IymifCGEDlijPA1ygcgVhtG0bU5klWD6Lzm1FaTcMb6dDgyEOltEY JI7gOedqPVrB4gxAT3ZQaRmJ986duMIdhDfDpWYF1YRNXqZ60s+EMOgiqJhyLQ3weGao 4pl082gh3iARFbRTRyy5QLkJ6250HKc7F7pXRRDvbrcHnpS+oZ3fBiDlVl/YLQCzvYYP eY+g== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a14si4102otk.2.2020.02.25.10.07.29; Tue, 25 Feb 2020 10:07:42 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729553AbgBYSB3 (ORCPT + 99 others); Tue, 25 Feb 2020 13:01:29 -0500 Received: from mx2.suse.de ([195.135.220.15]:46726 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727983AbgBYSB3 (ORCPT ); Tue, 25 Feb 2020 13:01:29 -0500 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 641A4AD48; Tue, 25 Feb 2020 18:01:26 +0000 (UTC) Date: Tue, 25 Feb 2020 19:01:25 +0100 (CET) From: Miroslav Benes To: Joe Lawrence cc: Petr Mladek , Will Deacon , linux-kernel@vger.kernel.org, kernel-team@android.com, akpm@linux-foundation.org, "K . Prasad" , Thomas Gleixner , Greg Kroah-Hartman , Frederic Weisbecker , Christoph Hellwig , Quentin Perret , Alexei Starovoitov , Masami Hiramatsu , live-patching@vger.kernel.org Subject: Re: [PATCH 0/3] Unexport kallsyms_lookup_name() and kallsyms_on_each_symbol() In-Reply-To: <943e7093-2862-53c6-b7f4-96c7d65789b9@redhat.com> Message-ID: References: <20200221114404.14641-1-will@kernel.org> <20200225121125.psvuz6e7coa77vxe@pathway.suse.cz> <943e7093-2862-53c6-b7f4-96c7d65789b9@redhat.com> User-Agent: Alpine 2.21 (LSU 202 2017-01-01) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="1678380546-697660208-1582653686=:1630" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --1678380546-697660208-1582653686=:1630 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT On Tue, 25 Feb 2020, Joe Lawrence wrote: > On 2/25/20 7:11 AM, Petr Mladek wrote: > > On Tue 2020-02-25 11:05:39, Miroslav Benes wrote: > >> CC live-patching ML, because this could affect many of its users... > >> > >> On Fri, 21 Feb 2020, Will Deacon wrote: > >> > >>> Hi folks, > >>> > >>> Despite having just a single modular in-tree user that I could spot, > >>> kallsyms_lookup_name() is exported to modules and provides a mechanism > >>> for out-of-tree modules to access and invoke arbitrary, non-exported > >>> kernel symbols when kallsyms is enabled. > > > > Just to explain how this affects livepatching users. > > > > Livepatch is a module that inludes fixed copies of functions that > > are buggy in the running kernel. These functions often > > call functions or access variables that were defined static in > > the original source code. There are two ways how this is currently > > solved. > > > > Some livepatch authors use kallsyms_lookup_name() to locate the > > non-exported symbols in the running kernel and then use these > > address in the fixed code. > > > > FWIW, kallsyms was historically used by the out-of-tree kpatch support module > to resolve external symbols as well as call set_memory_r{w,o}() API. All of > that support code has been merged upstream, so modern kpatch modules* no > longer leverage kallsyms by default. Good. Quick grep through the sources gave me a couple of hits, so I was not sure. > * That said, there are still some users who still use the deprecated support > module with newer kernels, but that is not officially supported by the > project. > > > Another possibility is to used special relocation sections, > > see Documentation/livepatch/module-elf-format.rst > > > > The problem with the special relocations sections is that the support > > to generate them is not ready yet. The main piece would klp-convert > > tool. Its development is pretty slow. The last version can be > > found at > > https://lkml.kernel.org/r/20190509143859.9050-1-joe.lawrence@redhat.com > > > > I am not sure if this use case is enough to keep the symbols exported. > > Anyway, there are currently some out-of-tree users. > > > > Another (temporary?) klp-relocation issue is that binutils has limited support > for them as currently implemented: > > https://sourceware.org/ml/binutils/2020-02/msg00317.html > > For example, try running strip or objcopy on a .ko that includes them and you > may find surprising results :( > > > As far as the klp-convert patchset goes, I forget whether or not we tied its > use case to source-based livepatch creation. If kallsyms goes unexported, > perhaps it finds more immediate users. > > However since klp-convert provides nearly the same functionality as kallsyms, > i.e. both can be used to circumvent symbol export licensing -- one could make > similar arguments against its inclusion. In a way yes, but as Masami described elsewhere in the thread there are more convenient ways to circumvent it even now. Not as convenient as kallsyms, of course. > If there is renewed (or greater, to be more accurate) interest in the > klp-convert patchset, we can dust it off and see what's left. AFAIK it was > blocked on arch-specific klp-relocations and whether per-object​ livepatch > modules would remove that requirement. Yes, I think it is on standby now. I thought about it while walking through Petr's module split patch set and it seemed to me that klp-convert could be made much much simpler on top of that. So we should start there. Anyway, as far as Will's patch set is concerned, there is no real obstacle on our side, is there? Alexei mentioned ksplice from git history, but no one cares about ksplice in upstream now, I would say. Thanks Miroslav --1678380546-697660208-1582653686=:1630--