Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1267946rwd; Tue, 16 May 2023 14:35:08 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4mSe2b4C7Eq+2xQ/hxC6V/HVU13p3mzG2yPgNL2uETiYUJFVFfJbr8zBJ3kIAOVEvi+QPi X-Received: by 2002:a17:903:2292:b0:1a9:bdf8:f551 with SMTP id b18-20020a170903229200b001a9bdf8f551mr45306165plh.69.1684272907773; Tue, 16 May 2023 14:35:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684272907; cv=none; d=google.com; s=arc-20160816; b=clNUq1Uya8QhfHjrCaqBG7DJLNQ2WOwyUk9uybFXGbO37+P6V7NPJIxU/CM6GfOJ1U 1OO94aWQVF9qNUj0iu3gWs/XGeqa3TQ4LX+DaLLjt/loFEF78eMOdW1fiC2eZOTox2DA LRKNttkk56vOG5s4F4GEsXQJumsE8nbMB8FGwhU1IYYHD7NPCOTRqU3JqjpOHRmeHfB7 j5rptz5/dT7Jkc+P5CZX64j3iYXytYjUtV4IjujkED5das5WvaX5TX48pAICqmUd9LjH 2rAIB3n3x/lO+C/uh31FRelcY6K60rwO2TIT5GNQ4ERR7F77/trHGeXaE6F1A8NsjkKt kYDA== 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:dkim-signature:date; bh=dbkTng8H6hiTn8uKTCVsk8fFMRZsv0G437tHoNcRdyw=; b=sBQmHgqNh7POSryGd33etBI3YXpwbRRF0llLZNfd5iNfLORgZr91rFwqbFWYhOyiff YGwWqq68W/OYImADNPdYmD6KR46SDeljFvUkKudPbdSsxuxUHmsKu3XPz2vLd3al32MB LlmcAHK1Oc9OgSu/njN2tci20KmNKHNSau8J/jB/OpPEIVAc1hIdRBI+EqIwXrB0f0LI /gOwWR51eYIt+Qmk5nKodV+/Hk5AROIPpGq4FrLvm1cdG8nAsNX1Hj5HQHOQ0Q8vNgOh a+WLMA/rfbzdxrWkKqZtpsNRkRDXfkhNV35WHAOMOdkIlPqoKhc8rUJiKpc1kiuf7j04 48CQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=SibD303e; 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=linux.dev Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r9-20020a170902be0900b001aaf7a9d7aasi18157129pls.126.2023.05.16.14.34.55; Tue, 16 May 2023 14:35:07 -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=@linux.dev header.s=key1 header.b=SibD303e; 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=linux.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230440AbjEPVUp (ORCPT + 99 others); Tue, 16 May 2023 17:20:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44358 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230454AbjEPVUm (ORCPT ); Tue, 16 May 2023 17:20:42 -0400 Received: from out-33.mta0.migadu.com (out-33.mta0.migadu.com [IPv6:2001:41d0:1004:224b::21]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0DD4B61AD for ; Tue, 16 May 2023 14:20:40 -0700 (PDT) Date: Tue, 16 May 2023 17:20:33 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1684272038; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=dbkTng8H6hiTn8uKTCVsk8fFMRZsv0G437tHoNcRdyw=; b=SibD303eoaJKDw/Qhvvh03L8pvarBF0nYUklNoNZHgjjEpZ53aMlv5snN9FpqFXPEHQbx0 LHXWrEV8byrPRslwxSNZj55hzeuxAFGK+ubsNu2p2v/2BFgQ2akuSeiuhIiYnhMwXR9Doi pF/mjBYG4GZWtq5+dZGjxFVscbKXIck= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Kent Overstreet To: Kees Cook Cc: Johannes Thumshirn , "linux-kernel@vger.kernel.org" , "linux-fsdevel@vger.kernel.org" , "linux-bcachefs@vger.kernel.org" , Kent Overstreet , Andrew Morton , Uladzislau Rezki , "hch@infradead.org" , "linux-mm@kvack.org" , "linux-hardening@vger.kernel.org" Subject: Re: [PATCH 07/32] mm: Bring back vmalloc_exec Message-ID: References: <20230509165657.1735798-1-kent.overstreet@linux.dev> <20230509165657.1735798-8-kent.overstreet@linux.dev> <3508afc0-6f03-a971-e716-999a7373951f@wdc.com> <202305111525.67001E5C4@keescook> <202305161401.F1E3ACFAC@keescook> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <202305161401.F1E3ACFAC@keescook> X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=unavailable 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 Tue, May 16, 2023 at 02:02:11PM -0700, Kees Cook wrote: > For something that small, why not use the text_poke API? This looks like it's meant for patching existing kernel text, which isn't what I want - I'm generating new functions on the fly, one per btree node. I'm working up a new allocator - a (very simple) slab allocator where you pass a buffer, and it gives you a copy of that buffer mapped executable, but not writeable. It looks like we'll be able to convert bpf, kprobes, and ftrace trampolines to it; it'll consolidate a fair amount of code (particularly in bpf), and they won't have to burn a full page per allocation anymore. bpf has a neat trick where it maps the same page in two different locations, one is the executable location and the other is the writeable location - I'm stealing that. external api will be: void *jit_alloc(void *buf, size_t len, gfp_t gfp); void jit_free(void *buf); void jit_update(void *buf, void *new_code, size_t len); /* update an existing allocation */