Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp1227083ybz; Thu, 16 Apr 2020 05:26:03 -0700 (PDT) X-Google-Smtp-Source: APiQypKJh3u9uHwp08lYp2VfbBKZ1xFMuOyxMhkXMYBMg/ylAVRFFEiXmbPNWRd+kVCTh5nRfXoM X-Received: by 2002:aa7:c5cf:: with SMTP id h15mr10223592eds.213.1587039963150; Thu, 16 Apr 2020 05:26:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587039963; cv=none; d=google.com; s=arc-20160816; b=mzroP+JteRBy0aPJvG0d+mXKar8xe/YRw0DcyMOcKvBw1TY1o/EU3WrBwVMWfTSPwV Q4iKqiREuMs5mD4wP+9GpVlvS3B6+jJWjhgR28ps4JXum8STm+hdzTuLyv/ozp4H+lQj qNJaUH70wfn/1fPrDx95NNCD3KBlzAznxb1x1M4j54zs2lpDfusr/j2tu1siYQjTYTqo MMVjM4pSklqLDWcjP0cToQl1JoRVOD2tBEVJgow55zq7qrTwc/sGhloCcdE+8J66X5ue YgLi/Cuy1C04wJ/f+gJpDkkTusQOTfzS3CIbQOqMA05XbyiH9R1KixqozrRoZQ21v+EJ tFAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=vqyaUkx8GR3JwQKbW/npDJYm+9ZLhBx+EmB8q5JLS1g=; b=BvtZADrqS6OISbflksayJ1K6ebtAH1rIEjGhHWYKGU/+Z20ukY1ZgOBhAaZ2TgnijT MS3sq73y1s2XNHx4PuWqBwcNXqjuKEGUL7nCtA9VXq3MGwLnVnvfzE+r4EeY/6LVQrSH 7dUeNp67UVaflknPnO3OnrTAzn8U+RLszGH33DZB2PLgig7XsQxFxyMOZmuAYODv7J0B kxjCtQNHwPr2dSY7MSrEZRaBVmlMtC9mKXXSp9TxGXgJkIdMOrpb2xAGZIWf62S8vW1/ 2jIh/BOYuJwASuKibWg/A+9go+AxghhpgofUZTuOpqLFdOS6efCCLLihNZlLGbm5x/0i Erkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=IWLMuW4s; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cm14si5550919edb.546.2020.04.16.05.25.39; Thu, 16 Apr 2020 05:26:03 -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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=IWLMuW4s; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2635524AbgDPMVp (ORCPT + 99 others); Thu, 16 Apr 2020 08:21:45 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:31857 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2635473AbgDPMVR (ORCPT ); Thu, 16 Apr 2020 08:21:17 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1587039675; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=vqyaUkx8GR3JwQKbW/npDJYm+9ZLhBx+EmB8q5JLS1g=; b=IWLMuW4sMqd1ybm2oqTmh62lqLQHvaYkDE0ZNgDODq/A/R7443rMSXCzBXn1jXPNTU/sbe X9F3sjia92aD3QJq1joi5XcgZkD3lG0IBsj8fg6OIDfqcL/sNrD0MI2MhnGWuvGQsJDmsJ BCd/lCKJQdDlvdCp4N2cqBBP5tUxusI= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-438-a-kyZDoHP2eJd_9KW0C3kQ-1; Thu, 16 Apr 2020 08:20:55 -0400 X-MC-Unique: a-kyZDoHP2eJd_9KW0C3kQ-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4A93C107B765; Thu, 16 Apr 2020 12:20:54 +0000 (UTC) Received: from treble (ovpn-116-146.rdu2.redhat.com [10.10.116.146]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9A7951001902; Thu, 16 Apr 2020 12:20:53 +0000 (UTC) Date: Thu, 16 Apr 2020 07:20:51 -0500 From: Josh Poimboeuf To: Miroslav Benes 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() Message-ID: <20200416122051.p3dk5i7h6ty4cwuc@treble> References: <20200414182726.GF2483@worktop.programming.kicks-ass.net> <20200414190814.glra2gceqgy34iyx@treble> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Apr 16, 2020 at 11:45:05AM +0200, Miroslav Benes wrote: > 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). Maybe I'm missing your point, but I don't see any races here. apply_relocate_add() only writes to the patch module's text, so there can't be races with other modules. -- Josh