Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1263056

Re: [PATCH] livepatch: Cleanup page permission changes

From Jiri Kosina <jikos@kernel.org>
Newsgroups linux.kernel
Subject Re: [PATCH] livepatch: Cleanup page permission changes
Date 2015-11-05 10:50 +0100
Message-ID <qrpl8-4PH-9@gated-at.bofh.it> (permalink)
References (1 earlier) <qqH0L-1sK-53@gated-at.bofh.it> <qqNSy-5Uf-7@gated-at.bofh.it> <qrfc6-6Fb-45@gated-at.bofh.it> <qrfvr-72q-7@gated-at.bofh.it> <qrp1M-4Jn-7@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Thu, 5 Nov 2015, Jiri Kosina wrote:

> > > > +#ifdef CONFIG_DEBUG_SET_MODULE_RONX
> > > > +static void set_page_attributes(void *start, void *end,
> > > > +				int (*set)(unsigned long start, int num_pages))
> > > > +{
> > > > +	unsigned long begin_pfn = PFN_DOWN((unsigned long)start);
> > > > +	unsigned long end_pfn = PFN_DOWN((unsigned long)end);
> > > > +
> > > > +	if (end_pfn > begin_pfn)
> > > > +		set(begin_pfn << PAGE_SHIFT, end_pfn - begin_pfn);
> > > > +}
> 
> BTW is there any reason not to make use of the function from module.c 
> which does exactly the same, instead of copy pasting it all around?
> 
> > > > +static void set_module_ro_rw(struct module *mod)
> > > > +{
> > > > +	set_page_attributes(mod->module_core,
> > > > +			    mod->module_core + mod->core_ro_size,
> > > > +			    set_memory_rw);
> > > > +}
> > > > +static void set_module_ro_ro(struct module *mod)
> > > 
> > > Honestly, I find both the function names above horrible and not really 
> > > self-explanatory (especially the _ro_ro variant). At least comment, 
> > > explaining what they are actually doing, or picking up a better name, 
> > > would make the code much more self-explanatory in my eyes.
> > 
> > Being the patch author, naturally the function names make sense to me.
> 
> :)
> 
> > set_module_ro_ro() means "set the module's read-only area to have 
> > read-only permissions."
> >
> > Do you have any suggestions for a better name?
> 
> I'd even say it's superfluous to have the functions at the first place, 
> and just calling set_page_attributes() directly makes the intent clear 
> enough already.

To make my proposal more clear:

- move set_page_attributes() to module.h and provide empty stub for 
  !CONFIG_DEBUG_SET_MODULE_RONX case (and probably rename it to something 
  like module_set_page_attributes() to avoid namespace conflicts with mm 
  code)

- make use of that function both from module.c (where it's already being 
  used) and livepatch.c, where it'd be called directly

Thanks,

-- 
Jiri Kosina
SUSE Labs

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH] x86/livepatch: Fix crash with !CONFIG_DEBUG_SET_MODULE_RONX Josh Poimboeuf <jpoimboe@redhat.com> - 2015-11-02 21:10 +0100
  Re: [PATCH] x86/livepatch: Fix crash with  !CONFIG_DEBUG_SET_MODULE_RONX Miroslav Benes <mbenes@suse.cz> - 2015-11-03 11:30 +0100
    Re: [PATCH] x86/livepatch: Fix crash with  !CONFIG_DEBUG_SET_MODULE_RONX Josh Poimboeuf <jpoimboe@redhat.com> - 2015-11-03 16:30 +0100
    [PATCH] livepatch: Cleanup page permission changes Josh Poimboeuf <jpoimboe@redhat.com> - 2015-11-03 18:50 +0100
      Re: [PATCH] livepatch: Cleanup page permission changes Jiri Kosina <jikos@kernel.org> - 2015-11-04 10:20 +0100
        Re: [PATCH] livepatch: Cleanup page permission changes Josh Poimboeuf <jpoimboe@redhat.com> - 2015-11-04 17:20 +0100
          Re: [PATCH] livepatch: Cleanup page permission changes Josh Poimboeuf <jpoimboe@redhat.com> - 2015-11-04 17:20 +0100
      Re: [PATCH] livepatch: Cleanup page permission changes Miroslav Benes <mbenes@suse.cz> - 2015-11-04 10:50 +0100
      Re: [PATCH] livepatch: Cleanup page permission changes Jiri Kosina <jikos@kernel.org> - 2015-11-05 00:00 +0100
        Re: [PATCH] livepatch: Cleanup page permission changes Josh Poimboeuf <jpoimboe@redhat.com> - 2015-11-05 00:20 +0100
          Re: [PATCH] livepatch: Cleanup page permission changes Jiri Kosina <jikos@kernel.org> - 2015-11-05 10:30 +0100
            Re: [PATCH] livepatch: Cleanup page permission changes Jiri Kosina <jikos@kernel.org> - 2015-11-05 10:50 +0100
              Re: [PATCH] livepatch: Cleanup page permission changes Josh Poimboeuf <jpoimboe@redhat.com> - 2015-11-05 16:20 +0100
                Re: [PATCH] livepatch: Cleanup page permission changes Josh Poimboeuf <jpoimboe@redhat.com> - 2015-11-05 18:40 +0100

csiph-web