From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753752AbcBXAzI (ORCPT ); Tue, 23 Feb 2016 19:55:08 -0500 Received: from mx2.suse.de ([195.135.220.15]:45673 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751949AbcBXAzF (ORCPT ); Tue, 23 Feb 2016 19:55:05 -0500 Date: Wed, 24 Feb 2016 01:54:58 +0100 From: "Luis R. Rodriguez" To: "H. Peter Anvin" Cc: "Luis R. Rodriguez" , Thomas Gleixner , Ingo Molnar , Borislav Petkov , X86 ML , "linux-kernel@vger.kernel.org" , Andy Lutomirski , Boris Ostrovsky , Rusty Russell , David Vrabel , Konrad Rzeszutek Wilk , Michael Brown , Juergen Gross , Ming Lei , Greg Kroah-Hartman , Arnd Bergmann , linux-arch@vger.kernel.org, Russell King , Benjamin Herrenschmidt , jbaron@akamai.com, ananth@in.ibm.com, anil.s.keshavamurthy@intel.com, David Miller , Masami Hiramatsu , andriy.shevchenko@linux.intel.com, David Woodhouse , "xen-devel@lists.xensource.com" , linux-security-module Subject: Re: [RFC v2 2/7] tables.h: add linker table support Message-ID: <20160224005458.GK25240@wotan.suse.de> References: <1455889559-9428-1-git-send-email-mcgrof@kernel.org> <1455889559-9428-3-git-send-email-mcgrof@kernel.org> <56C77A53.6060708@zytor.com> <20160219214856.GX25240@wotan.suse.de> <56CCE9B6.4080000@zytor.com> <56CCF41F.8080507@zytor.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <56CCF41F.8080507@zytor.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Feb 23, 2016 at 04:06:55PM -0800, H. Peter Anvin wrote: > On 02/23/2016 03:36 PM, Luis R. Rodriguez wrote: > > > >> 4. the only useful operator on a range is "is address X inside this > >> range"; this operator is likely *not* useful for a table, since ^^^^^^^^^^^^ > >> if you have to ever invoke it you are probably doing something very > >> wrong. > > > > kprobe uses it :P > > > > Could you explain how? Sorry I misread this as "unless you are a table", kprobes has two ranges, one is a table (blacklist) and the other just a range (for kprobes); only kprobes uses "address inside this range", as reflected below. So I agree with you. index d10ab6b9b5e0..d816c659f358 100644 --- a/kernel/kprobes.c +++ b/kernel/kprobes.c @@ -1328,8 +1328,7 @@ out: bool __weak arch_within_kprobe_blacklist(unsigned long addr) { /* The __kprobes marked functions and entry code must not be probed */ - return addr >= (unsigned long)__kprobes_text_start && - addr < (unsigned long)__kprobes_text_end; + return LINKTABLE_ADDR_WITHIN(kprobes, addr); } bool within_kprobe_blacklist(unsigned long addr) diff --git a/kernel/kprobes.c b/kernel/kprobes.c index d10ab6b9b5e0..d816c659f358 100644 --- a/kernel/kprobes.c +++ b/kernel/kprobes.c @@ -1328,8 +1328,7 @@ out: bool __weak arch_within_kprobe_blacklist(unsigned long addr) { /* The __kprobes marked functions and entry code must not be probed */ - return addr >= (unsigned long)__kprobes_text_start && - addr < (unsigned long)__kprobes_text_end; + return LINKTABLE_ADDR_WITHIN(kprobes, addr); } What about rebranding general section primitives under section.h #define DECLARE_SECTION_TEXT_TYPE(type, name) \ extern const type name[], name##__end[]; #define DECLARE_SECTION_TEXT(name) \ DECLARE_SECTION_TEXT_TYPE(char, name) Then tables.h would use the TYPE version: #define DECLARE_LINKTABLE_TEXT(type, name) \ DECLARE_SECTION_TEXT_TYPE(type, name) Since I've been making _TEXT the implicit type for section names(SECTION_INIT is .init.text) the above could just be DECLARE_SECTION_TYPE() and DECLARE_SECTION() for text if we prefer. Luis