Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp1434922iog; Tue, 14 Jun 2022 06:06:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzTF9nNA7ALYv+gBlgg57yMs2iphKHGk5grxkCNk5tydgDqFnh1qj5fPrJMOx/ngHUHWH/9 X-Received: by 2002:a63:1a0f:0:b0:3fe:4da7:1a38 with SMTP id a15-20020a631a0f000000b003fe4da71a38mr4373236pga.332.1655211990259; Tue, 14 Jun 2022 06:06:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655211990; cv=none; d=google.com; s=arc-20160816; b=06Wnm8WOay/UGLRIiPAUVOS1kH4I1yYQE7NCBWivmL/Ah0/ZKgUDplRV7OmQ+8mDGt OaRCWhWHfmbaUhzzX2ZaDTpsHTjxlA7XMV/ou9lLW2aayvDry5S01tUy9sC0VN5SkP9a KvoTNR0ykPJh36BbpGKeIURuWYEC2oEm8E15I5suwhyfJTCaJ7bjOVbhO/yqMPVZOcd5 Xacq2sCEqhIHrlZKjNw2dK+toRk6UU6o36ohbg5wq68Yf7N2Qj6BHuwkPcUpisMJ1gex uobc4wQwUlkG59fdO/OIQIq1t/EUU/snolCXTWnxslTF6tCE7afMLXXhEGjboOY8jD33 xuxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=u4b34jqst9o3VQwYAR4l2Q0Q6jjCtJ71KvGcXi++wTE=; b=DcV7JhW9ZbPU285B1cPeBBBUO5Akw8IrOywiXkR3vJ0GwCnbRSC5wTUDFae36khwx4 MB06+KF2q7FGRjDwqg8EJydckIMc1ZzeWFhIf+WcS89ZJ2fQSSiGC6xq2SHfcRpdhLmU 49+rEHvwgpsM7ZOiT45pDV1VNqMVVpvlhyRS1s5pKCYjTS/bWRQZSAo82tmg0SixuOT8 yeAk9Xpj0WdNZmX71EZgXwKsbcX7KfzD7HncbLXhjNWsroaInhRvrd/+cDIqKLkJWOi3 yZuMW9ZfWAsTWQraUVvJOngAB7mwdNzb01roDNTqH08IMG90pTicn9vDJ7R2xxgwSc0f 2MUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="RnGKuF+/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a2-20020a170902ee8200b00163cb1c5462si13217733pld.99.2022.06.14.06.06.07; Tue, 14 Jun 2022 06:06:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="RnGKuF+/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S244456AbiFNMjn (ORCPT + 99 others); Tue, 14 Jun 2022 08:39:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42254 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232518AbiFNMiP (ORCPT ); Tue, 14 Jun 2022 08:38:15 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F3F634C424; Tue, 14 Jun 2022 05:35:12 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id BB541615C0; Tue, 14 Jun 2022 12:34:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9871EC3411E; Tue, 14 Jun 2022 12:34:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1655210085; bh=S7mRYBt8dKQ302Phsd6Akm5kJqqFOUkmEA1v3KsTPWU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=RnGKuF+/Y/3maKreiqaBVGd5HuZNeDQoPMRXQEpiMn/f8SIJpRly6PX6lIVouvSRe xRFy4EGBk0z6QKt+Lz8vk6SzVZNTytJsNMc59tX/IUD7KSvHaKZebzDN6GiCttUHep wXb4Tjb7kuj6K751aGII97hYZlNWKbGQyTiy30ylzeLfPk8aM7eYe2aDaylZCNoeQR ATclZjOy43jDWkMIsNXUmPF4JLxmfzu7IwS+MDaUS4slOfQg5l4B5Bz1S20GP1bc6b sBMsCSdmiWO4qBNgMSuBqkfY0qDHqU9XbdztWs0lH8KCt5CzSbvS7jQB/nQOXFnOd8 zwJhPQWCFHDxw== Date: Tue, 14 Jun 2022 15:32:38 +0300 From: "jarkko@kernel.org" To: "Edgecombe, Rick P" Cc: "hch@lst.de" , "christophe.leroy@csgroup.eu" , "mcgrof@kernel.org" , "svens@linux.ibm.com" , "palmer@dabbelt.com" , "jpoimboe@kernel.org" , "paulus@samba.org" , "zepan@sipeed.com" , "iii@linux.ibm.com" , "deller@gmx.de" , "aou@eecs.berkeley.edu" , "joey.gouly@arm.com" , "anemo@mba.ocn.ne.jp" , "egorenar@linux.ibm.com" , "ast@kernel.org" , "ardb@kernel.org" , "mpe@ellerman.id.au" , "linux-kernel@vger.kernel.org" , "linux-mips@vger.kernel.org" , "npiggin@gmail.com" , "thomas.lendacky@amd.com" , "bp@alien8.de" , "davem@davemloft.net" , "x86@kernel.org" , "luis.machado@linaro.org" , "ebiederm@xmission.com" , "mbenes@suse.cz" , "mingo@redhat.com" , "jniethe5@gmail.com" , "mark.rutland@arm.com" , "linux@armlinux.org.uk" , "paul.walmsley@sifive.com" , "andreyknvl@gmail.com" , "dja@axtens.net" , "liaochang1@huawei.com" , "linux-modules@vger.kernel.org" , "huschle@linux.ibm.com" , "will@kernel.org" , "akpm@linux-foundation.org" , "James.Bottomley@hansenpartnership.com" , "song@kernel.org" , "guoren@kernel.org" , "nathan@kernel.org" , "dave.anglin@bell.net" , "rostedt@goodmis.org" , "atomlin@redhat.com" , "bristot@redhat.com" , "naveen.n.rao@linux.ibm.com" , "anup@brainfault.org" , "javierm@redhat.com" , "linux@roeck-us.net" , "linus.walleij@linaro.org" , "philipp.tomsich@vrull.eu" , "linux-arm-kernel@lists.infradead.org" , "ndesaulniers@google.com" , "samitolvanen@google.com" , "yangtiezhu@loongson.cn" , "aneesh.kumar@linux.ibm.com" , "geert@linux-m68k.org" , "hpa@zytor.com" , "heiko@sntech.de" , "nathaniel@profian.com" , "michael.roth@amd.com" , "rmk+kernel@armlinux.org.uk" , "Sakkinen, Jarkko" , "catalin.marinas@arm.com" , "borntraeger@linux.ibm.com" , "dave.hansen@linux.intel.com" , "wangkefeng.wang@huawei.com" , "tmricht@linux.ibm.com" , "hca@linux.ibm.com" , "linux-parisc@vger.kernel.org" , "gor@linux.ibm.com" , "atishp@atishpatra.org" , "linuxppc-dev@lists.ozlabs.org" , "dmitry.torokhov@gmail.com" , "tglx@linutronix.de" , "kirill.shutemov@linux.intel.com" , "sparclinux@vger.kernel.org" , "broonie@kernel.org" , "tsbogend@alpha.franken.de" , "nico@fluxnic.net" , "masahiroy@kernel.org" , "agordeev@linux.ibm.com" , "kernel@esmil.dk" , "ashimida@linux.alibaba.com" , "elver@google.com" , "keescook@chromium.org" , "peterz@infradead.org" , "mhiramat@kernel.org" , "Keshavamurthy, Anil S" , "linux-riscv@lists.infradead.org" , "chenzhongjin@huawei.com" , "andrealmeid@igalia.com" , "changbin.du@intel.com" , "benh@kernel.crashing.org" , "linux-s390@vger.kernel.org" Subject: Re: [PATCH] kprobes: Enable tracing for mololithic kernel images Message-ID: References: <20220608000014.3054333-1-jarkko@profian.com> <20220608232115.ccd4399f4a1d133e9b65c2a9@kernel.org> <20220609034852.GA30873@lst.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jun 09, 2022 at 06:41:36PM +0000, Edgecombe, Rick P wrote: > On Thu, 2022-06-09 at 06:24 -0700, Luis Chamberlain wrote: > > On Thu, Jun 09, 2022 at 05:48:52AM +0200, Christoph Hellwig wrote: > > > On Wed, Jun 08, 2022 at 01:26:19PM -0700, Luis Chamberlain wrote: > > > > No, that was removed because it has only one user. > > > > > > That is only part of the story. The other part is that the overall > > > kernel simply does not have any business allocating exutable > > > memory. > > > Executable memory is a very special concept for modules or module- > > > like > > > code like kprobes, and should not be exposed as a general concept. > > > > It is not just modules and kprobes, it is also ftrace and bpf too > > now. > > So while it should not be used everywhere calling it module_alloc() > > is just confusing at this point. Likewise, module_alloc_huge() is > > being proposed too and I'd rather we deal with this properly in > > aligment > > of taking care of the rename as well. > > > > If the concern is to restrict access we can use the module namespace > > stuff > > so to ensure only intended users get access to it. > > BPF even has multiple uses for text allocation. It has its own > trampoline feature that puts different type of text in the allocation, > with its own allocation routine. I looks like there are even more > little allocators in there. > > So yea, there seems to be a lot of the kernel in the business of > dynamically generated text, for better or worse. I agree that it needs > to be done carefully. However, these usages always seem to have the > same problems (W^X, arch eccentricities, etc). So I don't think we > should hide away the pieces. Instead we should have something with > guard rails on it, so they can't get the allocation part wrong. > > But I guess the question here is: what should we do in the meantime? It > is kind of similar to the questions that came up around the bpf prog > pack allocator. Should we hold up allocator related work until > underlying problems are resolved and there is some mature core > solution? > > Personally I had thought we would need to do some clean switch to a > much different interface. I still think someday it will be required, > but it seems to be evolving naturally for the time being. > > Like say for a next step we moved prog pack out of bpf into core code, > gave it it's own copy of module_alloc(), and then made kprobes use it. > Then we would have something with improved W^X guard rails, and kprobes > would not depend on modules anymore. I think maybe it's a step in the > right direction, even if it's not perfect. So you're saying that I should (as a first step) basically clone module_alloc() implementation for kprobes, and future for BPF use, in order to get a clean starting point? BR, Jarkko