From nobody Fri May 17 09:18:51 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1672763270; cv=none; d=zohomail.com; s=zohoarc; b=XlixOcYJJpSj3/mpMuTorLQbQShBiVRQT2MO0K540BTJ8w9wECKoaBepnIyY6USACPgV8Y6KPodQtpSq4fR+dKoomsGt4mQoanXKguJoa5AjFc8rAlHH4wjukAP+xPxvHqfO4FHeQGT9j1s69/dN8ZANxbpJ+pa3ZQ519upU374= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1672763270; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=sOOxbvXdgvOP4zB6Hz/UxCObXpoZMeoP71k2k11fUcc=; b=BEzLv0k10F042MUCYjWwXhUaSNs5ulZhBPiTuZLk5eUt/EqvTvC+QrpzZiRT/ytZ0aE/Peo8gMWAgoKUhpwwwblg1p/DLrMdb34BTmyGc/Nri/mGSi50Oi6Gdgixo6oLpVr8u6nIKeCkfEtAChb9J20zHyy/aFxPTaAWpgms2Gg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1672763270881761.3838854999838; Tue, 3 Jan 2023 08:27:50 -0800 (PST) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-661--R1det9hObWtC_cANFeOzg-1; Tue, 03 Jan 2023 11:27:44 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C65653C38FE6; Tue, 3 Jan 2023 16:27:41 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id EBC3EC15BA0; Tue, 3 Jan 2023 16:27:38 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id C50311946588; Tue, 3 Jan 2023 16:27:38 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 605B61946587 for ; Tue, 3 Jan 2023 16:27:37 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 0D6FA492C18; Tue, 3 Jan 2023 16:27:32 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id AA94D492C14 for ; Tue, 3 Jan 2023 16:27:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1672763270; h=from:from:sender:sender: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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=sOOxbvXdgvOP4zB6Hz/UxCObXpoZMeoP71k2k11fUcc=; b=ha9CBQt0VbYKY4R4HMYGoYP4aLSdf23UbJlAR01PwmgTV28SxAfuk0pGASPHjD85U6qghj tjfweFEsXhlePwWiYLsfQrwx8EmjeI8Jhfk53amqbuQr8PqN8kaYHR10FFGRKbaBJkhcCd 2FJ0NMxcl2i2vKL1BdRCfzDUIN+LLI4= X-MC-Unique: -R1det9hObWtC_cANFeOzg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH] qemu_namespace: Fix detection of nested mount points Date: Tue, 3 Jan 2023 17:27:27 +0100 Message-Id: <6aac70f94dd8e96686878180c85af7950049f2af.1672763247.git.mprivozn@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1672763272061100001 Content-Type: text/plain; charset="utf-8"; x-default="true" When deciding whether to bind mount a path in domain's namespace, we look at the QEMU mount table (/proc/$pid/mounts) and try to match prefix of given path with one of mount points. Well, we do that in a bit clumsy way. For instance, if there's "/dev/hugepages" already mounted inside the namespace and we are deciding whether to bind mount "/dev/hugepages1G/..." we decide to skip over the path and NOT bind mount it. This is because plain STRPREFIX() is used and yes, the former is prefix of the latter. What we need to check also is whether the next character after the prefix is slash. Signed-off-by: Michal Privoznik Reviewed-by: Peter Krempa --- src/qemu/qemu_namespace.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_namespace.c b/src/qemu/qemu_namespace.c index fb79460109..fc348c043e 100644 --- a/src/qemu/qemu_namespace.c +++ b/src/qemu/qemu_namespace.c @@ -1264,9 +1264,11 @@ qemuNamespacePrepareOneItem(qemuNamespaceMknodData *= data, bool found =3D false; =20 for (n =3D devMountsPath; n && *n; n++) { + const char *p; + if (STREQ(*n, "/dev")) continue; - if (STRPREFIX(item.file, *n)) { + if ((p =3D STRSKIP(item.file, *n)) && *p =3D=3D '/') { found =3D true; break; } --=20 2.38.2