From nobody Sat Dec 21 13:53:57 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass(p=reject dis=none) header.from=lists.libvirt.org ARC-Seal: i=1; a=rsa-sha256; t=1726178714; cv=none; d=zohomail.com; s=zohoarc; b=E1nRThCJ243gjqsfFZVMev7RBsPc29RCq9c/0Ds3mQRGZ5a2RtqiWLKpravzvyqDFji3MmrW+Q7OuGRUimtDYiWCvldPSxL1CERJR6uiljzYC/C+O/HkZpx15BbJxyjBAXZhathIpka7vM/FmHEjvZ0XTp6yXYzmuHf7TtUWHZI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1726178714; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:Subject:Subject:To:To:Message-Id; bh=z2BRm1V8J99LmRT9m8vSwpI4ywutuMOaXlJtIOgRNWw=; b=XOZd0DAm+RZ/IzKdinZvL1D6Kgw9QSSBsQigkKCXTSvFdPSmccrHwrVbG5B08IQxvNofj8ALsjsliawwnvcEMXx/FBkktXUxOgtI2qtIjHdeyi9TiAxcOQDIAJ+8R7Pvog9NJcbKciTi/Hub6DAJhmuf0E1Y3CY6atoDjR8IzT0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1726178714217947.6956763896388; Thu, 12 Sep 2024 15:05:14 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 0D56F1557; Thu, 12 Sep 2024 18:05:13 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 42A731543; Thu, 12 Sep 2024 18:04:54 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id CB1FC14EF; Thu, 12 Sep 2024 18:04:50 -0400 (EDT) Received: from mail-wr1-f66.google.com (mail-wr1-f66.google.com [209.85.221.66]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 5A30A14FA for ; Thu, 12 Sep 2024 18:04:49 -0400 (EDT) Received: by mail-wr1-f66.google.com with SMTP id ffacd0b85a97d-374d29ad8a7so1191573f8f.2 for ; Thu, 12 Sep 2024 15:04:49 -0700 (PDT) Received: from localhost ([192.150.154.54]) by smtp.gmail.com with ESMTPSA id e9e14a558f8ab-3a088522f7asm3683595ab.54.2024.09.12.15.04.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Sep 2024 15:04:46 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1726178688; x=1726783488; darn=lists.libvirt.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=PUP+i0AmzQWzTj7Z97KKK5zmwTm9OeI8FskdixLEjvs=; b=UJrvDsAOxU9LlAYBWeCWmQCHM462pX8+djAqxGVucP1n2FnEEs7EmI6zuT2XlZ6Y7p 53rq+0kK1NFooInAqVRqEnyNC2hDplUXZlQ4aHb5NF7sP30N38zKpcEphDA5ZtaRNAOn J3UNkJ4+w+sCB0mW8w7M0pRRpZ+wcTMTvbJTbG7uiwv0DVtklShGh4N9YQlpsLPYLklY +bfOOe/4TNyvNSXPAb3HYTc4piuBizVCC5l4I5H2f5+TCo4U3Ik+exs1PHxzP869f7fY GrSSxp8DZ4lnmgLaZVdXxcaPIrcpaBhGB1Z6TM924f1G047NcGYqaO7h7+dMFUI6dbxS 3FAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726178688; x=1726783488; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=PUP+i0AmzQWzTj7Z97KKK5zmwTm9OeI8FskdixLEjvs=; b=PBSSg9jmjKrN6/MNpVtIqMMZtGKCuVKGcbjI0ZD4W1oJQwtkmlqGQfPY2s4TojZAN1 8wB1VzJegOvkNSsEaJtzLbUwLFa8sTK0BCtyWGu5vrt5j/xp3RJ/gBTYVdz5UhnrKM0y 2skewySicz0iRH89oFNjdenaEAW8y//5q5Ia/6bIbpdw2vXrP5UPvwYwL8/XW8U0sVmU //18JDcfaF25j46P4Q3yYCfjeqtwlqnrjf2RAxEpMWh4S30abGHnCNl/OeijHndWTXfw BeeGm1vXPjpHEbdrWkaxZAMGuZxdgRzYGIqmQ89HGY4NQg3zP133yEWsk1RmsQn+gnwX m5LA== X-Gm-Message-State: AOJu0Yyox9mhTx/Bv/rgRIOYuzj1S1zsUCeliIUKHgUXDXiX6JGvXuMS IpMx1V9K2NzrS6XiaL6wAqyHvb8yedryFeqwDm1dyGhEX07Bnk/MfnydrxmdWQCnQ02cHs1l2PO 9IwquWw== X-Google-Smtp-Source: AGHT+IF3FxJ8M0UU4zUysj5s5V51L0QXg1wrqIKFUm06ApKBVErrUFhFX7bQLBWvu+hcluiXQxB/kQ== X-Received: by 2002:a05:6000:1941:b0:374:c69b:5a21 with SMTP id ffacd0b85a97d-378c2d51626mr2167607f8f.36.1726178687897; Thu, 12 Sep 2024 15:04:47 -0700 (PDT) To: devel@lists.libvirt.org Subject: [PATCH V2] libxl: Reject VM config referencing nwfilters Date: Thu, 12 Sep 2024 16:04:44 -0600 Message-Id: <20240912220444.12961-1-jfehlig@suse.com> X-Mailer: git-send-email 2.35.3 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: UHG4TMYRRHTHQSYAVDOB46KHZ6QPIT4O X-Message-ID-Hash: UHG4TMYRRHTHQSYAVDOB46KHZ6QPIT4O X-MailFrom: jfehlig@suse.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: demi@invisiblethingslab.com X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: From: Jim Fehlig via Devel Reply-To: Jim Fehlig X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1726178715038116600 Content-Type: text/plain; charset="utf-8" The Xen libxl driver does not support nwfilter. Introduce a deviceValidateCallback function with a check for nwfilters, returning VIR_ERR_CONFIG_UNSUPPORTED if any are found. Also fail to start any existing VMs referencing nwfilters. Drivers generally ignore unrecognized XML configuration, but ignoring a user's request to filter VM network traffic can be viewed as a security issue. Signed-off-by: Jim Fehlig --- This is a V2 of patch2 from this series https://lists.libvirt.org/archives/list/devel@lists.libvirt.org/thread/QDRD= SKDLL5GZVXDSIJO5R32Q5F4AFZLR/ I've pushed patch1. Personally I'm fine leaving it at that, but I made it this far so might as well give patch2 another attempt :-). There's still the open question whether the same should be done for the other hypervisor drivers that do not support nwfilters. Changes in V2: Use deviceValidateCallback instead of devicesPostParseCallback Reject use of nwfilters at VM start src/libxl/libxl_conf.c | 7 +++++++ src/libxl/libxl_domain.c | 18 ++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c index 62e1be6672..bf5d925a20 100644 --- a/src/libxl/libxl_conf.c +++ b/src/libxl/libxl_conf.c @@ -1279,6 +1279,13 @@ libxlMakeNic(virDomainDef *def, * x_nics[i].mtu =3D 1492; */ =20 + if (l_nic->filter) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("filterref is not supported in %1$s"), + virDomainVirtTypeToString(def->virtType)); + return -1; + } + if (l_nic->script && !(actual_type =3D=3D VIR_DOMAIN_NET_TYPE_BRIDGE || actual_type =3D=3D VIR_DOMAIN_NET_TYPE_ETHERNET= )) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c index 0f129ec69c..d400f32627 100644 --- a/src/libxl/libxl_domain.c +++ b/src/libxl/libxl_domain.c @@ -356,12 +356,30 @@ libxlDomainDefValidate(const virDomainDef *def, return 0; } =20 +static int +libxlDomainDeviceDefValidate(const virDomainDeviceDef *dev, + const virDomainDef *def, + void *opaque G_GNUC_UNUSED, + void *parseOpaque G_GNUC_UNUSED) +{ + if (dev->type =3D=3D VIR_DOMAIN_DEVICE_NET && dev->data.net->filter) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("filterref is not supported in %1$s"), + virDomainVirtTypeToString(def->virtType)); + return -1; + } + + return 0; +} + + virDomainDefParserConfig libxlDomainDefParserConfig =3D { .macPrefix =3D { 0x00, 0x16, 0x3e }, .netPrefix =3D LIBXL_GENERATED_PREFIX_XEN, .devicesPostParseCallback =3D libxlDomainDeviceDefPostParse, .domainPostParseCallback =3D libxlDomainDefPostParse, .domainValidateCallback =3D libxlDomainDefValidate, + .deviceValidateCallback =3D libxlDomainDeviceDefValidate, =20 .features =3D VIR_DOMAIN_DEF_FEATURE_USER_ALIAS | VIR_DOMAIN_DEF_FEATURE_FW_AUTOSELECT | --=20 2.35.3