Received: by 10.223.176.5 with SMTP id f5csp613302wra; Fri, 9 Feb 2018 04:30:44 -0800 (PST) X-Google-Smtp-Source: AH8x2248Sr+rTqkSMBeMnTIFznV7BVRnd8A6swQ5lmYcnYYa55FearA5rqeU6pNCBhl1ENRWv+88 X-Received: by 2002:a17:902:2c43:: with SMTP id m61-v6mr1547915plb.387.1518179444889; Fri, 09 Feb 2018 04:30:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518179444; cv=none; d=google.com; s=arc-20160816; b=XXvSkjK0qjvKOcOKMrYuvNEZiwV5W2CM/gIkaOkbQZ8toyU8R6zMKJMXjBfboyftkP Yml6xxOw410v+AohBlu6EFHsxLsmg8fYqoFe0GCj5vQWWBt08KZQ+DPP6b7NDftnVu0X NevGPBBJAzPI0BHF8A0Sz1ODHKCCh/02enOuddCPnIBGhtESblPKRkIU+cXwmsg+hKwU 512gbD2ZvS94WwGbpy/G2P1FbkW0BdEtmxXsaKVpCCyLp9q10Rpp2wn9xSqwZLs5Pini 0ojcnR4KsgNRkCtscbzFTf6KzTYZgo+5q8CQbr/H6TZwTacQ/t2RiczQjVtnIRkiDlvJ DbOw== 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 :arc-authentication-results; bh=S+ZWRk/w+1myW4vC2patpgdwMjYVXlnsuAHPcppMzhM=; b=gnmU/2ukzNZLCC6DDEA/8CVa142BFKE8X5Tqb53XyRjqNtzaELULa7S2a2tzZ4B7IG jRChsG4niJwWMcsivIIgN9cf5T6xHLilJvi4R0ZvLZxzrN9YMkxRDd3G5oe7ZhaGzQ2r qbTlSJMPud6rH3pmAFT4WDzMZppoS/8F/+7hE/g4opHztlXHe7rmvPehluSgEjmjBtZZ j6L2yriTXNKKZeK4yj1+Oil9Iycgat+crlEM1TnMCcCdjDv19on0YvLT7hvEes1VjZHv uKgqlDqcQLVahin3e0pW2W6MdCyYAH7un6Urf7y5M3KSPPBV746VZmUKcp0XYLsLz/o4 cjzg== 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 y184si1316633pgd.291.2018.02.09.04.30.30; Fri, 09 Feb 2018 04:30:44 -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 S1751049AbeBIM3v (ORCPT + 99 others); Fri, 9 Feb 2018 07:29:51 -0500 Received: from mx2.suse.de ([195.135.220.15]:43587 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750920AbeBIM3u (ORCPT ); Fri, 9 Feb 2018 07:29:50 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id C07CDAABE; Fri, 9 Feb 2018 12:29:48 +0000 (UTC) Date: Fri, 9 Feb 2018 13:29:46 +0100 (CET) From: Miroslav Benes To: Petr Mladek 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 v7 4/7] livepatch: Allow to unpatch only functions of the given type In-Reply-To: <20180206103424.10829-5-pmladek@suse.com> Message-ID: References: <20180206103424.10829-1-pmladek@suse.com> <20180206103424.10829-5-pmladek@suse.com> 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 > +/* > + * Remove ftrace handler for the given object and function type. Isn't it imprecise? It does not necessarily remove ftrace handler. It removes a function of given ftype from func_stack. I'd remove the sentence. > + * > + * It keeps obj->patched flag true when any listed function is still patched. > + * The caller is responsible for removing the unpatched functions to > + * make the flag clean again. > + */ > +void klp_unpatch_object(struct klp_object *obj, enum klp_func_type ftype) > { > struct klp_func *func; > + bool patched = false; > > - klp_for_each_func(obj, func) > - if (func->patched) > + klp_for_each_func(obj, func) { > + if (!func->patched) > + continue; > + > + if (klp_is_func_type(func, ftype)) > klp_unpatch_func(func); > + else > + patched = true; > + } > > - obj->patched = false; > + obj->patched = patched; > } > > int klp_patch_object(struct klp_object *obj) > @@ -258,7 +272,7 @@ int klp_patch_object(struct klp_object *obj) > klp_for_each_func(obj, func) { > ret = klp_patch_func(func); > if (ret) { > - klp_unpatch_object(obj); > + klp_unpatch_object(obj, KLP_FUNC_ANY); > return ret; > } > } > @@ -267,11 +281,12 @@ int klp_patch_object(struct klp_object *obj) > return 0; > } > > -void klp_unpatch_objects(struct klp_patch *patch) > +/* Removes ftrace handler in all objects for the given function type. */ Same here. > +void klp_unpatch_objects(struct klp_patch *patch, enum klp_func_type ftype) > { > struct klp_object *obj; > > klp_for_each_object(patch, obj) > if (obj->patched) > - klp_unpatch_object(obj); > + klp_unpatch_object(obj, ftype); > } Miroslav