Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp2662046ybh; Fri, 24 Jul 2020 20:20:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyoYBjJGOGwfZ6IbT00dyew6iplf6jaliFj/vZzOxcwtMTT8o12JkAbAqLA5/YK1MgDt/e6 X-Received: by 2002:a17:906:a40d:: with SMTP id l13mr10559203ejz.491.1595647226898; Fri, 24 Jul 2020 20:20:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595647226; cv=none; d=google.com; s=arc-20160816; b=O+tifcAiTdM/MeAVB/c1xHfHp+P+2tY/MvMz88ajgjBH7ltxX07ur9smZIZsC3TCvP V9YpSW+/1FIbKSn8IaKyGnc6203dGLy64Bmxln1fZucuIrBnrSwY3ADPDYDERfF5qhnY vJUtdzz/0KkuFehgy6By+eo8+yn3bpVxtmlWInxqmRAi2BTRe70Ud5yum2tWBEgS4A7Y wqB+eMQwWiUCslIgsWM0xLV27e0OZ2V4UFRwjqg6uPsRAZpAVTw5ZfmkhGflFJGdcFoD LOAFPVtC7kYobvTIsPh+bwf2xaMO1xORJh8dCNGHWsk+9wFk1/9g9nBQfS2mkiARW/Cg +7fg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:organization:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:ironport-sdr:ironport-sdr; bh=AvD40Bun390rzu6PfjhFS+0yiHKC1qgaWGjhzcGhlSs=; b=vAzL8Vs2UAR9FqJ7/K9UDjE9Q/wW0IzKRaljDt43zScwpzJwKqDCNqa0BV8tcpjEms 7Wqvzc5fs0mzI7g2C4alU39fIcJ+lF4EiZ2EgYcr5BMMLCWV/zPtdesT3Cic/s0gZ0wJ Lro6oMTGNqZrclv/3w52d1ACNxqzZk0A4d7yIKqvCTvG/lEb41+/7glHCIycs44db9Jd pouF8CXETNZoQDRljRanrBTWfpTYPDezciE7EvMzwmak4FxQ8tPs44jpu0JLKYPCLy3n AqfQEyF4s51LcvGySMnHtfQysdlrzi3YIUnJH0Y6V1UNpDxcYyChksusvBS9Ufh0apYK nNwQ== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v2si1698324eda.484.2020.07.24.20.20.04; Fri, 24 Jul 2020 20:20:26 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726686AbgGYDTT (ORCPT + 99 others); Fri, 24 Jul 2020 23:19:19 -0400 Received: from mga03.intel.com ([134.134.136.65]:64414 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726572AbgGYDTT (ORCPT ); Fri, 24 Jul 2020 23:19:19 -0400 IronPort-SDR: p1fCmPYYJggvcYmHPaywObo2/8T0/KAWO4dAHiSVm/gM9toWuh2Cj4G6+B+r60DFzalZ9cYkxn kraHVn76qoGw== X-IronPort-AV: E=McAfee;i="6000,8403,9692"; a="150801395" X-IronPort-AV: E=Sophos;i="5.75,392,1589266800"; d="scan'208";a="150801395" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Jul 2020 20:19:19 -0700 IronPort-SDR: rF/DkQl54TI4Kf7+dlXHs3+a+C2DbqtD6D7pz5Fjiclb1b+Wq8Nd2Ee4WrJzgbyUzdgZM1Szvp tE+SJlCJ+m1Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,392,1589266800"; d="scan'208";a="363549309" Received: from jcrametz-mobl.ger.corp.intel.com (HELO localhost) ([10.252.58.73]) by orsmga001.jf.intel.com with ESMTP; 24 Jul 2020 20:19:13 -0700 Date: Sat, 25 Jul 2020 06:19:11 +0300 From: Jarkko Sakkinen To: Ard Biesheuvel Cc: Ingo Molnar , Linux Kernel Mailing List , linux-mm@kvack.org, Andi Kleen , Masami Hiramatsu , Peter Zijlstra , "Naveen N. Rao" , Anil S Keshavamurthy , "David S. Miller" , Jessica Yu Subject: Re: [PATCH v5 5/6] kprobes: Use text_alloc() and text_free()] Message-ID: <20200725031911.GH17052@linux.intel.com> References: <20200724050553.1724168-1-jarkko.sakkinen@linux.intel.com> <20200724050553.1724168-6-jarkko.sakkinen@linux.intel.com> <20200724092746.GD517988@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jul 24, 2020 at 03:16:08PM +0300, Ard Biesheuvel wrote: > On Fri, 24 Jul 2020 at 12:27, Ingo Molnar wrote: > > > > > > * Jarkko Sakkinen wrote: > > > > > Use text_alloc() and text_free() instead of module_alloc() and > > > module_memfree() when an arch provides them. > > > > > > Cc: linux-mm@kvack.org > > > Cc: Andi Kleen > > > Cc: Masami Hiramatsu > > > Cc: Peter Zijlstra > > > Signed-off-by: Jarkko Sakkinen > > > --- > > > kernel/kprobes.c | 9 +++++++++ > > > 1 file changed, 9 insertions(+) > > > > > > diff --git a/kernel/kprobes.c b/kernel/kprobes.c > > > index 4e46d96d4e16..611fcda9f6bf 100644 > > > --- a/kernel/kprobes.c > > > +++ b/kernel/kprobes.c > > > @@ -40,6 +40,7 @@ > > > #include > > > #include > > > #include > > > +#include > > > > > > #define KPROBE_HASH_BITS 6 > > > #define KPROBE_TABLE_SIZE (1 << KPROBE_HASH_BITS) > > > @@ -111,12 +112,20 @@ enum kprobe_slot_state { > > > > > > void __weak *alloc_insn_page(void) > > > { > > > +#ifdef CONFIG_ARCH_HAS_TEXT_ALLOC > > > + return text_alloc(PAGE_SIZE); > > > +#else > > > return module_alloc(PAGE_SIZE); > > > +#endif > > > } > > > > > > void __weak free_insn_page(void *page) > > > { > > > +#ifdef CONFIG_ARCH_HAS_TEXT_ALLOC > > > + text_free(page); > > > +#else > > > module_memfree(page); > > > +#endif > > > } > > > > I've read the observations in the other threads, but this #ifdef > > jungle is silly, it's a de-facto open coded text_alloc() with a > > module_alloc() fallback... > > > > Also, as I attempted to explain before, there is no reason to allocate > kasan shadow for any of these use cases, so cloning module_alloc() to > implement text_alloc() is not the correct approach even on x86. > > I suppose module_alloc() could be reimplemented in terms of > text_alloc() in this case, but simply relabelling it like this seems > inappropriate on all architectures. I agree with this. Even if there was chance to do a merge of some kind, it should probably happen over time and accept some redundancy first. /Jarkko