Re: [PATCH 0/7] livepatch,module: Remove .klp.arch and module_disable_ro()

From: Josh Poimboeuf
Date: Tue Apr 14 2020 - 15:40:41 EST


On Tue, Apr 14, 2020 at 08:27:26PM +0200, Peter Zijlstra wrote:
> On Tue, Apr 14, 2020 at 11:28:36AM -0500, Josh Poimboeuf wrote:
> > Better late than never, these patches add simplifications and
> > improvements for some issues Peter found six months ago, as part of his
> > non-writable text code (W^X) cleanups.
>
> Excellent stuff, thanks!!
>
> I'll go brush up these two patches then:
>
> https://lkml.kernel.org/r/20191018074634.801435443@xxxxxxxxxxxxx
> https://lkml.kernel.org/r/20191018074634.858645375@xxxxxxxxxxxxx

Ah right, I meant to bring that up. I actually played around with those
patches. While it would be nice to figure out a way to converge the
ftrace module init, I didn't really like the first patch.

It bothers me that both the notifiers and the module init() both see the
same MODULE_STATE_COMING state, but only in the former case is the text
writable.

I think it's cognitively simpler if MODULE_STATE_COMING always means the
same thing, like the comments imply, "fully formed" and thus
not-writable:

enum module_state {
MODULE_STATE_LIVE, /* Normal state. */
MODULE_STATE_COMING, /* Full formed, running module_init. */
MODULE_STATE_GOING, /* Going away. */
MODULE_STATE_UNFORMED, /* Still setting it up. */
};

And, it keeps tighter constraints on what a notifier can do, which is a
good thing if we can get away with it.

> and write a patch that makes the x86 code throw a wobbly on W+X.
>
> Acked-by: Peter Zijlstra (Intel) <peterz@xxxxxxxxxxxxx>

Thanks!

--
Josh