Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E93D3C433F5 for ; Fri, 26 Nov 2021 08:19:57 +0000 (UTC) Received: from localhost ([::1]:33250 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mqWSa-0004H7-MH for qemu-devel@archiver.kernel.org; Fri, 26 Nov 2021 03:19:56 -0500 Received: from eggs.gnu.org ([209.51.188.92]:42932) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mqWRU-0002ur-3B; Fri, 26 Nov 2021 03:18:48 -0500 Received: from szxga08-in.huawei.com ([45.249.212.255]:2908) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mqWRO-0003wo-I7; Fri, 26 Nov 2021 03:18:47 -0500 Received: from dggemv704-chm.china.huawei.com (unknown [172.30.72.57]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4J0ncn6cw0z1DJZ6; Fri, 26 Nov 2021 16:15:53 +0800 (CST) Received: from kwepemm600002.china.huawei.com (7.193.23.29) by dggemv704-chm.china.huawei.com (10.3.19.47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.20; Fri, 26 Nov 2021 16:18:28 +0800 Received: from [10.174.185.187] (10.174.185.187) by kwepemm600002.china.huawei.com (7.193.23.29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.2308.20; Fri, 26 Nov 2021 16:18:27 +0800 Message-ID: <77d40088-e542-0245-458f-7372dfdd5026@huawei.com> Date: Fri, 26 Nov 2021 16:18:26 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.2.0 Subject: Re: [PATCH 1/2] block-backend: Retain permissions after migration Content-Language: en-US To: Hanna Reitz , CC: , Kevin Wolf References: <20211125135317.186576-1-hreitz@redhat.com> <20211125135317.186576-2-hreitz@redhat.com> In-Reply-To: <20211125135317.186576-2-hreitz@redhat.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.185.187] X-ClientProxiedBy: dggeme709-chm.china.huawei.com (10.1.199.105) To kwepemm600002.china.huawei.com (7.193.23.29) X-CFilter-Loop: Reflected Received-SPF: pass client-ip=45.249.212.255; envelope-from=liangpeng10@huawei.com; helo=szxga08-in.huawei.com X-Spam_score_int: -61 X-Spam_score: -6.2 X-Spam_bar: ------ X-Spam_report: (-6.2 / 5.0 requ) BAYES_00=-1.9, NICE_REPLY_A=-1.993, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_PASS=-0.001, T_SPF_HELO_TEMPERROR=0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Reply-to: Peng Liang From: Peng Liang via On 11/25/2021 9:53 PM, Hanna Reitz wrote: > After migration, the permissions the guest device wants to impose on its > BlockBackend are stored in blk->perm and blk->shared_perm. In > blk_root_activate(), we take our permissions, but keep all shared > permissions open by calling `blk_set_perm(blk->perm, BLK_PERM_ALL)`. > > Only afterwards (immediately or later, depending on the runstate) do we > restrict the shared permissions by calling > `blk_set_perm(blk->perm, blk->shared_perm)`. Unfortunately, our first > call with shared_perm=BLK_PERM_ALL has overwritten blk->shared_perm to > be BLK_PERM_ALL, so this is a no-op and the set of shared permissions is > not restricted. > > Fix this bug by saving the set of shared permissions before invoking > blk_set_perm() with BLK_PERM_ALL and restoring it afterwards. > > Fixes: 5f7772c4d0cf32f4e779fcd5a69ae4dae24aeebf > ("block-backend: Defer shared_perm tightening migration > completion") > Reported-by: Peng Liang > Signed-off-by: Hanna Reitz > --- > block/block-backend.c | 11 +++++++++++ > 1 file changed, 11 insertions(+) > Thanks for your patch! Tested-by: Peng Liang