Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp968119ybh; Wed, 22 Jul 2020 18:53:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw+DiKM+Ig1cOjuk4maC/qA8eQk5yhIcKIB6MPNpxTRBaxanGW4JxCE6uhnUMn8/als27th X-Received: by 2002:a50:9b18:: with SMTP id o24mr2042616edi.335.1595469189794; Wed, 22 Jul 2020 18:53:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595469189; cv=none; d=google.com; s=arc-20160816; b=AORoQTC1yE6XnC5aCmyBZXRUbVZIJDud7fwYhh/8Mp8AVZg/+O83P7da8ZchdEo6vn DlERuduxUahenw+7DONGxcjqrUV1A4YbrqLC96IfQLXObRSWrIxEK40pgFwqsbpURhLZ i+NGphcDdZOFYQ8cvQgA/ZScLxvbsSafnJg2KZBMemY3VuTvEAHFlSACuluqlwNhuyUw CUEXk2X8NUs9EQnlWEaXCu9XYzjn7+SP/Hw1xUU1YpHk8TvObnOoJS8yOPAB7gnb/nzn si12u3f/Y6yd03fPVcp+plOIlZ6EZnX7Cj6j7o8yb0CqhWM2zzV6yJ10GjqMA61GogV4 HFPQ== 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=3tb/h2sq803Sz+fUkIvZrL9FWAhSySnj3loKejxqInk=; b=oaVdLrohBiAp6Kt+zZDd3/c3Zb9vjzQE+geXw7m40rq5AdS4rEMOO3DMbOJkRaWDB0 i/sjgHoUjDoUcKTtB10sSLKlXZw5s2xUB+mql8/YOl3zVjV+WmaoiKszNqJyDhfGFpI6 Vs1ihgYLsdfLdAovs8+G1uMqsxzyJBCzPhodfmv1WhdfIHpNOSbNhhDQxCYMHvI7GEeg LZm5UOMJ2OqjP0XHa1y8ipBFHOOml/Z1XsqWMWVJWyrsjpFl72Z127NQ0+hsOeQA2POS 2EaZnSXXhM3yfMrfHjrQ3F4vwYnncyhpQz7HznVpEyMin9bD3rBjpI0tim8x8v2x/F0N FR2A== 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 c89si1071164edf.35.2020.07.22.18.52.47; Wed, 22 Jul 2020 18:53:09 -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 S2387647AbgGWBte (ORCPT + 99 others); Wed, 22 Jul 2020 21:49:34 -0400 Received: from mga06.intel.com ([134.134.136.31]:35650 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729198AbgGWBte (ORCPT ); Wed, 22 Jul 2020 21:49:34 -0400 IronPort-SDR: YlR3QaPbj5FXFizj8d1UwsMb8q3DyyccbG/crMscL69aj4nxolIxplDt7kRdSUw7wbbxrGssAo cVeUI6O78h6w== X-IronPort-AV: E=McAfee;i="6000,8403,9690"; a="211994602" X-IronPort-AV: E=Sophos;i="5.75,383,1589266800"; d="scan'208";a="211994602" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jul 2020 18:49:33 -0700 IronPort-SDR: QNP5KVt6QKgtWmoKOqeRoCIe45AqIHZRKo7xbNWyj+G+DYPdMKxxIdxZ6DQosE8B7coErHBY0h jolHgiunVirA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,383,1589266800"; d="scan'208";a="270910468" Received: from schwings-mobl.ger.corp.intel.com (HELO localhost) ([10.252.33.132]) by fmsmga007.fm.intel.com with ESMTP; 22 Jul 2020 18:49:17 -0700 Date: Thu, 23 Jul 2020 04:49:16 +0300 From: Jarkko Sakkinen To: Peter Zijlstra Cc: linux-kernel@vger.kernel.org, x86@vger.kernel.org, Andi Kleen , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)" , "H. Peter Anvin" , "Naveen N. Rao" , Anil S Keshavamurthy , "David S. Miller" , Masami Hiramatsu , Jessica Yu , Andrew Morton , "Aneesh Kumar K.V" , Kees Cook , Will Deacon , Sami Tolvanen , Alexandre Ghiti , Masahiro Yamada , Peter Collingbourne , Frederic Weisbecker , Krzysztof Kozlowski , Arnd Bergmann , Stephen Boyd , Andy Lutomirski , Josh Poimboeuf , Miroslav Benes , Babu Moger , Omar Sandoval , Nayna Jain , Marco Elver , Brian Gerst , Jiri Kosina , Joe Lawrence , Mike Rapoport Subject: Re: [PATCH v3 1/3] kprobes: Add text_alloc() and text_free() Message-ID: <20200723014916.GD45081@linux.intel.com> References: <20200714223239.1543716-1-jarkko.sakkinen@linux.intel.com> <20200714223239.1543716-2-jarkko.sakkinen@linux.intel.com> <20200716090253.GP10769@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200716090253.GP10769@hirez.programming.kicks-ass.net> 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 Thu, Jul 16, 2020 at 11:02:53AM +0200, Peter Zijlstra wrote: > On Wed, Jul 15, 2020 at 01:32:27AM +0300, Jarkko Sakkinen wrote: > > +void *text_alloc(unsigned long size) > > +{ > > + void *p; > > + > > + if (PAGE_ALIGN(size) > MODULES_LEN) > > + return NULL; > > + > > + p = __vmalloc_node_range(size, MODULE_ALIGN, > > + MODULES_VADDR + get_module_load_offset(), > > + MODULES_END, GFP_KERNEL, > > + PAGE_KERNEL, 0, NUMA_NO_NODE, > > + __builtin_return_address(0)); > > + if (p && (kasan_module_alloc(p, size) < 0)) { > > + vfree(p); > > + return NULL; > > + } > > + > > + return p; > > +} > > + > > +void text_free(void *region) > > +{ > > + /* > > + * This memory may be RO, and freeing RO memory in an interrupt is not > > + * supported by vmalloc. > > + */ > > + WARN_ON(in_interrupt()); > > I think that wants to be: > > lockdep_assert_irqs_enabled(); > > in_interrupt() isn't sufficient, interrupts must also not be disabled > when issuesing TLB invalidations. Shouldn't it be then also fixed in the module_memfree() fallback implementation (kernel/module.c)? /Jarkko