Received: by 10.223.185.116 with SMTP id b49csp7255798wrg; Thu, 1 Mar 2018 02:29:56 -0800 (PST) X-Google-Smtp-Source: AG47ELsCEAZJ+MOKy/jrjpo67wciyJ6tuFVaxV/eReBEamrHl+K+qlm2D/7SiNR0Hcncs3kd022A X-Received: by 10.99.160.17 with SMTP id r17mr1153181pge.127.1519900196781; Thu, 01 Mar 2018 02:29:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519900196; cv=none; d=google.com; s=arc-20160816; b=FvPZ1+6kGCKPfSm80Ecc5usRU52C1zDBXxs1iv7z4IENvw6pyeU7gdottm5HqckDY9 DDsuMV69g28sBB5cpjih+v128VrLnA0Bs6rcnmr0vVjurfSOt9G3Ok8gJ0Ou8hiqoS/G KbiwNGG9GExovBsfInrMitz9ir+B9le5Ahaac4B50aA8oKlLGbPydvqSZ3nfxue/nea+ hULDWKMve4S/d0dypVRxyHlrBrlpO7kB/+MAA6479gTYPi8VrbiiTuYu65nEDvLtu7ts gFKf+KDYYWA533qJvHQqDBGEUffcFKilfH/f/DOVidoqi1GD3d9JSkai4b6zXCHr42Cd FsRQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=3tC+CouHaVjjIPZi8fzxHK+rmfEiWgMCNi7YeTVHpF8=; b=NBwYOagpfWZz8dntf2Vf3+57AxI5xWG4DCsrrFT3/zXZNx9/Z89ZY9Z9P1mmNezh4q l1cb2GDwOPjg9NTG2c180O7CIsmk/dsQquUCfm6UtInGiAzfHPD/dPqS34Lnm5zEyDc4 QRAtCNvdIZkKoVFw502piBV/eTXbGEUj4QydIvLpZnnpwlvdY8LLSFYx6diTR4VK7/Xj A8f6CTf6RBTGr8S4OzWfHqT+TiUKpSmsizrIeQ4nbMK651yls7i/t5Iycice/j1NXUkn cDXbPM4UnalOUU/a2L14SKSpJlHefbfMQcCGGaiaEwexeZqwBEW8IvnIkK8XgmnGcECN g7Wg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b73-v6si2872715pli.261.2018.03.01.02.29.42; Thu, 01 Mar 2018 02:29:56 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S967096AbeCAK3E (ORCPT + 99 others); Thu, 1 Mar 2018 05:29:04 -0500 Received: from mx2.suse.de ([195.135.220.15]:40607 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S966146AbeCAK3B (ORCPT ); Thu, 1 Mar 2018 05:29:01 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 7032AB420; Thu, 1 Mar 2018 10:29:00 +0000 (UTC) Date: Thu, 1 Mar 2018 11:28:59 +0100 From: Petr Mladek To: Miroslav Benes Cc: Jiri Kosina , Josh Poimboeuf , Jason Baron , Joe Lawrence , Jessica Yu , Evgenii Shatokhin , live-patching@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v8 7/8] livepatch: Correctly handle atomic replace for not yet loaded modules Message-ID: <20180301102859.zwrt6w36ub474nb2@pathway.suse.cz> References: <20180221132914.4809-1-pmladek@suse.com> <20180221132914.4809-8-pmladek@suse.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20170421 (1.8.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu 2018-02-22 22:00:28, Miroslav Benes wrote: > On Wed, 21 Feb 2018, Petr Mladek wrote: > > This patch allows the late initialization. > > > > diff --git a/kernel/livepatch/core.c b/kernel/livepatch/core.c > > index ad508a86b2f9..da1438d47d83 100644 > > --- a/kernel/livepatch/core.c > > +++ b/kernel/livepatch/core.c > > @@ -984,7 +988,12 @@ static void klp_free_patch(struct klp_patch *patch) > > > > static int klp_init_func(struct klp_object *obj, struct klp_func *func) > > { > > - if (!func->old_name || !func->new_func) > > + if (!func->old_name) > > + return -EINVAL; > > + > > + /* NOPs do not know the address until the patched module is loaded. */ > > + if (!func->new_func && > > + (!klp_is_func_type(func, KLP_FUNC_NOP) || klp_is_object_loaded(obj))) > > return -EINVAL; > > If we changed the order of klp_init_func() and klp_init_object_loaded() > calls in klp_init_object(), the hunk would not be needed. Is that correct? Not really. klp_init_object_loaded() would set func->new_func only when the object was loaded. But we want to proceed here and create the kobject for NOPs even when it was not loaded. > > INIT_LIST_HEAD(&func->stack_node); > > @@ -1039,6 +1048,9 @@ static int klp_init_object_loaded(struct klp_patch *patch, > > return -ENOENT; > > } > > > > + if (klp_is_func_type(func, KLP_FUNC_NOP)) > > + func->new_func = (void *)func->old_addr; > > Is there a reason why you left the same assignment in > klp_alloc_func_nop()? This one is enough, no? Good point! I am going to replace the obsolete assignment with a comment in v8. Best Regards, Petr