Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp1149433pxm; Thu, 3 Mar 2022 11:16:30 -0800 (PST) X-Google-Smtp-Source: ABdhPJyiu7QOXMTNzmCmV8ZlpBK6FJ8VrPiUNc7drzRDLJYk9uJqF+24ZETaSuZ/W9V/jg7rwtV2 X-Received: by 2002:a63:161c:0:b0:372:e459:70e6 with SMTP id w28-20020a63161c000000b00372e45970e6mr31665643pgl.596.1646334989885; Thu, 03 Mar 2022 11:16:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646334989; cv=none; d=google.com; s=arc-20160816; b=Tb6MztO2Bw/a4gFyRXCkiLAwbbgmFL9TmezM71PUUhisUTBhckmVK85SLAiIS9citz hPyPhorpRF1iFK+DJrBtVvehAzICn72g5nEmK29seraNLg8G+tyFFuI9YrXmsJ5HgX5k ctuppG5hhtFCLpCpdTdeA2wSO/mIqTGMSC9w1QCt1tEZKqlhfNUc7/aG5QmBLEnwEV01 A6FyEHUwLtllhqKEz1Mcm6QxPOZVLJUCnW2jZzob6utI2ysCztxEjD1qXF3CKUUTUHun +hM7hZdxAZ3w0zURDzIYclyI+4uVcQ06kLtgCefKQYVBRAgTcNXWu3LztehX8cbs3TBK AUbw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:subject:from :references:cc:to:dkim-signature; bh=s27HdtG2F+kYjD9zNRAATi4qiD6z55RkiHx0Wy7hg6M=; b=kfg6lFKkP4nczC27wokhXBafCfbbHRmhiFSGRMfAz8YhYRtxyiJsEBFKoAWeZL1HL1 W6DG7DRfXTFoEYrbIOp7+TBw4pXE2WA2TiLJLbO342JdNVDC9VwZCaKR/QbAgyKPf+wm 8rsyKkbFHJa4i0HE7mwcR/JCiRGPrbEpkjd6Yn0CVWKkQmy7DS5fqSGZ8lR7rsIvHpNx noJmIk8+RCfwFJE7fcqnhSVsJJKXm8WHrCt0DFQgDCROAQztVMi7BHdugamX69q9y0Nh BBXGp7TwWIv4X8BZDiO0Xtze30EVlE92h5/jkEUvs2K9PfEd6r0vWb07Iu2VRndIlMBa Vmug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=LuX+2qdm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a14-20020a17090a740e00b001bcafc0fb9asi9379102pjg.71.2022.03.03.11.16.13; Thu, 03 Mar 2022 11:16:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=LuX+2qdm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S234707AbiCCPoT (ORCPT + 99 others); Thu, 3 Mar 2022 10:44:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39494 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234670AbiCCPoJ (ORCPT ); Thu, 3 Mar 2022 10:44:09 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id A8300154D20 for ; Thu, 3 Mar 2022 07:43:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646322202; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=s27HdtG2F+kYjD9zNRAATi4qiD6z55RkiHx0Wy7hg6M=; b=LuX+2qdmJpX4zgEPxnkRexB/KKxzQyvXN4nTNd5vz+sN+vUApHj+0/DmXmNlemrNYYtJAF kWuIoXr95NOI4IFafLcwfrDOKgOGsmKjzLoQGPgqK1VRzeIu58OiHpsV8KxpXXmNEgxxwF m/zdrm+RUMH34hpVk6fDpcn3oBtCcUo= Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-665-IMF5G0QhNBay0VhYuB-VVg-1; Thu, 03 Mar 2022 10:43:21 -0500 X-MC-Unique: IMF5G0QhNBay0VhYuB-VVg-1 Received: by mail-qk1-f199.google.com with SMTP id l82-20020a37a255000000b0060dd39f5d87so3525913qke.4 for ; Thu, 03 Mar 2022 07:43:21 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:to:cc:references:from:subject:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=s27HdtG2F+kYjD9zNRAATi4qiD6z55RkiHx0Wy7hg6M=; b=AMFXiR20kKLT4m0bYlnuUP44QjFC1qyRp9dAulP7pY5MpOQlAqifA4/r2DJScGFXec 5R4Bu5fRBiy6oZ7LLyN3nYV5dKZZdGpmEwqDwpHz4YxOqO98ReKnXwRP5+SLpK0PHvEk 7stGZet70Acytd3NXDwKgDD4+EXgG9lIo1NT9hhJtuMwhqZ9MXOl8gLYJLm9bvKIrACP 7HVicSZgqnCdWwvJmrJomdxUb06YhmOBl2r55CsvIfC4/FQEosev8o4M0W+O2zuPCFAM NG7ESkkosNVaqaNMnkw7xO+gSEDVDrvGMXXRu4bupY4pCmBMoDi0UWENS0B1hulAMKEt hfzg== X-Gm-Message-State: AOAM532v86Z7x4ht1aQgWx3E403g3Aym7sh1qPfCnB7PbekFxq6tSk6R O/o5FPK49zxxB3DFZLIBo0KEEW7N7UXQYYEVVwHm8R9cs0P9fOaxYXGGixZYYl17pBcK4uQxK6R STysq2pDPVbvvpMVqTdpJrrds X-Received: by 2002:a05:6214:62c:b0:435:1b3d:17e1 with SMTP id a12-20020a056214062c00b004351b3d17e1mr5989416qvx.113.1646322201107; Thu, 03 Mar 2022 07:43:21 -0800 (PST) X-Received: by 2002:a05:6214:62c:b0:435:1b3d:17e1 with SMTP id a12-20020a056214062c00b004351b3d17e1mr5989402qvx.113.1646322200848; Thu, 03 Mar 2022 07:43:20 -0800 (PST) Received: from [192.168.1.9] (pool-68-163-101-245.bstnma.fios.verizon.net. [68.163.101.245]) by smtp.gmail.com with ESMTPSA id c16-20020a05622a059000b002dc93dc92d1sm1777989qtb.48.2022.03.03.07.43.19 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 03 Mar 2022 07:43:19 -0800 (PST) To: Chengming Zhou , Miroslav Benes Cc: jpoimboe@redhat.com, jikos@kernel.org, pmladek@suse.com, live-patching@vger.kernel.org, linux-kernel@vger.kernel.org, songmuchun@bytedance.com, qirui.001@bytedance.com References: <20220301140840.29345-1-zhouchengming@bytedance.com> <1929669c-7674-035b-8cf1-5b5007ecccec@bytedance.com> From: Joe Lawrence Subject: Re: [External] Re: [PATCH] livepatch: Only block the removal of KLP_UNPATCHED forced transition patch Message-ID: Date: Thu, 3 Mar 2022 10:43:18 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 MIME-Version: 1.0 In-Reply-To: <1929669c-7674-035b-8cf1-5b5007ecccec@bytedance.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 3/3/22 5:33 AM, Chengming Zhou wrote: > On 2022/3/3 3:51 下午, Miroslav Benes wrote: >> On Thu, 3 Mar 2022, Chengming Zhou wrote: >> >>> Hi, >>> >>> On 2022/3/2 5:55 下午, Miroslav Benes wrote: >>>> Hi, >>>> >>>> On Tue, 1 Mar 2022, Chengming Zhou wrote: >>>> >>>>> module_put() is currently never called for a patch with forced flag, to block >>>>> the removal of that patch module that might still be in use after a forced >>>>> transition. >>>>> >>>>> But klp_force_transition() will flag all patches on the list to be forced, since >>>>> commit d67a53720966 ("livepatch: Remove ordering (stacking) of the livepatches") >>>>> has removed stack ordering of the livepatches, it will cause all other patches can't >>>>> be unloaded after disabled even if they have completed the KLP_UNPATCHED transition. >>>>> >>>>> In fact, we don't need to flag a patch to forced if it's a KLP_PATCHED forced >>>>> transition. It can still be unloaded only if it has passed through the consistency >>>>> model in KLP_UNPATCHED transition. >>>>> >>>>> So this patch only set forced flag and block the removal of a KLP_UNPATCHED forced >>>>> transition livepatch. >>>>> >>>>> Signed-off-by: Chengming Zhou >>>>> --- >>>>> kernel/livepatch/transition.c | 4 ++-- >>>>> 1 file changed, 2 insertions(+), 2 deletions(-) >>>>> >>>>> diff --git a/kernel/livepatch/transition.c b/kernel/livepatch/transition.c >>>>> index 5683ac0d2566..8b296ad9e407 100644 >>>>> --- a/kernel/livepatch/transition.c >>>>> +++ b/kernel/livepatch/transition.c >>>>> @@ -641,6 +641,6 @@ void klp_force_transition(void) >>>>> for_each_possible_cpu(cpu) >>>>> klp_update_patch_state(idle_task(cpu)); >>>>> >>>>> - klp_for_each_patch(patch) >>>>> - patch->forced = true; >>>>> + if (klp_target_state == KLP_UNPATCHED) >>>>> + klp_transition_patch->forced = true; >>>> >>>> I do not think this would interact nicely with the atomic replace feature. >>>> If you force the transition of a patch with ->replace set to true, no >>>> existing patch would get ->forced set with this change, which means all >>>> patches will be removed at the end of klp_try_complete_transition(). And >>>> that is something we want to prevent. >>> >>> Good point, I should check if it's an atomic replace livepatch in the else >>> branch, in which case we have to set all existing patches to forced. >> >> Yes, but that leads to a question if it then brings any value. Forcing a >> transition should be exceptional. If it is needed, there may be other >> issues involved which should probably be fixed. Have you come across a >> practical situation where the patch helped? > > Yes, you're right, the correct way is to find and fix the issues that > make us to use this "force" transition interface, until we don't need > to use it. > > Apart from this reason, another reason we may use "force" transition > is that we want to speed up the transition process of some patches > when load them, and we can make sure these patches are safe to do so. > (just like a consistency model check disable option when load a patch) > Interesting use case. Can you share any example livepatches where the transition time was exceptionally long and that lead to requiring this patch? From a kpatch developer's perspective, it would be interesting to read how you go about ensuring forced livepatch safety. We don't generally build forced livepatches, so I'm curious how the dev/review process goes. Thanks, -- Joe