Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp9149276ybl; Fri, 17 Jan 2020 07:08:10 -0800 (PST) X-Google-Smtp-Source: APXvYqwwGKaXs9FZktI3du3WFXqJz7MFkQz10wQ2P4kJam8lmddDtLVFs8cgdd6xMppQEzHkyK8R X-Received: by 2002:a05:6830:1042:: with SMTP id b2mr6345255otp.306.1579273689735; Fri, 17 Jan 2020 07:08:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579273689; cv=none; d=google.com; s=arc-20160816; b=wnM65BeRx0rUuzUyM9DBNbWi00OjHY6Bd6Yru9luJjJ8lLIhkwocOjvtgEl4bOREKs U07d0I/SIp5s8O3MasSE1eciiPWWK6Wk2BC5K1USeNtdeLPAQvFt8j5M8PFFLySRKt8z 6Eq0avzlWH9vFrnQr1Vqw1Qql7Col8u2gzO6kcjoWQdJS5dNFhJnU31qvWBjUIJqpQD9 G2biCx1HTW/blxLRPI+MpC0LBvXTtINlnGLM9p6Qh+ZPXWEPjPm8obSHF+gg0jgQkcXu xBZnV5kdYCwDRFOaUT6C4SpEOilX0VuNVwzLOAZDVvRwHxeTwIxHh3EEFZJb/1h8EGJt G6jg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=1t2QjfjC2ZBHeI2l6hJkrucEkrJ12A+6x/HsShpDRG4=; b=ObeaRG6rEjSo2NDyIdqSiR2Zhu1LVP71CDVavSpQIH4dZcF8refCn6hwxUklOxjJuG QIV/GGJgcmXUaEhFvviiQHB+cbctqCNzGqPlgpgEgmGxfodUzHSJkPeDEkxq9kEgFpcG wj//givEbYkF8d/x/x0YPtwtGJwgaRK4TrITh//O9MjOROjMq1xbRScburjBFCBZm6Ox rOPxSXV7QGVaKAuDsW7ehRmshmcCOMYfOrW3eeWT7n2eLO1p7o0orVcjMiRRD2ZIrrlh nFTSMhkq4gov5O+SCScMtvNgtye5BkAuBx+OIumpLDVpwlFGvB48BxfTyTv2tYneX1ky aYDg== 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 38si6232554otu.166.2020.01.17.07.07.56; Fri, 17 Jan 2020 07:08:09 -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 S1729394AbgAQPEo (ORCPT + 99 others); Fri, 17 Jan 2020 10:04:44 -0500 Received: from mx2.suse.de ([195.135.220.15]:46254 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729133AbgAQPEB (ORCPT ); Fri, 17 Jan 2020 10:04:01 -0500 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 5D7BEBB77; Fri, 17 Jan 2020 15:04:00 +0000 (UTC) From: Petr Mladek To: Jiri Kosina , Josh Poimboeuf , Miroslav Benes Cc: Joe Lawrence , Kamalesh Babulal , Nicolai Stange , live-patching@vger.kernel.org, linux-kernel@vger.kernel.org, Petr Mladek Subject: [POC 14/23] livepatch: Never block livepatch modules when the related module is being removed Date: Fri, 17 Jan 2020 16:03:14 +0100 Message-Id: <20200117150323.21801-15-pmladek@suse.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20200117150323.21801-1-pmladek@suse.com> References: <20200117150323.21801-1-pmladek@suse.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Originally, it was not possible to remove the single livepatch module when the code was used during a forced transition. There were no guarantees that the code was no longer used. Even the split livepatch modules have to stay when the entire livepatch gets disabled/replaced and the livepatch modules were used during a forced transition. On the other hand, klp_module_going() callback is called when the patched module is about to be removed. It's code should no longer be used. The same should be true also for the related livepatch module. Therefore the livepatch module could always get removed as well. It allows to load the patched module again in the future. Otherwise, it would get blocked because the related livepatch module could not get loaded more times. Signed-off-by: Petr Mladek --- kernel/livepatch/core.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/kernel/livepatch/core.c b/kernel/livepatch/core.c index 73462b66f63f..4b55d805f3ec 100644 --- a/kernel/livepatch/core.c +++ b/kernel/livepatch/core.c @@ -1391,6 +1391,13 @@ void klp_module_going(struct module *mod) klp_for_each_patch(patch) { klp_for_each_object_safe(patch, obj, tmp_obj) { if (obj->name && !strcmp(obj->name, mod->name)) { + /* + * The livepatched module is about to be + * destroyed. It's code is no longer used. + * Same is true for the livepatch even when + * it was part of forced transition. + */ + obj->forced = false; klp_remove_object(obj); } } -- 2.16.4