Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp1082895ybz; Thu, 16 Apr 2020 02:30:11 -0700 (PDT) X-Google-Smtp-Source: APiQypIz72barDk3SOZkHPPyMOljMQla9am7dohjY1yS7rsnXFCZOp/S+rCa5A4geNX92abKNVvA X-Received: by 2002:a50:d596:: with SMTP id v22mr408544edi.91.1587029411230; Thu, 16 Apr 2020 02:30:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587029411; cv=none; d=google.com; s=arc-20160816; b=bO6RZNxyr62cPwysczzZri0fRdj1bckW0nae+QNmM0mKg8O7cBWCBlyRx0pe7qUcrt hrH2lr3rsUM3gOBmGO1H2CSJc/ahqHiwelkzRJHQh2t0pWgc68R9i4kOFgz1xS8HDsIl fC6vFlCnXNcCuWcA7keTdCUVrso+ozEW9YsRmdJ0WyWI1iTJXus5m+trO15+jNG/BUpf KJOn42v335fIj41gFocVX3Dgy7Kxgm9mXxyb6ZoI2+k2i+32XgZmtzmmlH6748gKf0h1 bTB+/4AsJP9KiJnL2ZUM6lt8bgRdUuWPk2VQgQk3TIYHOCFBFOVy9b3XSbktENAjJdgb plkg== 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=4Ggs1YKFsdjSE+LjnziKwLWp97Km6+ZfwDv10GHI83k=; b=rg36fbE/TgDeA93Djmz0Y0GeJC9yIzvffpg1ydCSwKHuG39+KYOUNQy091vGRaAGo9 hzIsFWp0biulfOIWBJFA05k9imRu0pJkq42yPTahFNCWJgoLsKdhuqUtwCmqFD/48cAR DTC0t5aOWzLbF/5wUX/vvDfAvKZGSeZGfFKm9fExHDq0S2PGYidKoxnHX8c2LGC+8wtU JeFg09LK3zdt4t+l7jinyQ5mu/OHVaWOIvuekNgzSRTDDP7b+HtNkNP9I7rgJu42Leuo 5+R1DL9kjU/VeQ73zcmamClGVRwPf+iz/pOo8aSxgwS99sp44lLcstsibG3ZrM9Ewnm6 UMOA== 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 u12si14835721edt.299.2020.04.16.02.29.47; Thu, 16 Apr 2020 02:30:11 -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 S2392224AbgDPJ2c (ORCPT + 99 others); Thu, 16 Apr 2020 05:28:32 -0400 Received: from mx2.suse.de ([195.135.220.15]:59948 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2392188AbgDPJ22 (ORCPT ); Thu, 16 Apr 2020 05:28:28 -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 E9FEBAD0E; Thu, 16 Apr 2020 09:28:25 +0000 (UTC) Date: Thu, 16 Apr 2020 11:28:25 +0200 (CEST) From: Miroslav Benes To: Josh Poimboeuf cc: Jessica Yu , live-patching@vger.kernel.org, linux-kernel@vger.kernel.org, Peter Zijlstra Subject: Re: [PATCH 6/7] livepatch: Remove module_disable_ro() usage In-Reply-To: <20200415163303.ubdnza6okg4h3e5a@treble> Message-ID: References: <9f0d8229bbe79d8c13c091ed70c41d49caf598f2.1586881704.git.jpoimboe@redhat.com> <20200415150216.GA6164@linux-8ccs.fritz.box> <20200415163303.ubdnza6okg4h3e5a@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 Wed, 15 Apr 2020, Josh Poimboeuf wrote: > On Wed, Apr 15, 2020 at 05:02:16PM +0200, Jessica Yu wrote: > > +++ Josh Poimboeuf [14/04/20 11:28 -0500]: > > > With arch_klp_init_object_loaded() gone, and apply_relocate_add() now > > > using text_poke(), livepatch no longer needs to use module_disable_ro(). > > > > > > The text_mutex usage can also be removed -- its purpose was to protect > > > against module permission change races. > > > > > > Signed-off-by: Josh Poimboeuf > > > --- > > > kernel/livepatch/core.c | 8 -------- > > > 1 file changed, 8 deletions(-) > > > > > > diff --git a/kernel/livepatch/core.c b/kernel/livepatch/core.c > > > index 817676caddee..3a88639b3326 100644 > > > --- a/kernel/livepatch/core.c > > > +++ b/kernel/livepatch/core.c > > > @@ -767,10 +767,6 @@ static int klp_init_object_loaded(struct klp_patch *patch, > > > struct klp_modinfo *info = patch->mod->klp_info; > > > > > > if (klp_is_module(obj)) { > > > - > > > - mutex_lock(&text_mutex); > > > - module_disable_ro(patch->mod); > > > - > > > > Don't you still need the text_mutex to use text_poke() though? > > (Through klp_write_relocations -> apply_relocate_add -> text_poke) > > At least, I see this assertion there: > > > > void *text_poke(void *addr, const void *opcode, size_t len) > > { > > lockdep_assert_held(&text_mutex); > > > > return __text_poke(addr, opcode, len); > > } > > Hm, guess I should have tested with lockdep ;-) :) If I remember correctly, text_mutex must be held whenever text is modified to prevent race due to the modification. It is not only about permission changes even though it was how it manifested itself in our case. Miroslav