Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1161190AbbKFKk7 (ORCPT ); Fri, 6 Nov 2015 05:40:59 -0500 Received: from mx2.suse.de ([195.135.220.15]:41221 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1033039AbbKFKk6 (ORCPT ); Fri, 6 Nov 2015 05:40:58 -0500 Date: Fri, 6 Nov 2015 11:40:55 +0100 From: Petr Mladek To: Josh Poimboeuf Cc: Seth Jennings , Jiri Kosina , Vojtech Pavlik , linux-kernel@vger.kernel.org, live-patching@vger.kernel.org, "Cyril B." , Rusty Russell , Miroslav Benes Subject: Re: [PATCH v2 3/3] livepatch: Cleanup module page permission changes Message-ID: <20151106104055.GL2599@pathway.suse.cz> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 Content-Length: 1553 Lines: 41 On Thu 2015-11-05 15:18:05, Josh Poimboeuf wrote: > Calling set_memory_rw() and set_memory_ro() for every iteration of the > loop in klp_write_object_relocations() is messy, inefficient, and > error-prone. > > Change all the read-only pages to read-write before the loop and convert > them back to read-only again afterwards. > > The {un}set_module_core_ro_nx() functions are used to change the > page permissions. Toggling NX isn't necessary in this case, but it's > not highly performance sensitive code so it should be fine. Hmm, the name (un)set_module_core_ro_nx() still sounds a bit strange, especially the "ro_nx" suffix. Alternative solution would be to create set_module_text_rw() set_module_text_ro() There already exists set_all_modules_text_rw() set_all_modules_text_ro() They modify only the ro/rw flags. IMHO, the name is more descriptive They are used by ftrace for very similar purpose. They modify also the init section. But we might want to touch it as well. klp_module_notify() is called too late now. But once we have a more complex consistency model, we will need to reject the module when the patching fails. We will need to call the livepatch init earlier, close to ftrace_module_init(mod). Then the init section might be interesting as well. Best Regards, Petr -- 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/