Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp1096299ybz; Thu, 16 Apr 2020 02:49:02 -0700 (PDT) X-Google-Smtp-Source: APiQypJuXSIAoV3L8N1OTm9cxj4f3BLcmYJ0SubGwl3WD9jYcuak0K/gBbiATL7q6sWjrG2FdRQB X-Received: by 2002:a17:906:16ca:: with SMTP id t10mr9111593ejd.122.1587030542568; Thu, 16 Apr 2020 02:49:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587030542; cv=none; d=google.com; s=arc-20160816; b=iPwVThSh3hUqljRyBxEZuYeYSaaP6HjYe70cZ4S8SeShKX2nin668QKzCpXNDFfKCV wMzub68+PEYYcfGQXxAQHNjO9+fuzvoYOLNzmhB+zSRUk+UW+o+xavxvlcRRWLLdti6/ ZEeT/CZ/imG1Ivn1lrX4O5ikWTglf72li+UCAXqasLx8x/xWWh5JUItWKGpARXoi9b+B h+tGS4nDmVI8QsrU3Z1wM8qkk5M2ZMplA92ch1NS2VdvoSKMAzRnVXD59TpN95kAHYNf YT1suE3QgOK+3O19/BejsG2G6zpVBtQMpTOuytyStBugJYI7Q84CY7ZKiIBmo+TP0Y/p BD1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date; bh=UmphiX+D5ljucD9UmK8kFDnG54gmnzLfAURAcjys2bs=; b=bgnuphHq3PHC6IXwgq0Q4GdhqXMSH+HWJ+yCAy4KfjE+0Ulm+VAy9Yx5lWBCDfVt31 zaF4nEfKJnw5I4xoaY9rCivyqwE4+in/9nNFIVGC5iyw/79GIcbOQ8Zr16xufzBvOTsn DrVnhtbvSNAGZOQd6psbEUZFdkq+mWNwnaKxXJc+gKQ2iZ7zFMNR8I6stf8O14NOwCHb 8TZz/kBJKXNCKjvlqwyYM6FkmsWD0qdmaZaAQC+CHgObtF6gV2Ire637SYDI5a3qmC0D gC0swgSRy8ug5YJenVNX/hI1K6ivRI43nhqZgR51n13DH/K3m4SQllWbTDAUggXm38xZ 9DaQ== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k4si15995309edk.585.2020.04.16.02.48.38; Thu, 16 Apr 2020 02:49:02 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2504134AbgDPJpM (ORCPT + 99 others); Thu, 16 Apr 2020 05:45:12 -0400 Received: from mx2.suse.de ([195.135.220.15]:41080 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2503578AbgDPJpI (ORCPT ); Thu, 16 Apr 2020 05:45:08 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 08D91AE19; Thu, 16 Apr 2020 09:45:06 +0000 (UTC) Date: Thu, 16 Apr 2020 11:45:05 +0200 (CEST) From: Miroslav Benes To: Josh Poimboeuf cc: Peter Zijlstra , live-patching@vger.kernel.org, linux-kernel@vger.kernel.org, Jessica Yu Subject: Re: [PATCH 0/7] livepatch,module: Remove .klp.arch and module_disable_ro() In-Reply-To: <20200414190814.glra2gceqgy34iyx@treble> Message-ID: References: <20200414182726.GF2483@worktop.programming.kicks-ass.net> <20200414190814.glra2gceqgy34iyx@treble> User-Agent: Alpine 2.21 (LSU 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 14 Apr 2020, Josh Poimboeuf wrote: > 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@infradead.org > > https://lkml.kernel.org/r/20191018074634.858645375@infradead.org > > 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. Agreed. On the other hand, the first patch would remove the tiny race window when a module state is still UNFORMED, but the protections are (being) set up. Patches 4/7 and 5/7 allow to use memcpy in that case, because it is early. But it is in fact not already. I haven't checked yet if it really matters somewhere (a race with livepatch running klp_module_coming while another module is being loaded or anything like that). Miroslav