From nobody Mon Apr 29 01:46:55 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1593790168; cv=none; d=zohomail.com; s=zohoarc; b=ilrMEwybqWs5r9tjkQglMDIMC50LSCtus9lZZgNb/hlWKeSciIPpD/7mgwfK0RnVPF3LgIE7H2kMqotM8RkJ82hAWRkTIa5mQg6jhkVmKTNE9R1BUrt+/o5mZbZn+XyyUlQkpa8U2QWZUKRiDRJIbXV3HSCsXS6EsDZAY2miHZs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593790168; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=bSIB9Kmmm1xHiqSnDVdzW5IhUNQ98vxi22oX9dH1Cl4=; b=ODTOm1uhExQhdVGLRGWtLRe0JXOECCq1HzFBRoA8LlVKnxyRECd566KbMfrae2CqwcLI4lWdq+enG/hLWyZwfTbq3mSF7o2asWeZbRhKdb9G50NTwrIMmbIyOuLorTOT6Rehjych1RDOlEMXUtNbjGGdkBUfDG/vT8gLlxCps94= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1593790168301930.9430870563203; Fri, 3 Jul 2020 08:29:28 -0700 (PDT) Received: from localhost ([::1]:43854 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jrNcz-0000Rx-Sk for importer@patchew.org; Fri, 03 Jul 2020 11:29:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51022) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jrNbg-00072V-Ed for qemu-devel@nongnu.org; Fri, 03 Jul 2020 11:28:04 -0400 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:59262 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jrNba-0006bH-DA for qemu-devel@nongnu.org; Fri, 03 Jul 2020 11:28:03 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-170-xFcGjGVcPE6PiktAWCPsIg-1; Fri, 03 Jul 2020 11:27:55 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id AC58D80183C; Fri, 3 Jul 2020 15:27:54 +0000 (UTC) Received: from dgilbert-t580.localhost (ovpn-114-207.ams2.redhat.com [10.36.114.207]) by smtp.corp.redhat.com (Postfix) with ESMTP id AFF3D2DE73; Fri, 3 Jul 2020 15:27:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593790077; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bSIB9Kmmm1xHiqSnDVdzW5IhUNQ98vxi22oX9dH1Cl4=; b=Sf5hnn6MCtU/bHJT5c2uhYHAR6BMMwsmYdIJZnUVrNpQvm9EVuspirX/n0wo9wcew8yoX5 h1Kx5h6JkF2+Al1LDhwflQYjyyL2KU4EUOxPKum9slqoAFe2j6jNCbF+bWFUDd6Qc8Wx8Q L6Ansm3a/mBoUx/xq9OJjXQb4qJ8hY4= X-MC-Unique: xFcGjGVcPE6PiktAWCPsIg-1 From: "Dr. David Alan Gilbert (git)" To: qemu-devel@nongnu.org, quintela@redhat.com, zhukeqian1@huawei.com, stefanha@redhat.com Subject: [PULL 1/5] virtiofsd: Terminate capability list Date: Fri, 3 Jul 2020 16:27:44 +0100 Message-Id: <20200703152748.277255-2-dgilbert@redhat.com> In-Reply-To: <20200703152748.277255-1-dgilbert@redhat.com> References: <20200703152748.277255-1-dgilbert@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dgilbert@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.139.110.61; envelope-from=dgilbert@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/03 03:17:33 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: "Dr. David Alan Gilbert" capng_updatev is a varargs function that needs a -1 to terminate it, but it was missing. In practice what seems to have been happening is that it's added the capabilities we asked for, then runs into junk on the stack, so if we're unlucky it might be adding some more, but in reality it's failing - but after adding the capabilities we asked for. Fixes: a59feb483b8 ("virtiofsd: only retain file system capabilities") Signed-off-by: Dr. David Alan Gilbert Reviewed-by: Stefan Hajnoczi Acked-by: Vivek Goyal Message-Id: <20200629115420.98443-2-dgilbert@redhat.com> Signed-off-by: Dr. David Alan Gilbert --- tools/virtiofsd/passthrough_ll.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/virtiofsd/passthrough_ll.c b/tools/virtiofsd/passthrough= _ll.c index 2ce7c96085..e373e3b36e 100644 --- a/tools/virtiofsd/passthrough_ll.c +++ b/tools/virtiofsd/passthrough_ll.c @@ -2598,7 +2598,9 @@ static void setup_capabilities(void) CAP_SETGID, CAP_SETUID, CAP_MKNOD, - CAP_SETFCAP); + CAP_SETFCAP, + -1); + capng_apply(CAPNG_SELECT_BOTH); =20 cap.saved =3D capng_save_state(); --=20 2.26.2 From nobody Mon Apr 29 01:46:55 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1593790170; cv=none; d=zohomail.com; s=zohoarc; b=hSpxhrLg2IxPDwAjVmdRaYw1Amf9EW/otzRgD9xdlrvqIKrfYDbhJ/l66OrueyHqnvbqvZCrD+GRHP1aOhvQ7267uQ95FruCippG4H2W35lY850zkpIs8D7w3/B6hCTK6CLstXlu2UFWrQ5CZMPvommiExiRDO1RX/9mU/eAxvo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593790170; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=9pNmG9jjW2jNd4sNOYr7D1yE1KNWC5+nXpAgFyJUH6o=; b=aGDueiXIVPthnkGcYMBUBMW8+MRssZaxFkmzSDzMpGZkMcCBA8in91wYziKLjKffH3V+bn9aZh5yL4u0AQp7oTAd59v+oQ3yo3r7FtrtOL3R4P6lLQmPRd0ZRa+3WEQOM68oQtQFhXr3B1bWBLOfOSA88ivCsMuNZPdsQe/GcuM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1593790170217399.11206256658556; Fri, 3 Jul 2020 08:29:30 -0700 (PDT) Received: from localhost ([::1]:44008 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jrNd2-0000Vo-1y for importer@patchew.org; Fri, 03 Jul 2020 11:29:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51070) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jrNbh-00073r-TP for qemu-devel@nongnu.org; Fri, 03 Jul 2020 11:28:06 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:60996 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jrNbf-0006dW-Rc for qemu-devel@nongnu.org; Fri, 03 Jul 2020 11:28:05 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-27-OwTgMYSlMbKVglFi3mvbEg-1; Fri, 03 Jul 2020 11:27:56 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 00584A0BD7; Fri, 3 Jul 2020 15:27:56 +0000 (UTC) Received: from dgilbert-t580.localhost (ovpn-114-207.ams2.redhat.com [10.36.114.207]) by smtp.corp.redhat.com (Postfix) with ESMTP id F247A1972A; Fri, 3 Jul 2020 15:27:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593790080; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9pNmG9jjW2jNd4sNOYr7D1yE1KNWC5+nXpAgFyJUH6o=; b=buxmrBPZ7WceR724MDmbw9SxcC4mH2jO8L2YWi0fBm+B8YZAFtjRp/3CRTMF3qJFUakdWz 6fvNwO7lJIDdbXpRhGe5ss4lgjzR1ek83vpwrELEtu8HBjtiE3hw/eCjtQzdAxQPvfw05Q qfYG6VBOyWqRUwXKERpApsJvCSm3QUQ= X-MC-Unique: OwTgMYSlMbKVglFi3mvbEg-1 From: "Dr. David Alan Gilbert (git)" To: qemu-devel@nongnu.org, quintela@redhat.com, zhukeqian1@huawei.com, stefanha@redhat.com Subject: [PULL 2/5] virtiofsd: Check capability calls Date: Fri, 3 Jul 2020 16:27:45 +0100 Message-Id: <20200703152748.277255-3-dgilbert@redhat.com> In-Reply-To: <20200703152748.277255-1-dgilbert@redhat.com> References: <20200703152748.277255-1-dgilbert@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dgilbert@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=207.211.31.81; envelope-from=dgilbert@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/03 01:34:15 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: "Dr. David Alan Gilbert" Check the capability calls worked. Signed-off-by: Dr. David Alan Gilbert Reviewed-by: Stefan Hajnoczi Acked-by: Vivek Goyal Message-Id: <20200629115420.98443-3-dgilbert@redhat.com> Signed-off-by: Dr. David Alan Gilbert --- tools/virtiofsd/passthrough_ll.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/tools/virtiofsd/passthrough_ll.c b/tools/virtiofsd/passthrough= _ll.c index e373e3b36e..99d562046a 100644 --- a/tools/virtiofsd/passthrough_ll.c +++ b/tools/virtiofsd/passthrough_ll.c @@ -2589,7 +2589,7 @@ static void setup_capabilities(void) */ capng_setpid(syscall(SYS_gettid)); capng_clear(CAPNG_SELECT_BOTH); - capng_updatev(CAPNG_ADD, CAPNG_PERMITTED | CAPNG_EFFECTIVE, + if (capng_updatev(CAPNG_ADD, CAPNG_PERMITTED | CAPNG_EFFECTIVE, CAP_CHOWN, CAP_DAC_OVERRIDE, CAP_DAC_READ_SEARCH, @@ -2599,11 +2599,21 @@ static void setup_capabilities(void) CAP_SETUID, CAP_MKNOD, CAP_SETFCAP, - -1); + -1)) { + fuse_log(FUSE_LOG_ERR, "%s: capng_updatev failed\n", __func__); + exit(1); + } =20 - capng_apply(CAPNG_SELECT_BOTH); + if (capng_apply(CAPNG_SELECT_BOTH)) { + fuse_log(FUSE_LOG_ERR, "%s: capng_apply failed\n", __func__); + exit(1); + } =20 cap.saved =3D capng_save_state(); + if (!cap.saved) { + fuse_log(FUSE_LOG_ERR, "%s: capng_save_state failed\n", __func__); + exit(1); + } pthread_mutex_unlock(&cap.mutex); } =20 --=20 2.26.2 From nobody Mon Apr 29 01:46:55 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1593790263; cv=none; d=zohomail.com; s=zohoarc; b=YZ/1TFoZlR84NtjNGWTa3Mr4FTHfJC2okKki3dYrXM9Z/0eof5tREM8mCta3jjKrT4GH1a/U4aIiMevWcxZqj5MDoiFQtdbcfggNxlM+fz8fZBd6+o5AcWPrxD33WdF7qpAmdWEEaFM1jDTGn8wXygcvV2nYm/aHeMeic056TrM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593790263; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=nGqi3SN32stCXF5/qmcRGZpat5DOF5S0r6YBTnx6GI4=; b=UTKByadzdjp67GPSzcFldn8Wrxjwge98n+/SDuGQZs0UC6GbAl2ZUvfU4Tl9yo1VwzYMelZoaF/KPgTZ4e+FWPnF9n/Hz5ZzS4XPqS86BbYHzNHw9B0uChfwXSymYwGWTteuZU8jCcqKYxRlkOObmM+0Dnt7CvAzYcV2giVXJWY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1593790263174256.95238356395873; Fri, 3 Jul 2020 08:31:03 -0700 (PDT) Received: from localhost ([::1]:49252 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jrNeX-0002lx-IK for importer@patchew.org; Fri, 03 Jul 2020 11:31:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51078) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jrNbj-00074Z-Bn for qemu-devel@nongnu.org; Fri, 03 Jul 2020 11:28:07 -0400 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:42058) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jrNbf-0006cO-R3 for qemu-devel@nongnu.org; Fri, 03 Jul 2020 11:28:06 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-2-Jq6HaIslNGejucH0sOrMQw-1; Fri, 03 Jul 2020 11:27:58 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4446A80183C; Fri, 3 Jul 2020 15:27:57 +0000 (UTC) Received: from dgilbert-t580.localhost (ovpn-114-207.ams2.redhat.com [10.36.114.207]) by smtp.corp.redhat.com (Postfix) with ESMTP id 46BB21972A; Fri, 3 Jul 2020 15:27:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593790080; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nGqi3SN32stCXF5/qmcRGZpat5DOF5S0r6YBTnx6GI4=; b=Gd2A8bE7wt3txVGwtywm39BuVK1ezNQ4oHZQKdvtFc61qaSdxj4V/5fdxuNyeUBFiFJOIE zGgChgmQFkNp0FHhnob2P1/5M6KgLLRqCWwdZpCd7YGEuUETGQAlRu2TPS6jnRQP6j0y3R Hc0KTKAkP+EtXlSb2TflFPJABzDQAYs= X-MC-Unique: Jq6HaIslNGejucH0sOrMQw-1 From: "Dr. David Alan Gilbert (git)" To: qemu-devel@nongnu.org, quintela@redhat.com, zhukeqian1@huawei.com, stefanha@redhat.com Subject: [PULL 3/5] virtiofsd: Allow addition or removal of capabilities Date: Fri, 3 Jul 2020 16:27:46 +0100 Message-Id: <20200703152748.277255-4-dgilbert@redhat.com> In-Reply-To: <20200703152748.277255-1-dgilbert@redhat.com> References: <20200703152748.277255-1-dgilbert@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dgilbert@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.139.110.61; envelope-from=dgilbert@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/03 03:17:33 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: "Dr. David Alan Gilbert" Allow capabilities to be added or removed from the allowed set for the daemon; e.g. default: CapPrm: 00000000880000df CapEff: 00000000880000df -o modcaps=3D+sys_admin CapPrm: 00000000882000df CapEff: 00000000882000df -o modcaps=3D+sys_admin:-chown CapPrm: 00000000882000de CapEff: 00000000882000de Signed-off-by: Dr. David Alan Gilbert Message-Id: <20200629115420.98443-4-dgilbert@redhat.com> Acked-by: Vivek Goyal Reviewed-by: Stefan Hajnoczi Signed-off-by: Dr. David Alan Gilbert --- docs/tools/virtiofsd.rst | 5 +++ tools/virtiofsd/helper.c | 2 ++ tools/virtiofsd/passthrough_ll.c | 53 ++++++++++++++++++++++++++++++-- 3 files changed, 58 insertions(+), 2 deletions(-) diff --git a/docs/tools/virtiofsd.rst b/docs/tools/virtiofsd.rst index 378594c422..824e713491 100644 --- a/docs/tools/virtiofsd.rst +++ b/docs/tools/virtiofsd.rst @@ -54,6 +54,11 @@ Options * flock|no_flock - Enable/disable flock. The default is ``no_flock``. =20 + * modcaps=3DCAPLIST + Modify the list of capabilities allowed; CAPLIST is a colon separated + list of capabilities, each preceded by either + or -, e.g. + ''+sys_admin:-chown''. + * log_level=3DLEVEL - Print only log messages matching LEVEL or more severe. LEVEL is one of ``err``, ``warn``, ``info``, or ``debug``. The default is ``info``. diff --git a/tools/virtiofsd/helper.c b/tools/virtiofsd/helper.c index 00a1ef666a..3105b6c23a 100644 --- a/tools/virtiofsd/helper.c +++ b/tools/virtiofsd/helper.c @@ -174,6 +174,8 @@ void fuse_cmdline_help(void) " default: no_writeback\n" " -o xattr|no_xattr enable/disable xattr\n" " default: no_xattr\n" + " -o modcaps=3DCAPLIST Modify the list of capabiliti= es\n" + " e.g. -o modcaps=3D+sys_admin:-c= hown\n" " --rlimit-nofile=3D set maximum number of file de= scriptors\n" " (0 leaves rlimit unchanged)\n" " default: min(1000000, fs.file-m= ax - 16384)\n" diff --git a/tools/virtiofsd/passthrough_ll.c b/tools/virtiofsd/passthrough= _ll.c index 99d562046a..94e0de2d2b 100644 --- a/tools/virtiofsd/passthrough_ll.c +++ b/tools/virtiofsd/passthrough_ll.c @@ -145,6 +145,7 @@ struct lo_data { int posix_lock; int xattr; char *source; + char *modcaps; double timeout; int cache; int timeout_set; @@ -170,6 +171,7 @@ static const struct fuse_opt lo_opts[] =3D { { "no_posix_lock", offsetof(struct lo_data, posix_lock), 0 }, { "xattr", offsetof(struct lo_data, xattr), 1 }, { "no_xattr", offsetof(struct lo_data, xattr), 0 }, + { "modcaps=3D%s", offsetof(struct lo_data, modcaps), 0 }, { "timeout=3D%lf", offsetof(struct lo_data, timeout), 0 }, { "timeout=3D", offsetof(struct lo_data, timeout_set), 1 }, { "cache=3Dnone", offsetof(struct lo_data, cache), CACHE_NONE }, @@ -2570,9 +2572,11 @@ static void setup_mounts(const char *source) =20 /* * Only keep whitelisted capabilities that are needed for file system oper= ation + * The (possibly NULL) modcaps_in string passed in is free'd before exit. */ -static void setup_capabilities(void) +static void setup_capabilities(char *modcaps_in) { + char *modcaps =3D modcaps_in; pthread_mutex_lock(&cap.mutex); capng_restore_state(&cap.saved); =20 @@ -2604,6 +2608,51 @@ static void setup_capabilities(void) exit(1); } =20 + /* + * The modcaps option is a colon separated list of caps, + * each preceded by either + or -. + */ + while (modcaps) { + capng_act_t action; + int cap; + + char *next =3D strchr(modcaps, ':'); + if (next) { + *next =3D '\0'; + next++; + } + + switch (modcaps[0]) { + case '+': + action =3D CAPNG_ADD; + break; + + case '-': + action =3D CAPNG_DROP; + break; + + default: + fuse_log(FUSE_LOG_ERR, + "%s: Expecting '+'/'-' in modcaps but found '%c'\n", + __func__, modcaps[0]); + exit(1); + } + cap =3D capng_name_to_capability(modcaps + 1); + if (cap < 0) { + fuse_log(FUSE_LOG_ERR, "%s: Unknown capability '%s'\n", __func= __, + modcaps); + exit(1); + } + if (capng_update(action, CAPNG_PERMITTED | CAPNG_EFFECTIVE, cap)) { + fuse_log(FUSE_LOG_ERR, "%s: capng_update failed for '%s'\n", + __func__, modcaps); + exit(1); + } + + modcaps =3D next; + } + g_free(modcaps_in); + if (capng_apply(CAPNG_SELECT_BOTH)) { fuse_log(FUSE_LOG_ERR, "%s: capng_apply failed\n", __func__); exit(1); @@ -2627,7 +2676,7 @@ static void setup_sandbox(struct lo_data *lo, struct = fuse_session *se, setup_namespaces(lo, se); setup_mounts(lo->source); setup_seccomp(enable_syslog); - setup_capabilities(); + setup_capabilities(g_strdup(lo->modcaps)); } =20 /* Set the maximum number of open file descriptors */ --=20 2.26.2 From nobody Mon Apr 29 01:46:55 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1593790339; cv=none; d=zohomail.com; s=zohoarc; b=jNRJc2pYLPpxr8Y7TYR2nclgvQt3Obyl0XZjRF+1CO9T9WSn0exUR8Rh+b4yMZGuUF+/8QpXlJb588TFYOmphsdTN41PHD0JIEA+IrfFVMsbsVdJfXPhLU+gozVxSkp95uQ5ufVR2hyzxtBdRKJN9an5Oihx0bXmQV0QwXDRSFc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593790339; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=n1C5a7JztNWosbsqPUhwZhKiIAVmAdulGlfADd5r4eg=; b=G/fdi/kMfIRwZ5+VtS2CXNLNaN26VCntBTHH0ZCvAWHo6ItAwfO+EgDIRc2WBP34aM6LEjATXGrk6CzEOWELbaZHlHJYE4GVRKCs6XLaNPs/QMUkAwASJOJs7HHy5ieMFUte0hGdSBcP0XpUoxa1+VaPjZOGddgxocDQVtCPufU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1593790339018563.127264094749; Fri, 3 Jul 2020 08:32:19 -0700 (PDT) Received: from localhost ([::1]:51356 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jrNfl-0003gE-Kv for importer@patchew.org; Fri, 03 Jul 2020 11:32:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51108) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jrNbl-00075w-Js for qemu-devel@nongnu.org; Fri, 03 Jul 2020 11:28:09 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:59688 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jrNbi-0006f8-UG for qemu-devel@nongnu.org; Fri, 03 Jul 2020 11:28:09 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-355-qF00r_0TPKiWm5NAi0_UDA-1; Fri, 03 Jul 2020 11:27:59 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 89C0F1054F8B; Fri, 3 Jul 2020 15:27:58 +0000 (UTC) Received: from dgilbert-t580.localhost (ovpn-114-207.ams2.redhat.com [10.36.114.207]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8D3782DE72; Fri, 3 Jul 2020 15:27:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593790085; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=n1C5a7JztNWosbsqPUhwZhKiIAVmAdulGlfADd5r4eg=; b=HPIvE6MTOfHChGE5tMrzYCK/4F2Ti4/yn/lOfrZsZXGGjc/GRglapWSQgOO39oQJ7tRWq5 vsI3BCannlpcRTqXDaslm6/SCm/GRAJ4LVH5lSV4eMFPrca6KkR6S2XDxWqsiA0SA3f+/j YPmTCka8REmlfwLu8qkDB+3iB3RTZV4= X-MC-Unique: qF00r_0TPKiWm5NAi0_UDA-1 From: "Dr. David Alan Gilbert (git)" To: qemu-devel@nongnu.org, quintela@redhat.com, zhukeqian1@huawei.com, stefanha@redhat.com Subject: [PULL 4/5] migration: postcopy take proper error return Date: Fri, 3 Jul 2020 16:27:47 +0100 Message-Id: <20200703152748.277255-5-dgilbert@redhat.com> In-Reply-To: <20200703152748.277255-1-dgilbert@redhat.com> References: <20200703152748.277255-1-dgilbert@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dgilbert@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=207.211.31.120; envelope-from=dgilbert@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/03 02:53:25 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: "Dr. David Alan Gilbert" This function returns a boolean success and we're returning -1; lets just use the 'out' error path. Signed-off-by: Dr. David Alan Gilbert Fixes: 58b7c17e226 ("Disable mlock around incoming postcopy") Buglink: https://bugs.launchpad.net/qemu/+bug/1885720 Message-Id: <20200701093557.130096-1-dgilbert@redhat.com> Reviewed-by: Thomas Huth Signed-off-by: Dr. David Alan Gilbert --- migration/postcopy-ram.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/migration/postcopy-ram.c b/migration/postcopy-ram.c index a36402722b..bef2a3afed 100644 --- a/migration/postcopy-ram.c +++ b/migration/postcopy-ram.c @@ -389,7 +389,7 @@ bool postcopy_ram_supported_by_host(MigrationIncomingSt= ate *mis) */ if (munlockall()) { error_report("%s: munlockall: %s", __func__, strerror(errno)); - return -1; + goto out; } =20 /* --=20 2.26.2 From nobody Mon Apr 29 01:46:55 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1593790409; cv=none; d=zohomail.com; s=zohoarc; b=Z+iSp5MHWbDgUibRcLuvYyQvORIRXJLpC3wv7zsa0zg2EUV3p+7scb449/fFsQhScgJJ7lMWnKZ/S3pSn1cooimuCucYvVPo7RvNGik8F3J11NLnCMDPwwc2CfW3b++IT8Wo16IwnDv4+c6XwrGR4uI4r/+Zz99ibYlJDAOREj0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593790409; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=TgBnNY+2WV0e8/kWUtIYyrE1baZDFHlj+IejXzvllD8=; b=d6JZwJJuc5pa/e5ys6G9/NeQTSiNSCxdxhbHCEL3vu+jGh7MBAYz+0lxWEQWo4gZrkBNVLYdJN8NWhhpr3rTIDJhtlvfhneS2x4g/4OFw2pcVcK/dACTYbiCyUyaFJUlyyp3UaJRIN1Wj2sKjNTPiFB7+A3jv7sAQ9GOAsy2Zw8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 159379040967381.78142041158367; Fri, 3 Jul 2020 08:33:29 -0700 (PDT) Received: from localhost ([::1]:53572 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jrNgu-0005Dr-Ej for importer@patchew.org; Fri, 03 Jul 2020 11:33:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51110) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jrNbl-000768-Nr for qemu-devel@nongnu.org; Fri, 03 Jul 2020 11:28:09 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:58093 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1jrNbg-0006eC-AV for qemu-devel@nongnu.org; Fri, 03 Jul 2020 11:28:09 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-367-4XdK1vOXN52AiGmc0iux8A-1; Fri, 03 Jul 2020 11:28:00 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id CAE7B800C60; Fri, 3 Jul 2020 15:27:59 +0000 (UTC) Received: from dgilbert-t580.localhost (ovpn-114-207.ams2.redhat.com [10.36.114.207]) by smtp.corp.redhat.com (Postfix) with ESMTP id CF3F42DE72; Fri, 3 Jul 2020 15:27:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593790082; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=TgBnNY+2WV0e8/kWUtIYyrE1baZDFHlj+IejXzvllD8=; b=hTRRcDqRvigdy4xjIfg+9/iiVOQiWLbtvfu0zDkzC9Ag7zzMvHwXyW9JGldGQsUrmtIYJW 4phqq4VaPe0/e7Y3hDImOo9Uqo95wCuGv7DVXyFFBOU18gsglQzh9i6E4l4BklPfaA/Tta U/vadCUA9TjBawbsoXA40/zhnicnSus= X-MC-Unique: 4XdK1vOXN52AiGmc0iux8A-1 From: "Dr. David Alan Gilbert (git)" To: qemu-devel@nongnu.org, quintela@redhat.com, zhukeqian1@huawei.com, stefanha@redhat.com Subject: [PULL 5/5] migration: Count new_dirty instead of real_dirty Date: Fri, 3 Jul 2020 16:27:48 +0100 Message-Id: <20200703152748.277255-6-dgilbert@redhat.com> In-Reply-To: <20200703152748.277255-1-dgilbert@redhat.com> References: <20200703152748.277255-1-dgilbert@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dgilbert@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=207.211.31.81; envelope-from=dgilbert@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/03 01:34:15 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Keqian Zhu real_dirty_pages becomes equal to total ram size after dirty log sync in ram_init_bitmaps, the reason is that the bitmap of ramblock is initialized to be all set, so old path counts them as "real dirty" at beginning. This causes wrong dirty rate and false positive throttling. Signed-off-by: Keqian Zhu Message-Id: <20200622032037.31112-1-zhukeqian1@huawei.com> Reviewed-by: Dr. David Alan Gilbert Signed-off-by: Dr. David Alan Gilbert --- include/exec/ram_addr.h | 5 +---- migration/ram.c | 8 +++++--- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/include/exec/ram_addr.h b/include/exec/ram_addr.h index 7b5c24e928..3ef729a23c 100644 --- a/include/exec/ram_addr.h +++ b/include/exec/ram_addr.h @@ -442,8 +442,7 @@ static inline void cpu_physical_memory_clear_dirty_rang= e(ram_addr_t start, static inline uint64_t cpu_physical_memory_sync_dirty_bitmap(RAMBlock *rb, ram_addr_t start, - ram_addr_t length, - uint64_t *real_dirty_pages) + ram_addr_t length) { ram_addr_t addr; unsigned long word =3D BIT_WORD((start + rb->offset) >> TARGET_PAGE_BI= TS); @@ -469,7 +468,6 @@ uint64_t cpu_physical_memory_sync_dirty_bitmap(RAMBlock= *rb, if (src[idx][offset]) { unsigned long bits =3D atomic_xchg(&src[idx][offset], 0); unsigned long new_dirty; - *real_dirty_pages +=3D ctpopl(bits); new_dirty =3D ~dest[k]; dest[k] |=3D bits; new_dirty &=3D bits; @@ -502,7 +500,6 @@ uint64_t cpu_physical_memory_sync_dirty_bitmap(RAMBlock= *rb, start + addr + offset, TARGET_PAGE_SIZE, DIRTY_MEMORY_MIGRATION)) { - *real_dirty_pages +=3D 1; long k =3D (start + addr) >> TARGET_PAGE_BITS; if (!test_and_set_bit(k, dest)) { num_dirty++; diff --git a/migration/ram.c b/migration/ram.c index 069b6e30bc..5554a7d2d8 100644 --- a/migration/ram.c +++ b/migration/ram.c @@ -859,9 +859,11 @@ static inline bool migration_bitmap_clear_dirty(RAMSta= te *rs, /* Called with RCU critical section */ static void ramblock_sync_dirty_bitmap(RAMState *rs, RAMBlock *rb) { - rs->migration_dirty_pages +=3D - cpu_physical_memory_sync_dirty_bitmap(rb, 0, rb->used_length, - &rs->num_dirty_pages_period); + uint64_t new_dirty_pages =3D + cpu_physical_memory_sync_dirty_bitmap(rb, 0, rb->used_length); + + rs->migration_dirty_pages +=3D new_dirty_pages; + rs->num_dirty_pages_period +=3D new_dirty_pages; } =20 /** --=20 2.26.2