Received: by 2002:a5d:925a:0:0:0:0:0 with SMTP id e26csp431370iol; Thu, 9 Jun 2022 06:45:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzJZ8+8pTq58OlJ8DEeNbHEVcdrFsfqr27xHM5yozkfKrtEEejALPLgbUNOIlVgzeLcvgdD X-Received: by 2002:a17:902:bd94:b0:168:9d30:dd08 with SMTP id q20-20020a170902bd9400b001689d30dd08mr6822728pls.46.1654782332758; Thu, 09 Jun 2022 06:45:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654782332; cv=none; d=google.com; s=arc-20160816; b=VRB2R3srvC1VkW2/qJcWZtN0F5n/T3G9dzmDvQklhv9VWOAhSy/M8G5EOmdiYWLJVO 5+qpMhfFci0VBROSEeAhP/RrXHxx97PdLtFL56By8MYCTRkQx/AMxLcyroozR6ZDQs3k GydPHAe/Hy/popjmhXKr45bvUWIQBGK1PtxwGZvENdXgk4bd34hJ6+nJzY3GxlC2OOGi 5ee/xy5JYZEA6n7/TB4XMWPipZTK8KkTQntW+JcOEwFlgNzDE7VwFcVdI63akkAkLQ+d gnqJHwE5xtbFmeksElR3N5Ok+7og9vMBGw7Ewzm0WW/8JejTB/ePYtx/F5oWgentOYuK 4umA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=SFRCVVrRGHSCzaC+svV91Zy2fb9KgpsgW9PodQQtuVA=; b=Gsa5cYq3vyGmiJglRj9xM7GoPpWrMkpp2UPPSt/ldWu6hkig4eF1Z3a2uKBHR3zGcM GDvgn6NTpkypS14tPloQzbedFouKW4361elhIBnIXjy1M4K7FOERhWOCkm4TCVX2e9Mr +hs5ZwaGC106jgyV8q81zRhrCAXxk2W7bpeXljLBeHeVhALJqT7nFptRwYjGfPRQ0o1a 1+SWgHvoIRAHnqyqjvQz5/acJGEiVdKvQ066nUZXYuVeC+t59sF+po1IybB61yTqSH1h t2/UdICvJbkieAq/laREUu4LTKdfomh+zPTNjK/2nQsCol4a0UnsByhbOQrpdl+r+W6Q JeBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=ZXUIBRWw; 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 d13-20020a056a00244d00b0051b3a927ad4si31374714pfj.289.2022.06.09.06.45.20; Thu, 09 Jun 2022 06:45:32 -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=@infradead.org header.s=bombadil.20210309 header.b=ZXUIBRWw; 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 S1343784AbiFINYx (ORCPT + 99 others); Thu, 9 Jun 2022 09:24:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47878 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343879AbiFINYq (ORCPT ); Thu, 9 Jun 2022 09:24:46 -0400 Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CF9A31451CA; Thu, 9 Jun 2022 06:24:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=SFRCVVrRGHSCzaC+svV91Zy2fb9KgpsgW9PodQQtuVA=; b=ZXUIBRWwS9a1A+i7Wlnvbq7c8v 6SK4in80vdIW70IGh6Qwe/9mFxNaBZtzv0uCfovEqg5B7wUC50nw2bh7ER+xaP3QNR+1iZYXnNxos S1DekrsiVQcuauqgAW2+sZFC/1rHvD65HUzk2WexFzY/WbUzTA0pWZot8NWi77yxehXc35lrntlkB Qm2bnOZFbox6CvC5LSuNuJ2I85jiSSXcaN35yBtUgsVQkHMxSoBGhW1SghmYnnm8iMvnQWF6TnUmW X1ud3JxTTmlPwgF7s5xG9BVcKDfLwreRR4yef4m+LNO6b+HhdBpLgVt2qZH1BGOEUFylRzfms6+VM DcV1sHDg==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1nzI9A-0027yT-Ln; Thu, 09 Jun 2022 13:24:24 +0000 Date: Thu, 9 Jun 2022 06:24:24 -0700 From: Luis Chamberlain To: Christoph Hellwig , "Edgecombe, Rick P" , Christophe Leroy Cc: Song Liu , Masami Hiramatsu , Jarkko Sakkinen , Guo Ren , Jarkko Sakkinen , Linux Kernel Mailing List , Nathaniel McCallum , Russell King , Catalin Marinas , Will Deacon , Thomas Bogendoerfer , "James E.J. Bottomley" , Helge Deller , Michael Ellerman , Benjamin Herrenschmidt , Paul Mackerras , Paul Walmsley , Palmer Dabbelt , Albert Ou , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Sven Schnelle , "David S. Miller" , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , the arch/x86 maintainers , "H. Peter Anvin" , "Naveen N. Rao" , Anil S Keshavamurthy , Steven Rostedt , Kees Cook , "Peter Zijlstra (Intel)" , Nathan Chancellor , Josh Poimboeuf , Mark Rutland , "Eric W. Biederman" , Marco Elver , Dan Li , Sami Tolvanen , Ard Biesheuvel , "Russell King (Oracle)" , Nick Desaulniers , Linus Walleij , Chen Zhongjin , Nicolas Pitre , Mark Brown , Luis Machado , Geert Uytterhoeven , Joey Gouly , Masahiro Yamada , Andrew Morton , Andrey Konovalov , Kefeng Wang , Atsushi Nemoto , Guenter Roeck , Dave Anglin , Alexei Starovoitov , Nicholas Piggin , Daniel Axtens , "Aneesh Kumar K.V" , Jordan Niethe , Anup Patel , Atish Patra , Changbin Du , Heiko Stuebner , Liao Chang , Philipp Tomsich , Wu Caize , Emil Renner Berthing , Alexander Egorenkov , Thomas Richter , Tobias Huschle , Ilya Leoshkevich , Tom Lendacky , Daniel Bristot de Oliveira , Michael Roth , "Kirill A. Shutemov" , Javier Martinez Canillas , Miroslav Benes , =?iso-8859-1?Q?Andr=E9?= Almeida , Tiezhu Yang , Dmitry Torokhov , Aaron Tomlin , Linux ARM , "open list:BROADCOM NVRAM DRIVER" , Parisc List , linuxppc-dev , linux-riscv , linux-s390 , sparclinux , linux-modules@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: <20220609034852.GA30873@lst.de> Sender: Luis Chamberlain X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=no 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 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. > Especially as executable memory really should not also be writable > for security reasons. In other words, we should actually never > allocate executable memory, every. We might seal memory and then > mark it executable after having written to it, which is how modules > and kprobes are implemented on all modern Linux ports anyway. The respective free *should* do the executable bits, and there is no generic way to do this for all archs and so it is open coded today. In fact some architectures need further work / help and so split up the module data and exect already on v5.19+ with the new ARCH_WANTS_MODULES_DATA_IN_VMALLOC. See this thread for details: https://lkml.kernel.org/r/Yo1XTN441qbNTLGR@bombadil.infradead.org Doing this work is not easy, but if we're going to do it, it must be done right. Luis