From nobody Sat May 18 22:54:08 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1615529900; cv=none; d=zohomail.com; s=zohoarc; b=mNZOPXKp/V6T4E2ob+0FIdnn5ehoFehvlaChrCJn2+NE9LeQsj6oiz97prboxKyURsT1Z+aL4+ueQZrpkHXNUIYDYzOzKyDla8D8yz9QOB6pl4XfhIdwD1ru0OgHdf5ebi6Jdi7n4STpcQx+Iw/ra2/7K1elGCJIJ+BCiw3w9Lc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1615529900; h=Content-Type:Content-Transfer-Encoding:Cc: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=5zEzMfg/wj4Rhh5BSpxXPJCT+SYE/L9MbBTqBoF1i98=; b=DW1orD1f86erD6SwEPXYL/CTDHuOcu5eoedsWAiHypDULOKV4xTLNe/6ATsBm/CmvNXRM2Ms9ghUgIe80rPCVA/5jlT6v0Fk3Ikm0m1wWonvasp0LRvTTe6rVm1+kie2TUPA3dzZMpOXhdrlCoJRSmBw4L9tJ57fUTFYDsE4d6w= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail 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 1615529900407428.7453252826007; Thu, 11 Mar 2021 22:18:20 -0800 (PST) Received: from localhost ([::1]:47074 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lKb7r-0001ib-5a for importer@patchew.org; Fri, 12 Mar 2021 01:18:19 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:60298) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lKb6H-0008Jj-Jw for qemu-devel@nongnu.org; Fri, 12 Mar 2021 01:16:41 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:27817) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1lKb6F-0005ci-4M for qemu-devel@nongnu.org; Fri, 12 Mar 2021 01:16:41 -0500 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-232-7Tvy5U9BPuCJAhdm91rEqw-1; Fri, 12 Mar 2021 01:16:33 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 94AD981744F; Fri, 12 Mar 2021 06:16:32 +0000 (UTC) Received: from jason-ThinkPad-T430s.redhat.com (ovpn-12-126.pek2.redhat.com [10.72.12.126]) by smtp.corp.redhat.com (Postfix) with ESMTP id 33171101F501; Fri, 12 Mar 2021 06:16:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1615529797; 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=5zEzMfg/wj4Rhh5BSpxXPJCT+SYE/L9MbBTqBoF1i98=; b=eP8nsANjx5grsWqgBun4MK2tXEVIW0pOJcLjw+e84b9CH72A1l/VWNr8xAkSXJ2LNSY4sw iy7Qta/cuRyN9PPLGzT8u5qg/brGJFu+tRY8O9DoxvCoaN/E09z8kFiF8AQIP2jhoNOQ36 V20uCnfGGSC2LVoSdYXMCBD3mYTNGwI= X-MC-Unique: 7Tvy5U9BPuCJAhdm91rEqw-1 From: Jason Wang To: peter.maydell@linaro.org Subject: [PULL 01/16] virtio-net: calculating proper msix vectors on init Date: Fri, 12 Mar 2021 14:16:11 +0800 Message-Id: <1615529786-30763-2-git-send-email-jasowang@redhat.com> In-Reply-To: <1615529786-30763-1-git-send-email-jasowang@redhat.com> References: <1615529786-30763-1-git-send-email-jasowang@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jasowang@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" 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=63.128.21.124; envelope-from=jasowang@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.25, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no 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: , Cc: Jason Wang , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Currently, the default msix vectors for virtio-net-pci is 3 which is obvious not suitable for multiqueue guest, so we depends on the user or management tools to pass a correct vectors parameter. In fact, we can simplifying this by calculating the number of vectors on realize. Consider we have N queues, the number of vectors needed is 2*N + 2 (#queue pairs + plus one config interrupt and control vq). We didn't check whether or not host support control vq because it was added unconditionally by qemu to avoid breaking legacy guests such as Minix. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Stefan Hajnoczi Signed-off-by: Jason Wang --- hw/core/machine.c | 1 + hw/virtio/virtio-net-pci.c | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/hw/core/machine.c b/hw/core/machine.c index 4386f57..979133f 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -39,6 +39,7 @@ GlobalProperty hw_compat_5_2[] =3D { { "ICH9-LPC", "smm-compat", "on"}, { "PIIX4_PM", "smm-compat", "on"}, + { "virtio-net-pci", "vectors", "3"}, }; const size_t hw_compat_5_2_len =3D G_N_ELEMENTS(hw_compat_5_2); =20 diff --git a/hw/virtio/virtio-net-pci.c b/hw/virtio/virtio-net-pci.c index 292d13d..aa0b3ca 100644 --- a/hw/virtio/virtio-net-pci.c +++ b/hw/virtio/virtio-net-pci.c @@ -41,7 +41,8 @@ struct VirtIONetPCI { static Property virtio_net_properties[] =3D { DEFINE_PROP_BIT("ioeventfd", VirtIOPCIProxy, flags, VIRTIO_PCI_FLAG_USE_IOEVENTFD_BIT, true), - DEFINE_PROP_UINT32("vectors", VirtIOPCIProxy, nvectors, 3), + DEFINE_PROP_UINT32("vectors", VirtIOPCIProxy, nvectors, + DEV_NVECTORS_UNSPECIFIED), DEFINE_PROP_END_OF_LIST(), }; =20 @@ -50,6 +51,13 @@ static void virtio_net_pci_realize(VirtIOPCIProxy *vpci_= dev, Error **errp) DeviceState *qdev =3D DEVICE(vpci_dev); VirtIONetPCI *dev =3D VIRTIO_NET_PCI(vpci_dev); DeviceState *vdev =3D DEVICE(&dev->vdev); + VirtIONet *net =3D VIRTIO_NET(vdev); + + if (vpci_dev->nvectors =3D=3D DEV_NVECTORS_UNSPECIFIED) { + vpci_dev->nvectors =3D 2 * MAX(net->nic_conf.peers.queues, 1) + + 1 /* Config interrupt */ + + 1 /* Control vq */; + } =20 virtio_net_set_netclient_name(&dev->vdev, qdev->id, object_get_typename(OBJECT(qdev))); --=20 2.7.4 From nobody Sat May 18 22:54:08 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1615529902; cv=none; d=zohomail.com; s=zohoarc; b=FASeezuM2hqr2mLkFnKyapXj0/8z9Wr9XJ9UcTK98HHM6ATPznysf5p2jOQYF3nDP7CMpznFV6o/lXpwA08dgYlsvqibpBW5L52eOjM6qIwd7x5uhZPAyLf3m5VSCGHxdh0XpKty8Kx1aZhL5bT/8CmggFxnXAdZWsAC+tlomuQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1615529902; h=Content-Type:Content-Transfer-Encoding:Cc: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=wdtR9IURHSBCH/7Cd8JFFpyrCeL7bbZBZfTfFoEPuLE=; b=ixVrnajj/P+MfUqAuSN2wRqyEXDPjTQGD6rmuGJFatftNOKXd2+gKh7PtxJwyKicMiZYr2bPdtNNhngw5sauEMNqpAplzzcPkRao9GUN0l72SoGLKlzW55nCy8CAarGgnwDVRa+YpJJDXnNC7kXTAeG8M8cfv1Mvlh+5/je7uII= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail 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 1615529902080447.44050307154964; Thu, 11 Mar 2021 22:18:22 -0800 (PST) Received: from localhost ([::1]:47228 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lKb7s-0001mI-Sg for importer@patchew.org; Fri, 12 Mar 2021 01:18:20 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:60326) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lKb6I-0008LN-SV for qemu-devel@nongnu.org; Fri, 12 Mar 2021 01:16:42 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:41183) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1lKb6H-0005es-Br for qemu-devel@nongnu.org; Fri, 12 Mar 2021 01:16:42 -0500 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-71-RAHgoNJEPtWDsvAl3ZWwdg-1; Fri, 12 Mar 2021 01:16:36 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E42DD8018A3; Fri, 12 Mar 2021 06:16:34 +0000 (UTC) Received: from jason-ThinkPad-T430s.redhat.com (ovpn-12-126.pek2.redhat.com [10.72.12.126]) by smtp.corp.redhat.com (Postfix) with ESMTP id 20D331037E80; Fri, 12 Mar 2021 06:16:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1615529800; 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=wdtR9IURHSBCH/7Cd8JFFpyrCeL7bbZBZfTfFoEPuLE=; b=HcIuD7H+Oc4RL4HI0rbpvFUa97bxvIraOxoW/4IDIl8qZTcuFLMB9BwTWhDqotaosuAw3H UFpjlXWW6NnP8PSo48VsHbJld/vFawei3rElySWHzzjd+kAdUU38zs9baoI0bx2a5v/jAY GkmR/vu6Y4ItPTVqkOGGl/1XazrDGnk= X-MC-Unique: RAHgoNJEPtWDsvAl3ZWwdg-1 From: Jason Wang To: peter.maydell@linaro.org Subject: [PULL 02/16] net: Fix build error when DEBUG_NET is on Date: Fri, 12 Mar 2021 14:16:12 +0800 Message-Id: <1615529786-30763-3-git-send-email-jasowang@redhat.com> In-Reply-To: <1615529786-30763-1-git-send-email-jasowang@redhat.com> References: <1615529786-30763-1-git-send-email-jasowang@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jasowang@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" 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=216.205.24.124; envelope-from=jasowang@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.25, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no 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: , Cc: Jason Wang , Bin Meng , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Bin Meng "qemu-common.h" should be included to provide the forward declaration of qemu_hexdump() when DEBUG_NET is on. Signed-off-by: Bin Meng Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Jason Wang --- net/net.c | 1 + 1 file changed, 1 insertion(+) diff --git a/net/net.c b/net/net.c index 6002ba5..9c784da 100644 --- a/net/net.c +++ b/net/net.c @@ -23,6 +23,7 @@ */ =20 #include "qemu/osdep.h" +#include "qemu-common.h" =20 #include "net/net.h" #include "clients.h" --=20 2.7.4 From nobody Sat May 18 22:54:08 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1615530023; cv=none; d=zohomail.com; s=zohoarc; b=nIhEzVgWe//RpNnzWKWbAWC8SPAoyzblg530JWU6rOnVUJ7BjeXMo/Ej0Zmvlgj5dYPp0OYQM1a1BN0Ik+2GmKg3ozPP5yORNBFb/1S2fWdye7vTKsrdsHtZYfFergEXsJd1ChE4nOOsOkEwDw0yl2K318HkT/kM3+eHWwPIfnU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1615530023; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=LPhbcqyxcyoyPXkD5fH7Pir5XGNglXAH1qxGcICQIdM=; b=naCiIZtaJAn4PHvJrhlV+w9EuHfKyqXvkuLEE6riBWOPVxkQoYitVhCpPj7mGs27GBKkij73ZizN9ATOGBQNiWaWWYfXp5a3Dyzg6VP7O7DZON3ued3UZ7U/n+eYH7fAcx/WYJ9AhSmhYlv1N9jHpC5Dsvdu8KxnwQw3gZpYIB4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail 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 161553002317386.12063457279157; Thu, 11 Mar 2021 22:20:23 -0800 (PST) Received: from localhost ([::1]:55562 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lKb9q-0005Do-4K for importer@patchew.org; Fri, 12 Mar 2021 01:20:22 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:60332) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lKb6J-0008M6-BW for qemu-devel@nongnu.org; Fri, 12 Mar 2021 01:16:43 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:22206) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1lKb6H-0005f0-Ns for qemu-devel@nongnu.org; Fri, 12 Mar 2021 01:16:43 -0500 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-533-cyzFnnf_NYufnWEpe8Ssng-1; Fri, 12 Mar 2021 01:16:38 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 218A992504; Fri, 12 Mar 2021 06:16:37 +0000 (UTC) Received: from jason-ThinkPad-T430s.redhat.com (ovpn-12-126.pek2.redhat.com [10.72.12.126]) by smtp.corp.redhat.com (Postfix) with ESMTP id 71AD6101F501; Fri, 12 Mar 2021 06:16:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1615529800; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:content-type:content-type:in-reply-to:in-reply-to: references:references; bh=LPhbcqyxcyoyPXkD5fH7Pir5XGNglXAH1qxGcICQIdM=; b=FqH8a2BNG+8Ww3zDXMo0kpgAz9r+kVCZwg+HbhlOqkHvIqEuy39DamaTuNTlfK/hjpAI6h ZJxoodfwn9cyMMiyEgurry24bJAbDPf92NzpZ4VdCusjm4WgQD53VxH67tbrhGZlXSYfOd Gqf4dvxTNdXooYJ5u9aU05gfTZAnPUg= X-MC-Unique: cyzFnnf_NYufnWEpe8Ssng-1 From: Jason Wang To: peter.maydell@linaro.org Subject: [PULL 03/16] net: validate that ids are well formed Date: Fri, 12 Mar 2021 14:16:13 +0800 Message-Id: <1615529786-30763-4-git-send-email-jasowang@redhat.com> In-Reply-To: <1615529786-30763-1-git-send-email-jasowang@redhat.com> References: <1615529786-30763-1-git-send-email-jasowang@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jasowang@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=216.205.24.124; envelope-from=jasowang@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.25, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no 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: , Cc: Paolo Bonzini , Jason Wang , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Paolo Bonzini When a network or network device is created from the command line or HMP, QemuOpts ensures that the id passes the id_wellformed check. However, QMP skips this: $ qemu-system-x86_64 -qmp stdio -S -nic user,id=3D123/456 qemu-system-x86_64: -nic user,id=3D123/456: Parameter id expects an iden= tifier Identifiers consist of letters, digits, -, ., _, starting with a letter. $ qemu-system-x86_64 -qmp stdio -S {"execute":"qmp_capabilities"} {"return": {}} {"execute":"netdev_add", "arguments": {"type": "user", "id": "123/456"}} {"return": {}} After: $ qemu-system-x86_64 -qmp stdio -S {"execute":"qmp_capabilities"} {"return": {}} {"execute":"netdev_add", "arguments": {"type": "user", "id": "123/456"}} {"error": {"class": "GenericError", "desc": "Parameter "id" expects an i= dentifier"}} Validity checks should be performed always at the bottom of the call chain, because QMP skips all the steps above. Do this for the network subsystem. Cc: Jason Wang Reviewed-by: Eric Blake Signed-off-by: Paolo Bonzini Signed-off-by: Jason Wang --- net/net.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/net/net.c b/net/net.c index 9c784da..d36729f 100644 --- a/net/net.c +++ b/net/net.c @@ -44,6 +44,7 @@ #include "qemu/cutils.h" #include "qemu/config-file.h" #include "qemu/ctype.h" +#include "qemu/id.h" #include "qemu/iov.h" #include "qemu/qemu-print.h" #include "qemu/main-loop.h" @@ -1011,6 +1012,17 @@ static int net_client_init1(const Netdev *netdev, bo= ol is_netdev, Error **errp) } } =20 + /* + * The id for -net has already been checked by QemuOpts and + * could be automatically generated, in which case it is not + * well-formed by design. HMP and QMP only call us with + * is_netdev =3D=3D true. + */ + if (is_netdev && !id_wellformed(netdev->id)) { + error_setg(errp, QERR_INVALID_PARAMETER_VALUE, "id", "an identifie= r"); + return -1; + } + nc =3D qemu_find_netdev(netdev->id); if (nc) { error_setg(errp, "Duplicate ID '%s'", netdev->id); --=20 2.7.4 From nobody Sat May 18 22:54:08 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1615529906; cv=none; d=zohomail.com; s=zohoarc; b=LUoeAX/98GewJjgWmOjFO04zzHdey8mPP7EOKe9075/gM81kcY6e+8EcgVwj44j+Xrbc+0wbNH9LUjqxn4kEYv7uyxYsEK7xqMzjUtWuARmxn4DuP5MPah7YHkpKyOXXNZ7xh6HVk4VFRSjGDAGqg7puIPhpHcCfaH1B+vXRDvY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1615529906; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=zW9hyJYHJ9pE8jgpFjlmvcLUuE9o200mHrxveLpfK2o=; b=oHKZ86dv2sGe3+lpHWNnqcL+sUNnWfdxYHeFMWkv4k62Mz0eM6tLLBvEN1BlSlxbKzbVNQWO8QGXwQC1dMLLBXV+kwVxOpdBXClThNjeJM3Js2sky3QnwcToKRUNUNleE4kDCVXfy7BW+uAtcKUoO/GUGudXehu7ssFTVh9ZNnE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail 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 1615529906731117.12518301420971; Thu, 11 Mar 2021 22:18:26 -0800 (PST) Received: from localhost ([::1]:47584 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lKb7x-0001v4-N8 for importer@patchew.org; Fri, 12 Mar 2021 01:18:25 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:60376) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lKb6M-0008Sq-6N for qemu-devel@nongnu.org; Fri, 12 Mar 2021 01:16:46 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:60808) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1lKb6K-0005hb-JH for qemu-devel@nongnu.org; Fri, 12 Mar 2021 01:16:45 -0500 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-419-oOL-oKYgOOCO9rTpnrFiJA-1; Fri, 12 Mar 2021 01:16:40 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0BD3918397A0; Fri, 12 Mar 2021 06:16:39 +0000 (UTC) Received: from jason-ThinkPad-T430s.redhat.com (ovpn-12-126.pek2.redhat.com [10.72.12.126]) by smtp.corp.redhat.com (Postfix) with ESMTP id A22C1101F501; Fri, 12 Mar 2021 06:16:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1615529804; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:content-type:content-type:in-reply-to:in-reply-to: references:references; bh=zW9hyJYHJ9pE8jgpFjlmvcLUuE9o200mHrxveLpfK2o=; b=OmIMKN40ayNPYV8AyVWxadaVHgTxpkJTs6bI6KXsUtFRxElmwFSIK80mW13m2Nu1rBKk+X 1LkVbCB/ikYyOSWM6HFGJ/OXitE9Brmdj3IravizFBHmZ7Ed+81kWsurCrfRQnk1Dma8Hr yMXV0dbWCG6vI76ez5GleKK4ToT6j8A= X-MC-Unique: oOL-oKYgOOCO9rTpnrFiJA-1 From: Jason Wang To: peter.maydell@linaro.org Subject: [PULL 04/16] net: unbreak well-form id check for "-nic" Date: Fri, 12 Mar 2021 14:16:14 +0800 Message-Id: <1615529786-30763-5-git-send-email-jasowang@redhat.com> In-Reply-To: <1615529786-30763-1-git-send-email-jasowang@redhat.com> References: <1615529786-30763-1-git-send-email-jasowang@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jasowang@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=216.205.24.124; envelope-from=jasowang@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.25, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no 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: , Cc: Jason Wang , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The auto genreated id for "-nic" has "_" prefix which can't satisfy the well-formed id check that is introduced by 871579b9834aca517dc2d4941691a1d2082db6f2 ("net: validate that ids are well formed"). Fix this by simply removing the "__" prefix. Signed-off-by: Jason Wang --- net/net.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/net.c b/net/net.c index d36729f..254b42f 100644 --- a/net/net.c +++ b/net/net.c @@ -1479,7 +1479,7 @@ static int net_param_nic(void *dummy, QemuOpts *opts,= Error **errp) /* Create an ID if the user did not specify one */ nd_id =3D g_strdup(qemu_opts_id(opts)); if (!nd_id) { - nd_id =3D g_strdup_printf("__org.qemu.nic%i", idx); + nd_id =3D g_strdup_printf("org.qemu.nic%i", idx); qemu_opts_set_id(opts, nd_id); } =20 --=20 2.7.4 From nobody Sat May 18 22:54:08 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1615530309; cv=none; d=zohomail.com; s=zohoarc; b=Pf+v6t/kS1CsX0JC8Wknb8QwolBtdTPnIUF4XRU0t3qz0COpQSaTbbcz7aQLATN+nuiY1GpYWmN1dBRDb9TV/8iPv+Udo43TzgXxXx9P7kOoCNgnB3gSy/ogG2gAGxF2kNxq4+fvbcECOdMo/sD33hiz00lpP4YKW5HqTKOqOUU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1615530309; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=cHDylX3VDgnAxGpHNhSOXdMfRX+mhcDAqVY6r7JPZHo=; b=U3g5nNICY9rv37V9Rc5klU5m1DoTaxtPcFDLFJ4NBn9k5kKbc5ulVdocFNxTe0lPL6I0qjnlUSerucSmr9GgmQyuNi0vDxLYyg19bz3maGOjRMCJe9ITnJS93kAPJydhCcAN2YUJUPPWe+UoOtqyXxGRYKSZhaycdW0yUZuZkjY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail 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 161553030974124.292431946115585; Thu, 11 Mar 2021 22:25:09 -0800 (PST) Received: from localhost ([::1]:43572 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lKbES-0003fN-GG for importer@patchew.org; Fri, 12 Mar 2021 01:25:08 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:60430) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lKb6Q-0000BA-Ce for qemu-devel@nongnu.org; Fri, 12 Mar 2021 01:16:50 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:20937) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1lKb6N-0005kf-TA for qemu-devel@nongnu.org; Fri, 12 Mar 2021 01:16:50 -0500 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-593-yFEswhfvOS6EqEuctrtHXg-1; Fri, 12 Mar 2021 01:16:42 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8046E1005E6C; Fri, 12 Mar 2021 06:16:41 +0000 (UTC) Received: from jason-ThinkPad-T430s.redhat.com (ovpn-12-126.pek2.redhat.com [10.72.12.126]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8D1CB1037E80; Fri, 12 Mar 2021 06:16:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1615529807; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:content-type:content-type:in-reply-to:in-reply-to: references:references; bh=cHDylX3VDgnAxGpHNhSOXdMfRX+mhcDAqVY6r7JPZHo=; b=J3QuzWaWBwk2GsqaH88TeMmpG6WIODGC4UD1CjV38siO0MK34TuGZsO7Zdg/e284v4fc63 jUGsnVAIwUvGRK96ImiVdgubmo2brOdqyBbFNlZ8fcnVtQQTMzyeIoycMLkslBgWKbc0qI XYmqXoP9klcC7yeR+8/BAWY5ZK3lauI= X-MC-Unique: yFEswhfvOS6EqEuctrtHXg-1 From: Jason Wang To: peter.maydell@linaro.org Subject: [PULL 05/16] e1000: fail early for evil descriptor Date: Fri, 12 Mar 2021 14:16:15 +0800 Message-Id: <1615529786-30763-6-git-send-email-jasowang@redhat.com> In-Reply-To: <1615529786-30763-1-git-send-email-jasowang@redhat.com> References: <1615529786-30763-1-git-send-email-jasowang@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jasowang@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=216.205.24.124; envelope-from=jasowang@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.25, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no 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: , Cc: Jason Wang , qemu-stable@nongnu.org, qemu-devel@nongnu.org, Prasad J Pandit Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" During procss_tx_desc(), driver can try to chain data descriptor with legacy descriptor, when will lead underflow for the following calculation in process_tx_desc() for bytes: if (tp->size + bytes > msh) bytes =3D msh - tp->size; This will lead a infinite loop. So check and fail early if tp->size if greater or equal to msh. Reported-by: Alexander Bulekov Reported-by: Cheolwoo Myung Reported-by: Ruhr-University Bochum Cc: Prasad J Pandit Cc: qemu-stable@nongnu.org Signed-off-by: Jason Wang --- hw/net/e1000.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hw/net/e1000.c b/hw/net/e1000.c index d8da2f6..4345d86 100644 --- a/hw/net/e1000.c +++ b/hw/net/e1000.c @@ -670,6 +670,9 @@ process_tx_desc(E1000State *s, struct e1000_tx_desc *dp) msh =3D tp->tso_props.hdr_len + tp->tso_props.mss; do { bytes =3D split_size; + if (tp->size >=3D msh) { + goto eop; + } if (tp->size + bytes > msh) bytes =3D msh - tp->size; =20 @@ -695,6 +698,7 @@ process_tx_desc(E1000State *s, struct e1000_tx_desc *dp) tp->size +=3D split_size; } =20 +eop: if (!(txd_lower & E1000_TXD_CMD_EOP)) return; if (!(tp->cptse && tp->size < tp->tso_props.hdr_len)) { --=20 2.7.4 From nobody Sat May 18 22:54:08 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1615530150; cv=none; d=zohomail.com; s=zohoarc; b=B40jZFOO903TjW5+5OPrDF1wAkU2lIDzIyZDKB4dIumHvdXvb2DeXe8dT53TaZeJVjjE8UcCwVW9Gzf8ZJp2DnFsGnKhvrkFl+l+mcjT6QxSxUdZEABOI8803hY4t40GvEgLJe6av3x6HFImC/MHSQZzqsw0X8cL3+N89fRQM8s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1615530150; h=Content-Type:Content-Transfer-Encoding:Cc: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=r+Uv3kkGtVymYT1ILAvg4wzrflsAJV2HM3FIlxV2xI8=; b=Hy3rp5d/uj7BxeaPNz/oje8zK0CaIrulI8V8GF9iKtKgJO9SmbbfMtTaIMYWEHlkI32p5gymLvkeVBT6fhqBCehwr6vFxfSUaZODwhQT1GnldZ+sQMjBXgFUEBSb7mr0zMSG9hRGqkixIoBNAA+qtzqmG9AJaVMGJYjBaWjdis4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail 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 1615530150462210.4105911770596; Thu, 11 Mar 2021 22:22:30 -0800 (PST) Received: from localhost ([::1]:35914 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lKbBt-0000SB-EY for importer@patchew.org; Fri, 12 Mar 2021 01:22:29 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:60422) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lKb6P-00008a-Ex for qemu-devel@nongnu.org; Fri, 12 Mar 2021 01:16:49 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:50228) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1lKb6N-0005kM-KI for qemu-devel@nongnu.org; Fri, 12 Mar 2021 01:16:49 -0500 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-497-fkD9BrfKP_eG25IRwW9ecw-1; Fri, 12 Mar 2021 01:16:45 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EE15A1005E71; Fri, 12 Mar 2021 06:16:43 +0000 (UTC) Received: from jason-ThinkPad-T430s.redhat.com (ovpn-12-126.pek2.redhat.com [10.72.12.126]) by smtp.corp.redhat.com (Postfix) with ESMTP id 08F281037E80; Fri, 12 Mar 2021 06:16:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1615529806; 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=r+Uv3kkGtVymYT1ILAvg4wzrflsAJV2HM3FIlxV2xI8=; b=SA7bGIDe2fubrlSaw1XGIJ1+4z1VrHR020GQULyQxns74cZfYewfXq387GUNIrxWJKD4y4 HLKQ/yH6zHPCYfnAH9D/F0hzCe+R+H798UW0C7FRFRgBdgoh3mxO1jHTmwDzOuibXMEajC Dlp/woT9w5x/WGNHCbSEPxu18mjam7w= X-MC-Unique: fkD9BrfKP_eG25IRwW9ecw-1 From: Jason Wang To: peter.maydell@linaro.org Subject: [PULL 06/16] net: introduce qemu_receive_packet() Date: Fri, 12 Mar 2021 14:16:16 +0800 Message-Id: <1615529786-30763-7-git-send-email-jasowang@redhat.com> In-Reply-To: <1615529786-30763-1-git-send-email-jasowang@redhat.com> References: <1615529786-30763-1-git-send-email-jasowang@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jasowang@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" 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=216.205.24.124; envelope-from=jasowang@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.25, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no 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: , Cc: Jason Wang , qemu-stable@nongnu.org, qemu-devel@nongnu.org, Prasad J Pandit Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Some NIC supports loopback mode and this is done by calling nc->info->receive() directly which in fact suppresses the effort of reentrancy check that is done in qemu_net_queue_send(). Unfortunately we can't use qemu_net_queue_send() here since for loopback there's no sender as peer, so this patch introduce a qemu_receive_packet() which is used for implementing loopback mode for a NIC with this check. NIC that supports loopback mode will be converted to this helper. This is intended to address CVE-2021-3416. Cc: Prasad J Pandit Reviewed-by: Philippe Mathieu-Daud=C3=A9 Cc: qemu-stable@nongnu.org Signed-off-by: Jason Wang --- include/net/net.h | 5 +++++ include/net/queue.h | 8 ++++++++ net/net.c | 38 +++++++++++++++++++++++++++++++------- net/queue.c | 22 ++++++++++++++++++++++ 4 files changed, 66 insertions(+), 7 deletions(-) diff --git a/include/net/net.h b/include/net/net.h index 919faca..4f56cae 100644 --- a/include/net/net.h +++ b/include/net/net.h @@ -144,12 +144,17 @@ void *qemu_get_nic_opaque(NetClientState *nc); void qemu_del_net_client(NetClientState *nc); typedef void (*qemu_nic_foreach)(NICState *nic, void *opaque); void qemu_foreach_nic(qemu_nic_foreach func, void *opaque); +int qemu_can_receive_packet(NetClientState *nc); int qemu_can_send_packet(NetClientState *nc); ssize_t qemu_sendv_packet(NetClientState *nc, const struct iovec *iov, int iovcnt); ssize_t qemu_sendv_packet_async(NetClientState *nc, const struct iovec *io= v, int iovcnt, NetPacketSent *sent_cb); ssize_t qemu_send_packet(NetClientState *nc, const uint8_t *buf, int size); +ssize_t qemu_receive_packet(NetClientState *nc, const uint8_t *buf, int si= ze); +ssize_t qemu_receive_packet_iov(NetClientState *nc, + const struct iovec *iov, + int iovcnt); ssize_t qemu_send_packet_raw(NetClientState *nc, const uint8_t *buf, int s= ize); ssize_t qemu_send_packet_async(NetClientState *nc, const uint8_t *buf, int size, NetPacketSent *sent_cb); diff --git a/include/net/queue.h b/include/net/queue.h index c0269bb..9f2f289 100644 --- a/include/net/queue.h +++ b/include/net/queue.h @@ -55,6 +55,14 @@ void qemu_net_queue_append_iov(NetQueue *queue, =20 void qemu_del_net_queue(NetQueue *queue); =20 +ssize_t qemu_net_queue_receive(NetQueue *queue, + const uint8_t *data, + size_t size); + +ssize_t qemu_net_queue_receive_iov(NetQueue *queue, + const struct iovec *iov, + int iovcnt); + ssize_t qemu_net_queue_send(NetQueue *queue, NetClientState *sender, unsigned flags, diff --git a/net/net.c b/net/net.c index 254b42f..6e61053 100644 --- a/net/net.c +++ b/net/net.c @@ -529,6 +529,17 @@ int qemu_set_vnet_be(NetClientState *nc, bool is_be) #endif } =20 +int qemu_can_receive_packet(NetClientState *nc) +{ + if (nc->receive_disabled) { + return 0; + } else if (nc->info->can_receive && + !nc->info->can_receive(nc)) { + return 0; + } + return 1; +} + int qemu_can_send_packet(NetClientState *sender) { int vm_running =3D runstate_is_running(); @@ -541,13 +552,7 @@ int qemu_can_send_packet(NetClientState *sender) return 1; } =20 - if (sender->peer->receive_disabled) { - return 0; - } else if (sender->peer->info->can_receive && - !sender->peer->info->can_receive(sender->peer)) { - return 0; - } - return 1; + return qemu_can_receive_packet(sender->peer); } =20 static ssize_t filter_receive_iov(NetClientState *nc, @@ -680,6 +685,25 @@ ssize_t qemu_send_packet(NetClientState *nc, const uin= t8_t *buf, int size) return qemu_send_packet_async(nc, buf, size, NULL); } =20 +ssize_t qemu_receive_packet(NetClientState *nc, const uint8_t *buf, int si= ze) +{ + if (!qemu_can_receive_packet(nc)) { + return 0; + } + + return qemu_net_queue_receive(nc->incoming_queue, buf, size); +} + +ssize_t qemu_receive_packet_iov(NetClientState *nc, const struct iovec *io= v, + int iovcnt) +{ + if (!qemu_can_receive_packet(nc)) { + return 0; + } + + return qemu_net_queue_receive_iov(nc->incoming_queue, iov, iovcnt); +} + ssize_t qemu_send_packet_raw(NetClientState *nc, const uint8_t *buf, int s= ize) { return qemu_send_packet_async_with_flags(nc, QEMU_NET_PACKET_FLAG_RAW, diff --git a/net/queue.c b/net/queue.c index 19e32c8..c872d51 100644 --- a/net/queue.c +++ b/net/queue.c @@ -182,6 +182,28 @@ static ssize_t qemu_net_queue_deliver_iov(NetQueue *qu= eue, return ret; } =20 +ssize_t qemu_net_queue_receive(NetQueue *queue, + const uint8_t *data, + size_t size) +{ + if (queue->delivering) { + return 0; + } + + return qemu_net_queue_deliver(queue, NULL, 0, data, size); +} + +ssize_t qemu_net_queue_receive_iov(NetQueue *queue, + const struct iovec *iov, + int iovcnt) +{ + if (queue->delivering) { + return 0; + } + + return qemu_net_queue_deliver_iov(queue, NULL, 0, iov, iovcnt); +} + ssize_t qemu_net_queue_send(NetQueue *queue, NetClientState *sender, unsigned flags, --=20 2.7.4 From nobody Sat May 18 22:54:08 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1615530032; cv=none; d=zohomail.com; s=zohoarc; b=Y5HA1tbKMPDmmJYux2vKt/AEjNYZ++cqy9jq5tOjaozJx2VXdgBZoyzadSUYLJwu+2gjHOL+zltBqPckWSxhX7NFu6Sah6hnSYvKXs7k0TzWtk9zT162QJE8DXrQXU0FpmfOLrIEUvdFj0BXGYzWPRadHlqwe7gH0BAlj4Eikic= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1615530032; h=Content-Type:Content-Transfer-Encoding:Cc: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=77lYuJueY3ZZ0H0iB015D9A2tcUPOFqLouZQaLMS7fI=; b=j9JyYBrNHzSk3OiqX1jGOjFY7byec6nO5vIuXogypm2+5EZyI1NQm69E/cc0zhQBe6WVnbGGoSuStPI//P6fA5mp+ruVNb+OEZPJFbVKMbMuJ33velnFCq4vYHQZSdmfwfmMuvlTClwIm5ZLUWJTwWBG+CsEwDF2UTNNbsNlTCE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail 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 1615530032920323.1918188602963; Thu, 11 Mar 2021 22:20:32 -0800 (PST) Received: from localhost ([::1]:55792 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lKb9z-0005Kq-R0 for importer@patchew.org; Fri, 12 Mar 2021 01:20:31 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:60448) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lKb6R-0000E1-Lu for qemu-devel@nongnu.org; Fri, 12 Mar 2021 01:16:51 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:58506) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1lKb6P-0005lj-VW for qemu-devel@nongnu.org; Fri, 12 Mar 2021 01:16:51 -0500 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-224-2N2v5vAEN4Gd6gHwe7RXLA-1; Fri, 12 Mar 2021 01:16:47 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6A84F1074644; Fri, 12 Mar 2021 06:16:46 +0000 (UTC) Received: from jason-ThinkPad-T430s.redhat.com (ovpn-12-126.pek2.redhat.com [10.72.12.126]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7A06B1037E80; Fri, 12 Mar 2021 06:16:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1615529809; 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=77lYuJueY3ZZ0H0iB015D9A2tcUPOFqLouZQaLMS7fI=; b=KxSYZLvet+JLsCGcrtAfXDDq9WrOULUC9Ztr6aL7qxVvm6OHS32WTQAuNxk3WUEE7IBZGW RnylpJjFXWw4jk4PvSgK5Pjd4ZyX0AAcGhhsfOXgcTZECabaHjRpKxTdJcg8eQdRM9gsWL KEBTsjbeAloga5zFbMoDAAv+B30/Fl8= X-MC-Unique: 2N2v5vAEN4Gd6gHwe7RXLA-1 From: Jason Wang To: peter.maydell@linaro.org Subject: [PULL 07/16] e1000: switch to use qemu_receive_packet() for loopback Date: Fri, 12 Mar 2021 14:16:17 +0800 Message-Id: <1615529786-30763-8-git-send-email-jasowang@redhat.com> In-Reply-To: <1615529786-30763-1-git-send-email-jasowang@redhat.com> References: <1615529786-30763-1-git-send-email-jasowang@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jasowang@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" 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=63.128.21.124; envelope-from=jasowang@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.25, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no 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: , Cc: Jason Wang , qemu-stable@nongnu.org, qemu-devel@nongnu.org, Prasad J Pandit Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) This patch switches to use qemu_receive_packet() which can detect reentrancy and return early. This is intended to address CVE-2021-3416. Cc: Prasad J Pandit Cc: qemu-stable@nongnu.org Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Jason Wang --- hw/net/e1000.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/net/e1000.c b/hw/net/e1000.c index 4345d86..4f75b44 100644 --- a/hw/net/e1000.c +++ b/hw/net/e1000.c @@ -546,7 +546,7 @@ e1000_send_packet(E1000State *s, const uint8_t *buf, in= t size) =20 NetClientState *nc =3D qemu_get_queue(s->nic); if (s->phy_reg[PHY_CTRL] & MII_CR_LOOPBACK) { - nc->info->receive(nc, buf, size); + qemu_receive_packet(nc, buf, size); } else { qemu_send_packet(nc, buf, size); } --=20 2.7.4 From nobody Sat May 18 22:54:08 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1615530058; cv=none; d=zohomail.com; s=zohoarc; b=mG+ke1nCHF5ME04ngTpZ3eYHkEsMCVjFyoVyuKNnE7QJLNOyBCyGbrhTVFXo9cS/Cq68uafIc/8krHsqY0cxiEAPI4nb+r6/Bw0GDqBmuXWO+fVg5Xm9AfBrnAtEpOZgVXOOTMQD9TEtjJquCvTnXAzRsovQQ2DH7JKwF1AEOJg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1615530058; h=Content-Type:Content-Transfer-Encoding:Cc: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=qKE7TWyoGxDr+8pHmWsEJIClKHQdRsabnkAaiD6An8s=; b=lROGyj/yYS3qSxj01/0EaVNHmjgBUIviKoVPs2taiRhiUjnwLlRCvZdU9Zb9+NMbO9Qva9dkYkSDg2ukmMBgVNxApJ5ulAJVfyMlPVxDbX1GUW5FGZ2SwR/vKFwtYtu2lerHXy5ULILMmf1PsTsdsEIGM/AO9S6TFm2R+cw0w3w= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail 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 1615530058950916.4406444264496; Thu, 11 Mar 2021 22:20:58 -0800 (PST) Received: from localhost ([::1]:57210 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lKbAO-0005uO-Ao for importer@patchew.org; Fri, 12 Mar 2021 01:20:56 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:60482) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lKb6T-0000LD-UE for qemu-devel@nongnu.org; Fri, 12 Mar 2021 01:16:53 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:25590) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1lKb6S-0005nU-Ae for qemu-devel@nongnu.org; Fri, 12 Mar 2021 01:16:53 -0500 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-335-IGsKzhubPLmH5hSFrzp0ZA-1; Fri, 12 Mar 2021 01:16:50 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D9F421005E6C; Fri, 12 Mar 2021 06:16:48 +0000 (UTC) Received: from jason-ThinkPad-T430s.redhat.com (ovpn-12-126.pek2.redhat.com [10.72.12.126]) by smtp.corp.redhat.com (Postfix) with ESMTP id EAA4C101F501; Fri, 12 Mar 2021 06:16:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1615529811; 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=qKE7TWyoGxDr+8pHmWsEJIClKHQdRsabnkAaiD6An8s=; b=G3nPzjpMxDm3Riwq+Tl8ekYl5UxG7AIJhIdqvGKy+C8WnIeCcLYWpPgWr0utAMMjQmfK8E DqASWY/XI2ii4IycXqEA2onOhjDTrqASpfMenYcqUhyrKD25I6dpIl+LmhoDdbRSTtC6Ox RIQo/tFMCdH7OxCfW1hOY5ZR26BtCNg= X-MC-Unique: IGsKzhubPLmH5hSFrzp0ZA-1 From: Jason Wang To: peter.maydell@linaro.org Subject: [PULL 08/16] dp8393x: switch to use qemu_receive_packet() for loopback packet Date: Fri, 12 Mar 2021 14:16:18 +0800 Message-Id: <1615529786-30763-9-git-send-email-jasowang@redhat.com> In-Reply-To: <1615529786-30763-1-git-send-email-jasowang@redhat.com> References: <1615529786-30763-1-git-send-email-jasowang@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jasowang@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" 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=216.205.24.124; envelope-from=jasowang@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.25, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no 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: , Cc: Jason Wang , qemu-stable@nongnu.org, qemu-devel@nongnu.org, Prasad J Pandit Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) This patch switches to use qemu_receive_packet() which can detect reentrancy and return early. This is intended to address CVE-2021-3416. Cc: Prasad J Pandit Cc: qemu-stable@nongnu.org Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/net/dp8393x.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/net/dp8393x.c b/hw/net/dp8393x.c index 205c0de..533a830 100644 --- a/hw/net/dp8393x.c +++ b/hw/net/dp8393x.c @@ -506,7 +506,7 @@ static void dp8393x_do_transmit_packets(dp8393xState *s) s->regs[SONIC_TCR] |=3D SONIC_TCR_CRSL; if (nc->info->can_receive(nc)) { s->loopback_packet =3D 1; - nc->info->receive(nc, s->tx_buffer, tx_len); + qemu_receive_packet(nc, s->tx_buffer, tx_len); } } else { /* Transmit packet */ --=20 2.7.4 From nobody Sat May 18 22:54:08 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1615530460; cv=none; d=zohomail.com; s=zohoarc; b=haPYS7En8RJd2HdoAiC7FByj43cCGCIX2IfAGSpMEq92wKA4VwKSM9um24bn1CIMi6LTK9zvMyCSC0QEj/tDnEmES9Oq2+D6BbHJgRX2QSagJRF5t2qSLpIJCezentEPOhXWetjfX/ketBgHhZliucZbLKiThiTQslRTVe0SRXs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1615530460; h=Content-Type:Content-Transfer-Encoding:Cc: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=RyNIINoBz1Hi6Rbx/YwEruYvIrkhCW2bFy+35okkCBk=; b=NVxL3QXPq6YsJ07hLIba3ZOgz2cEmVHIQMolc/LR8xbTO1/jifPdx9g1IgOpcWgIpFxDt/YQkH8RrpgtYuWd9gxG3X6j1HuhzQ2BqPpfeI14lVT+hjG89LA2/RLgxbCVJhggTbXMmI0e+OeTlvqFVzBYAryKMLJBEf3xFWs1sVw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail 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 1615530460291397.72535008006105; Thu, 11 Mar 2021 22:27:40 -0800 (PST) Received: from localhost ([::1]:51108 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lKbGt-0006wr-8p for importer@patchew.org; Fri, 12 Mar 2021 01:27:39 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:60516) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lKb6X-0000TB-TH for qemu-devel@nongnu.org; Fri, 12 Mar 2021 01:16:58 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:50532) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1lKb6V-0005qK-39 for qemu-devel@nongnu.org; Fri, 12 Mar 2021 01:16:57 -0500 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-246-Y3ADGl_0OY2Bv25XCaGY-w-1; Fri, 12 Mar 2021 01:16:52 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 53C24107ACCD; Fri, 12 Mar 2021 06:16:51 +0000 (UTC) Received: from jason-ThinkPad-T430s.redhat.com (ovpn-12-126.pek2.redhat.com [10.72.12.126]) by smtp.corp.redhat.com (Postfix) with ESMTP id 65EC7101F501; Fri, 12 Mar 2021 06:16:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1615529814; 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=RyNIINoBz1Hi6Rbx/YwEruYvIrkhCW2bFy+35okkCBk=; b=Cgqq9WjPXXBrDyi7wzK+esjo3b2ZXQHWJW/NVUsuT5x4+dPeb0416C3LQ4Vgtb/4X4ZMf0 tTJhM52O7cFqOVlcE+evf5exBOWF6+kYDi6YctpuN6YhVlHdiieHf4jkb+sXvOgYda9XeW bKTJBbKM5bsSrlVmR5eyIZAWE538dRk= X-MC-Unique: Y3ADGl_0OY2Bv25XCaGY-w-1 From: Jason Wang To: peter.maydell@linaro.org Subject: [PULL 09/16] msf2-mac: switch to use qemu_receive_packet() for loopback Date: Fri, 12 Mar 2021 14:16:19 +0800 Message-Id: <1615529786-30763-10-git-send-email-jasowang@redhat.com> In-Reply-To: <1615529786-30763-1-git-send-email-jasowang@redhat.com> References: <1615529786-30763-1-git-send-email-jasowang@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jasowang@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" 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=63.128.21.124; envelope-from=jasowang@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.25, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no 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: , Cc: Jason Wang , qemu-stable@nongnu.org, qemu-devel@nongnu.org, Prasad J Pandit Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) This patch switches to use qemu_receive_packet() which can detect reentrancy and return early. This is intended to address CVE-2021-3416. Cc: Prasad J Pandit Cc: qemu-stable@nongnu.org Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Jason Wang --- hw/net/msf2-emac.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/net/msf2-emac.c b/hw/net/msf2-emac.c index 32ba9e8..3e62060 100644 --- a/hw/net/msf2-emac.c +++ b/hw/net/msf2-emac.c @@ -158,7 +158,7 @@ static void msf2_dma_tx(MSF2EmacState *s) * R_CFG1 bit 0 is set. */ if (s->regs[R_CFG1] & R_CFG1_LB_EN_MASK) { - nc->info->receive(nc, buf, size); + qemu_receive_packet(nc, buf, size); } else { qemu_send_packet(nc, buf, size); } --=20 2.7.4 From nobody Sat May 18 22:54:08 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1615530568; cv=none; d=zohomail.com; s=zohoarc; b=Lm8A3qk86NeHNK9bStA7OfMEzz9Jpa82KuTXHeM4bZ/ql5OuQ/Fy2BZj2nfNvygzf0SWVI9rCdxrwR8sWunfO3gujNwUYVwkwL0mAvst7P4FJBQ1mSgZGHPo4HNbFNn7ZP31nm3HHo9HKcEjG7c2RkNHRUwyP9E0TTAyKGchZxs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1615530568; h=Content-Type:Content-Transfer-Encoding:Cc: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=RdcJWZ6DHPuuQFJeMiOmCH7fjRe4vlISaTRE6TS3Riw=; b=mSfH0d3CKmSCj5r58jmrpLj9Wo2sdw38oqmWRdXTCkdFmGtjWXCKMoTXpbZn92eSsIrRvIQPRvaglPVUduB3SGMve1HLZbV4Wp2ZaxsnAVlDNwfYGCcgsQdqN0UO+1mRFuVK4nGx9eMpc/4NM8h/TAb9qF+CIHfLpMUa+fbkqi8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail 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 1615530568858192.09992040116015; Thu, 11 Mar 2021 22:29:28 -0800 (PST) Received: from localhost ([::1]:57556 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lKbId-0001Gs-RC for importer@patchew.org; Fri, 12 Mar 2021 01:29:27 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:60560) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lKb6a-0000WU-NT for qemu-devel@nongnu.org; Fri, 12 Mar 2021 01:17:01 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:25476) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1lKb6X-0005rk-Kq for qemu-devel@nongnu.org; Fri, 12 Mar 2021 01:17:00 -0500 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-504-QnewdyGmO9uLuLvCL90zWg-1; Fri, 12 Mar 2021 01:16:54 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C1B9D81744F; Fri, 12 Mar 2021 06:16:53 +0000 (UTC) Received: from jason-ThinkPad-T430s.redhat.com (ovpn-12-126.pek2.redhat.com [10.72.12.126]) by smtp.corp.redhat.com (Postfix) with ESMTP id D38AA101F501; Fri, 12 Mar 2021 06:16:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1615529816; 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=RdcJWZ6DHPuuQFJeMiOmCH7fjRe4vlISaTRE6TS3Riw=; b=frt1JI5OU6MF8G1skQE9fy1Oh1UxRYFkzXyLHzmzK71kYyd/r1ob1oANXbiWb73kznw3Gr +BxYMlnicaNzd5rUhHu64O7PaVDhZ45FtviCK3EhJkDvdnhcrKOqwflr9/F33e+SRVzwWS rOc7Nb7O+LnRu+fg1zckT8HZxiddQYg= X-MC-Unique: QnewdyGmO9uLuLvCL90zWg-1 From: Jason Wang To: peter.maydell@linaro.org Subject: [PULL 10/16] sungem: switch to use qemu_receive_packet() for loopback Date: Fri, 12 Mar 2021 14:16:20 +0800 Message-Id: <1615529786-30763-11-git-send-email-jasowang@redhat.com> In-Reply-To: <1615529786-30763-1-git-send-email-jasowang@redhat.com> References: <1615529786-30763-1-git-send-email-jasowang@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jasowang@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" 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=63.128.21.124; envelope-from=jasowang@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.25, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no 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: , Cc: Jason Wang , qemu-stable@nongnu.org, qemu-devel@nongnu.org, Prasad J Pandit Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) This patch switches to use qemu_receive_packet() which can detect reentrancy and return early. This is intended to address CVE-2021-3416. Cc: Prasad J Pandit Cc: qemu-stable@nongnu.org Reviewed-by: Mark Cave-Ayland Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Alistair Francis Signed-off-by: Jason Wang --- hw/net/sungem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/net/sungem.c b/hw/net/sungem.c index 33c3722..3684a4d 100644 --- a/hw/net/sungem.c +++ b/hw/net/sungem.c @@ -306,7 +306,7 @@ static void sungem_send_packet(SunGEMState *s, const ui= nt8_t *buf, NetClientState *nc =3D qemu_get_queue(s->nic); =20 if (s->macregs[MAC_XIFCFG >> 2] & MAC_XIFCFG_LBCK) { - nc->info->receive(nc, buf, size); + qemu_receive_packet(nc, buf, size); } else { qemu_send_packet(nc, buf, size); } --=20 2.7.4 From nobody Sat May 18 22:54:08 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1615530176; cv=none; d=zohomail.com; s=zohoarc; b=HGvfVmSZy0OdC/AT0rFHfX0kYJIoG60qMTM72FpWZoHb2pOq83JkC/4zMZowYSrxtD7WttaJIOGMa7sp1mnKgTprr9dxXpUfu/GZQh3fqIKV5+6cNutU4/VQNSGCA2MeAfYWiioCGevX45/zqEHaN77ZrrPxWXLjVCosn0ZTdbY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1615530176; h=Content-Type:Content-Transfer-Encoding:Cc: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=6bJKthAT4Mc9pCJJjfRZzZpHScIqv7jLZTPGXL8J8zk=; b=AaCZD4lP8uCSz5rZYHUqxS4/cyizQQ2/VAb4rq62en8inr8s7xChnAfUvBD7ywk7acXV2DU4XDm7DqxzNOzLrWhB+33I0y7J38+Ro7dgwlkelX4KZWPqcHho4OXpinB8FxT++dD4LwExhUtGszXH9cYrP1/kzNNDOUBIFIEwx00= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail 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 1615530176923805.3392080332037; Thu, 11 Mar 2021 22:22:56 -0800 (PST) Received: from localhost ([::1]:37154 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lKbCJ-0000xy-U9 for importer@patchew.org; Fri, 12 Mar 2021 01:22:55 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:60588) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lKb6d-0000YV-1Y for qemu-devel@nongnu.org; Fri, 12 Mar 2021 01:17:03 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:55390) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1lKb6a-0005tM-Cy for qemu-devel@nongnu.org; Fri, 12 Mar 2021 01:17:02 -0500 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-198-3hH4MNTMO-OHm7P8ocotVQ-1; Fri, 12 Mar 2021 01:16:57 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 40DE492505; Fri, 12 Mar 2021 06:16:56 +0000 (UTC) Received: from jason-ThinkPad-T430s.redhat.com (ovpn-12-126.pek2.redhat.com [10.72.12.126]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4D97B101F501; Fri, 12 Mar 2021 06:16:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1615529819; 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=6bJKthAT4Mc9pCJJjfRZzZpHScIqv7jLZTPGXL8J8zk=; b=EtSBhEQbd8vI9C243fuwifgUCcHXkfpJ21DvTYBRjakzZGXDH2P1ellPevN1cYdd/Ui/c2 MPhrCN59B0WyFEYSDXQMnmGFGVOdKsA6O+ZDpeC1n+YquH0b5ZBFKo6zc9InOoV1FUOsa3 EJBU7DhYTx+8/4pCpnEt/cDnfSv5jJ4= X-MC-Unique: 3hH4MNTMO-OHm7P8ocotVQ-1 From: Jason Wang To: peter.maydell@linaro.org Subject: [PULL 11/16] tx_pkt: switch to use qemu_receive_packet_iov() for loopback Date: Fri, 12 Mar 2021 14:16:21 +0800 Message-Id: <1615529786-30763-12-git-send-email-jasowang@redhat.com> In-Reply-To: <1615529786-30763-1-git-send-email-jasowang@redhat.com> References: <1615529786-30763-1-git-send-email-jasowang@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jasowang@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" 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=63.128.21.124; envelope-from=jasowang@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.25, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no 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: , Cc: Jason Wang , qemu-stable@nongnu.org, qemu-devel@nongnu.org, Prasad J Pandit Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) This patch switches to use qemu_receive_receive_iov() which can detect reentrancy and return early. This is intended to address CVE-2021-3416. Cc: Prasad J Pandit Cc: qemu-stable@nongnu.org Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Jason Wang --- hw/net/net_tx_pkt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/net/net_tx_pkt.c b/hw/net/net_tx_pkt.c index da262ed..1f9aa59 100644 --- a/hw/net/net_tx_pkt.c +++ b/hw/net/net_tx_pkt.c @@ -553,7 +553,7 @@ static inline void net_tx_pkt_sendv(struct NetTxPkt *pk= t, NetClientState *nc, const struct iovec *iov, int iov_cnt) { if (pkt->is_loopback) { - nc->info->receive_iov(nc, iov, iov_cnt); + qemu_receive_packet_iov(nc, iov, iov_cnt); } else { qemu_sendv_packet(nc, iov, iov_cnt); } --=20 2.7.4 From nobody Sat May 18 22:54:08 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1615530189; cv=none; d=zohomail.com; s=zohoarc; b=h/Vd1oPDlfd9V17WedKJsnq9sCEJfYzqvp7NXJZza5D5eyHxt1HAybc+aWGpcV3tjyjmekJOYOnP9QhLHiPCH4849DUot5ntJ1JOfZFlWQ68etqEBFBU4KMULgWyqADb1gaGdQsvTzI7+UtMPhz+xIiU/ZO4LbE+p3cgJq5NNnE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1615530189; h=Content-Type:Content-Transfer-Encoding:Cc: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=/ENnQUGZLLVogXHtCtzqE57XhBQnjWTcfqvtIxe9h40=; b=krDFyFmXQSdJoW1fKEAb+uhADVybrEeNEqVuJSAiMOWVKIdChCuX+3hbn2rKwJUMxmPeo+KwkZ2skAt3dk3RZk3T40//T/jptyxtNBaD8WXV7VTDgDer6uMcgT90pg4W0JsAWc4wdw7zqGfWClwxaCS6Y9d3uPntU2ULl9+Dwjc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail 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 1615530189867477.22946907667085; Thu, 11 Mar 2021 22:23:09 -0800 (PST) Received: from localhost ([::1]:38510 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lKbCW-0001WC-RG for importer@patchew.org; Fri, 12 Mar 2021 01:23:08 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:60618) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lKb6h-0000e7-KW for qemu-devel@nongnu.org; Fri, 12 Mar 2021 01:17:07 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:59029) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1lKb6f-0005xg-R8 for qemu-devel@nongnu.org; Fri, 12 Mar 2021 01:17:07 -0500 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-257-mutwWIaGPT2INO1PDjrgdQ-1; Fri, 12 Mar 2021 01:17:00 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 14CF418397A2; Fri, 12 Mar 2021 06:16:59 +0000 (UTC) Received: from jason-ThinkPad-T430s.redhat.com (ovpn-12-126.pek2.redhat.com [10.72.12.126]) by smtp.corp.redhat.com (Postfix) with ESMTP id C0B71101F501; Fri, 12 Mar 2021 06:16:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1615529825; 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=/ENnQUGZLLVogXHtCtzqE57XhBQnjWTcfqvtIxe9h40=; b=L/pUhsmjuUv2vhaUasXp1V7ITEal0AUxeYgFnDGNQ0gCAGUI5+wqGcbRP4VHr1E06dXU4A mtBhWhJ1Z0ceDnGCsNJ96kONgOxgmMa6gVObGyHrQewJN+elb+6ljwvy4F2SFkF6CXRY6l OPdYuxjnwCksShfQbl4vudnd1K2CrTo= X-MC-Unique: mutwWIaGPT2INO1PDjrgdQ-1 From: Jason Wang To: peter.maydell@linaro.org Subject: [PULL 12/16] rtl8139: switch to use qemu_receive_packet() for loopback Date: Fri, 12 Mar 2021 14:16:22 +0800 Message-Id: <1615529786-30763-13-git-send-email-jasowang@redhat.com> In-Reply-To: <1615529786-30763-1-git-send-email-jasowang@redhat.com> References: <1615529786-30763-1-git-send-email-jasowang@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jasowang@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" 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=216.205.24.124; envelope-from=jasowang@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.25, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no 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: , Cc: Jason Wang , Alexander Bulekov , qemu-stable@nongnu.org, qemu-devel@nongnu.org, Prasad J Pandit Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Alexander Bulekov This patch switches to use qemu_receive_packet() which can detect reentrancy and return early. This is intended to address CVE-2021-3416. Cc: Prasad J Pandit Cc: qemu-stable@nongnu.org Buglink: https://bugs.launchpad.net/qemu/+bug/1910826 Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Jason Wang --- hw/net/rtl8139.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/net/rtl8139.c b/hw/net/rtl8139.c index 4675ac8..90b4fc6 100644 --- a/hw/net/rtl8139.c +++ b/hw/net/rtl8139.c @@ -1795,7 +1795,7 @@ static void rtl8139_transfer_frame(RTL8139State *s, u= int8_t *buf, int size, } =20 DPRINTF("+++ transmit loopback mode\n"); - rtl8139_do_receive(qemu_get_queue(s->nic), buf, size, do_interrupt= ); + qemu_receive_packet(qemu_get_queue(s->nic), buf, size); =20 if (iov) { g_free(buf2); --=20 2.7.4 From nobody Sat May 18 22:54:08 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1615530332; cv=none; d=zohomail.com; s=zohoarc; b=FVDan6m5FSpZkj+vMxvQEki0JPTcs/pQyJ14uRiB7LuJBvrDxmev0oWxw5bJ9c3T7mjxr5bWRUAMhpOvs5TnI0RBPGA9hvVy08qDU9S0/5SfGkxXT+UtbCF1n8WML1xR+RB2u1vCDoI96hCZtIop5Tl/bjopd2BphthTmVICP1M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1615530332; h=Content-Type:Content-Transfer-Encoding:Cc: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=ew/5txxMQKVoLsaPrRnRTg8UBay6ZQd+g3eeE8dHLCA=; b=dKWKTImySTlSKRJeruD0sE8utuoZI9Bsjj68nbouTaZc+NcuoJg+FprETLqnd0zuwYj0v2HsIdGj3ty381BnVb75rPuvwQ8u0RC4JFbvYtixXsOvfWdepDc5+8hCXGCzSvWQNB61jTtlsuY5Ov7TtTQxHNfFJPZypVM4kgjJZ+g= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail 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 1615530332987678.055011672633; Thu, 11 Mar 2021 22:25:32 -0800 (PST) Received: from localhost ([::1]:44862 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lKbEp-0004Do-UV for importer@patchew.org; Fri, 12 Mar 2021 01:25:31 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:60648) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lKb6j-0000kD-Uk for qemu-devel@nongnu.org; Fri, 12 Mar 2021 01:17:09 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:37034) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1lKb6i-0005zg-Aj for qemu-devel@nongnu.org; Fri, 12 Mar 2021 01:17:09 -0500 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-195-I4iqBYYiOl-zbgnLdxsiFg-1; Fri, 12 Mar 2021 01:17:03 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C5F551005E6C; Fri, 12 Mar 2021 06:17:01 +0000 (UTC) Received: from jason-ThinkPad-T430s.redhat.com (ovpn-12-126.pek2.redhat.com [10.72.12.126]) by smtp.corp.redhat.com (Postfix) with ESMTP id 950A3101F501; Fri, 12 Mar 2021 06:16:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1615529827; 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=ew/5txxMQKVoLsaPrRnRTg8UBay6ZQd+g3eeE8dHLCA=; b=JDI3Awc7z6O/l9ZckfUl0WrY+nmPNeOAN2cED7+8dBLwzfan+73CfCBwoShRVX2HpRzhHM XKzr1FhqKZqDuRyzM2T3bzERkXw+B4A/ryHjR18XU2k6ZUOffdku8N7uG30iYeEg65qsTn RvM0iJzlKw8E4gEqjOS+7g0cL+KlprQ= X-MC-Unique: I4iqBYYiOl-zbgnLdxsiFg-1 From: Jason Wang To: peter.maydell@linaro.org Subject: [PULL 13/16] pcnet: switch to use qemu_receive_packet() for loopback Date: Fri, 12 Mar 2021 14:16:23 +0800 Message-Id: <1615529786-30763-14-git-send-email-jasowang@redhat.com> In-Reply-To: <1615529786-30763-1-git-send-email-jasowang@redhat.com> References: <1615529786-30763-1-git-send-email-jasowang@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jasowang@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" 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=216.205.24.124; envelope-from=jasowang@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.25, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no 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: , Cc: Jason Wang , Alexander Bulekov , qemu-stable@nongnu.org, qemu-devel@nongnu.org, Prasad J Pandit Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Alexander Bulekov This patch switches to use qemu_receive_packet() which can detect reentrancy and return early. This is intended to address CVE-2021-3416. Cc: Prasad J Pandit Cc: qemu-stable@nongnu.org Buglink: https://bugs.launchpad.net/qemu/+bug/1917085 Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Jason Wang --- hw/net/pcnet.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/net/pcnet.c b/hw/net/pcnet.c index f3f18d8..dcd3fc4 100644 --- a/hw/net/pcnet.c +++ b/hw/net/pcnet.c @@ -1250,7 +1250,7 @@ txagain: if (BCR_SWSTYLE(s) =3D=3D 1) add_crc =3D !GET_FIELD(tmd.status, TMDS, NOFCS); s->looptest =3D add_crc ? PCNET_LOOPTEST_CRC : PCNET_LOOPTEST_= NOCRC; - pcnet_receive(qemu_get_queue(s->nic), s->buffer, s->xmit_pos); + qemu_receive_packet(qemu_get_queue(s->nic), s->buffer, s->xmit= _pos); s->looptest =3D 0; } else { if (s->nic) { --=20 2.7.4 From nobody Sat May 18 22:54:08 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1615530693; cv=none; d=zohomail.com; s=zohoarc; b=ac0t/stdQQ61KHsBmVaErr9cBSDyHwBEm+t+1PpXp4UXn8DKDOH8qhSdGh0LBzULMEYGmBv7L1mDESggqWJMo0UFoXZ/rYqZHjgB7EqXeH9DjDP9F/SMvP2HiRhpRcOsqwOs26X/Dms5B3o6Ixt0CfpxyvUPP87O4KKvkbnuguQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1615530693; h=Content-Type:Content-Transfer-Encoding:Cc: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=bbGpWHYX8p5RfriyfsnYp7IJPRDfebqyZu6HAJFvgYA=; b=D0WN0GpfJFr9dEQ9i954hI7l0/yV7EcJDoR1Au40D8R7lAWYMmzpl3PNoqtyM1ukJtnmmqEi09XA0CXyeXUYLbXDZwfUxpmthsxO2lmG6fIIfTTOAB+KWmkpM4DRF8nSMXXuw4joez++X+D58DNKke28r7Dy8Eiap58ZKGxcRbM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail 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 1615530693963876.312952057205; Thu, 11 Mar 2021 22:31:33 -0800 (PST) Received: from localhost ([::1]:33734 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lKbKe-0003J0-P8 for importer@patchew.org; Fri, 12 Mar 2021 01:31:32 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:60672) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lKb6m-0000qA-HG for qemu-devel@nongnu.org; Fri, 12 Mar 2021 01:17:12 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:35437) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1lKb6l-000617-1R for qemu-devel@nongnu.org; Fri, 12 Mar 2021 01:17:12 -0500 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-487-ebnBkR2XO7SuU6apB7c-eg-1; Fri, 12 Mar 2021 01:17:05 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8189A92503; Fri, 12 Mar 2021 06:17:04 +0000 (UTC) Received: from jason-ThinkPad-T430s.redhat.com (ovpn-12-126.pek2.redhat.com [10.72.12.126]) by smtp.corp.redhat.com (Postfix) with ESMTP id 535D3101F501; Fri, 12 Mar 2021 06:17:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1615529830; 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=bbGpWHYX8p5RfriyfsnYp7IJPRDfebqyZu6HAJFvgYA=; b=S/K7Jf5GIRZDbqrlkuUdMBbTNcqzFYdytiTJhIAbBvuHPT4ofPoLVhB8p2IJfAY70AeCJD CpqoTrb60BNZp78x/dzaDBxzm0GQVQng/vLcEUa1KAtKt7bfxIpbp3VrQ8/VheIKYZgcoT 6k4s9k/Xf0OU5a6SK82KXHhE57YiHg8= X-MC-Unique: ebnBkR2XO7SuU6apB7c-eg-1 From: Jason Wang To: peter.maydell@linaro.org Subject: [PULL 14/16] cadence_gem: switch to use qemu_receive_packet() for loopback Date: Fri, 12 Mar 2021 14:16:24 +0800 Message-Id: <1615529786-30763-15-git-send-email-jasowang@redhat.com> In-Reply-To: <1615529786-30763-1-git-send-email-jasowang@redhat.com> References: <1615529786-30763-1-git-send-email-jasowang@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jasowang@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" 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=216.205.24.124; envelope-from=jasowang@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.25, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no 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: , Cc: Jason Wang , Alexander Bulekov , qemu-stable@nongnu.org, qemu-devel@nongnu.org, Prasad J Pandit Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Alexander Bulekov This patch switches to use qemu_receive_packet() which can detect reentrancy and return early. This is intended to address CVE-2021-3416. Cc: Prasad J Pandit Cc: qemu-stable@nongnu.org Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Alexander Bulekov Signed-off-by: Jason Wang --- hw/net/cadence_gem.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/net/cadence_gem.c b/hw/net/cadence_gem.c index 9a4474a..24b3a0f 100644 --- a/hw/net/cadence_gem.c +++ b/hw/net/cadence_gem.c @@ -1275,8 +1275,8 @@ static void gem_transmit(CadenceGEMState *s) /* Send the packet somewhere */ if (s->phy_loop || (s->regs[GEM_NWCTRL] & GEM_NWCTRL_LOCALLOOP)) { - gem_receive(qemu_get_queue(s->nic), s->tx_packet, - total_bytes); + qemu_receive_packet(qemu_get_queue(s->nic), s->tx_pack= et, + total_bytes); } else { qemu_send_packet(qemu_get_queue(s->nic), s->tx_packet, total_bytes); --=20 2.7.4 From nobody Sat May 18 22:54:08 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1615530120; cv=none; d=zohomail.com; s=zohoarc; b=AZuLfyiNo7B6TmVqOGd4jgMhxX3YHU/c9z2Mjbc3bGtqGsg0Vt4kNf/hJz0Sk5DizH7fHhPVuKNa5H78T9hfohDeFhNRHITC74jfEJGBwviBcrrzicjni/Ct0GbAgXna7MAukFWOIXZRnAyb7L2pxb5gQ7PMQhlD+2mbNj7wfVQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1615530120; h=Content-Type:Content-Transfer-Encoding:Cc: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=Da8utT56JvLvicbWmGO2VftTBd8X0cgM9z+/I38HVq4=; b=l1qtmWF/zswVbRrj25vxidLXdgwdF+UiWHCpjIslc01cd5/m5fJUa9znxMa6Qxbz7kuOIgZ+P/JVISyS5sCFuYl9ExC8X0UzC4m1j/AdAlprphzqNcUITRysE3PcYWSvEueFDPG52TiX5DTMUeUNrLoZdVyhPZyRLDpEInlCsSc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail 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 1615530120061314.0015475728418; Thu, 11 Mar 2021 22:22:00 -0800 (PST) Received: from localhost ([::1]:33244 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lKbBO-0007lh-W6 for importer@patchew.org; Fri, 12 Mar 2021 01:21:59 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:60758) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lKb6s-0000va-2D for qemu-devel@nongnu.org; Fri, 12 Mar 2021 01:17:18 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:44501) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1lKb6o-00062q-GA for qemu-devel@nongnu.org; Fri, 12 Mar 2021 01:17:17 -0500 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-332-hwim-jxnM96uJZ4sgF46Ng-1; Fri, 12 Mar 2021 01:17:08 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 582EE107ACCA; Fri, 12 Mar 2021 06:17:07 +0000 (UTC) Received: from jason-ThinkPad-T430s.redhat.com (ovpn-12-126.pek2.redhat.com [10.72.12.126]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0E8B2101F501; Fri, 12 Mar 2021 06:17:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1615529833; 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=Da8utT56JvLvicbWmGO2VftTBd8X0cgM9z+/I38HVq4=; b=L990vLkzC0sjupFs+2lpNPOw6O0m/D/E1TMV7EqpsSGcDYqvLdVPp+WAZ4eLObS46Ke6vq yMZatbXyineUfy1fi+OeDil+CIJo2BFgHzG2IMkaOlrmJmbnE37lMIRnscS1sZk0S43gE+ GxkCeaJHMfJrN8PZHto3+RNukKKlkFo= X-MC-Unique: hwim-jxnM96uJZ4sgF46Ng-1 From: Jason Wang To: peter.maydell@linaro.org Subject: [PULL 15/16] lan9118: switch to use qemu_receive_packet() for loopback Date: Fri, 12 Mar 2021 14:16:25 +0800 Message-Id: <1615529786-30763-16-git-send-email-jasowang@redhat.com> In-Reply-To: <1615529786-30763-1-git-send-email-jasowang@redhat.com> References: <1615529786-30763-1-git-send-email-jasowang@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jasowang@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" 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=63.128.21.124; envelope-from=jasowang@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.25, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no 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: , Cc: Jason Wang , Alexander Bulekov , qemu-stable@nongnu.org, qemu-devel@nongnu.org, Prasad J Pandit Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Alexander Bulekov This patch switches to use qemu_receive_packet() which can detect reentrancy and return early. This is intended to address CVE-2021-3416. Cc: Prasad J Pandit Cc: qemu-stable@nongnu.org Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Jason Wang --- hw/net/lan9118.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/net/lan9118.c b/hw/net/lan9118.c index abc7962..6aff424 100644 --- a/hw/net/lan9118.c +++ b/hw/net/lan9118.c @@ -680,7 +680,7 @@ static void do_tx_packet(lan9118_state *s) /* FIXME: Honor TX disable, and allow queueing of packets. */ if (s->phy_control & 0x4000) { /* This assumes the receive routine doesn't touch the VLANClient. = */ - lan9118_receive(qemu_get_queue(s->nic), s->txp->data, s->txp->len); + qemu_receive_packet(qemu_get_queue(s->nic), s->txp->data, s->txp->= len); } else { qemu_send_packet(qemu_get_queue(s->nic), s->txp->data, s->txp->len= ); } --=20 2.7.4 From nobody Sat May 18 22:54:08 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1615530788; cv=none; d=zohomail.com; s=zohoarc; b=c0ZVwtGyixWIPumTaVtzd51h8ic2CcrUG8Al54cLYXJVv4IYuUOJ/yqlqkpCAereLf7uct0Ue5GQ1YKEM1vc+Xg04fTLdvp8RUz40oklu4XBjkGO5xCQt8IH9U628lqYtgcMrwcveXmcIJtCLmRQGr2z1wQ6kva012iuhggxs8U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1615530788; h=Content-Type:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=jz7rXc9MSNcMN+9Z+ch6NrMClneZPv4Jj5Qe+VK/CQs=; b=QisGlDTZh0GhRpASYS0I4e0uveHtBdovwI0v3+Nfhu+9jq3kmQwcWpxNstbNyT8bExqviwI+hrZdGqJIGuu4ltwDuNttOzqwlVE+FpuNYx7CXHaEYLcHDXDZrwT0tMxsAY1rJ41ju64Py3tLIOSg3oL6H1VA5fJfdbgQPFJdBgM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail 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 1615530788053968.2781343514683; Thu, 11 Mar 2021 22:33:08 -0800 (PST) Received: from localhost ([::1]:36256 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lKbMA-0004Rv-UL for importer@patchew.org; Fri, 12 Mar 2021 01:33:06 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:60728) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lKb6r-0000vL-5e for qemu-devel@nongnu.org; Fri, 12 Mar 2021 01:17:18 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:57694) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1lKb6o-00063k-EH for qemu-devel@nongnu.org; Fri, 12 Mar 2021 01:17:16 -0500 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-390-BHAxRqZyPF6_6zE-h6pmxA-1; Fri, 12 Mar 2021 01:17:10 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 88C7B800D55; Fri, 12 Mar 2021 06:17:09 +0000 (UTC) Received: from jason-ThinkPad-T430s.redhat.com (ovpn-12-126.pek2.redhat.com [10.72.12.126]) by smtp.corp.redhat.com (Postfix) with ESMTP id D8BFD101F501; Fri, 12 Mar 2021 06:17:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1615529833; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:content-type:content-type:in-reply-to:in-reply-to: references:references; bh=jz7rXc9MSNcMN+9Z+ch6NrMClneZPv4Jj5Qe+VK/CQs=; b=N1pd59l2XEeOLiJmbIgtGjhPH/KaSZ1lbfFwVQLCeJqlS9Q08CzMIR3Xl9WgvBCASGa3JB zeTpHsCS9/y5TyDNv8SeCSBrZ96f5B1w446bs27LNpil19pS/wbk4212ysuPhlqyr2cLBw 89qnTd5qLyN8XNV2styoAiYYrAOexyI= X-MC-Unique: BHAxRqZyPF6_6zE-h6pmxA-1 From: Jason Wang To: peter.maydell@linaro.org Subject: [PULL 16/16] pvrdma: wean code off pvrdma_ring.h kernel header Date: Fri, 12 Mar 2021 14:16:26 +0800 Message-Id: <1615529786-30763-17-git-send-email-jasowang@redhat.com> In-Reply-To: <1615529786-30763-1-git-send-email-jasowang@redhat.com> References: <1615529786-30763-1-git-send-email-jasowang@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=jasowang@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com 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=63.128.21.124; envelope-from=jasowang@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -29 X-Spam_score: -3.0 X-Spam_bar: --- X-Spam_report: (-3.0 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.25, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no 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: , Cc: Jason Wang , Cornelia Huck , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Cornelia Huck The pvrdma code relies on the pvrdma_ring.h kernel header for some basic ring buffer handling. The content of that header isn't very exciting, but contains some (q)atomic_*() invocations that (a) cause manual massaging when doing a headers update, and (b) are an indication that we probably should not be importing that header at all. Let's reimplement the ring buffer handling directly in the pvrdma code instead. This arguably also improves readability of the code. Importing the header can now be dropped. Signed-off-by: Cornelia Huck Reviewed-by: Paolo Bonzini Reviewed-by: Yuval Shaia Tested-by: Yuval Shaia Signed-off-by: Jason Wang --- hw/rdma/vmw/pvrdma.h | 5 +- hw/rdma/vmw/pvrdma_cmd.c | 6 +- hw/rdma/vmw/pvrdma_dev_ring.c | 41 ++++---- hw/rdma/vmw/pvrdma_dev_ring.h | 9 +- hw/rdma/vmw/pvrdma_main.c | 4 +- .../drivers/infiniband/hw/vmw_pvrdma/pvrdma_ring.h | 114 -----------------= ---- scripts/update-linux-headers.sh | 3 +- 7 files changed, 38 insertions(+), 144 deletions(-) delete mode 100644 include/standard-headers/drivers/infiniband/hw/vmw_pvrd= ma/pvrdma_ring.h diff --git a/hw/rdma/vmw/pvrdma.h b/hw/rdma/vmw/pvrdma.h index 1d36a76..d08965d 100644 --- a/hw/rdma/vmw/pvrdma.h +++ b/hw/rdma/vmw/pvrdma.h @@ -26,7 +26,6 @@ #include "../rdma_backend_defs.h" #include "../rdma_rm_defs.h" =20 -#include "standard-headers/drivers/infiniband/hw/vmw_pvrdma/pvrdma_ring.h" #include "standard-headers/drivers/infiniband/hw/vmw_pvrdma/pvrdma_dev_api= .h" #include "pvrdma_dev_ring.h" #include "qom/object.h" @@ -64,10 +63,10 @@ typedef struct DSRInfo { union pvrdma_cmd_req *req; union pvrdma_cmd_resp *rsp; =20 - struct pvrdma_ring *async_ring_state; + PvrdmaRingState *async_ring_state; PvrdmaRing async; =20 - struct pvrdma_ring *cq_ring_state; + PvrdmaRingState *cq_ring_state; PvrdmaRing cq; } DSRInfo; =20 diff --git a/hw/rdma/vmw/pvrdma_cmd.c b/hw/rdma/vmw/pvrdma_cmd.c index 692125a..f59879e 100644 --- a/hw/rdma/vmw/pvrdma_cmd.c +++ b/hw/rdma/vmw/pvrdma_cmd.c @@ -262,7 +262,7 @@ static int create_cq_ring(PCIDevice *pci_dev , PvrdmaRi= ng **ring, r =3D g_malloc(sizeof(*r)); *ring =3D r; =20 - r->ring_state =3D (struct pvrdma_ring *) + r->ring_state =3D (PvrdmaRingState *) rdma_pci_dma_map(pci_dev, tbl[0], TARGET_PAGE_SIZE); =20 if (!r->ring_state) { @@ -398,7 +398,7 @@ static int create_qp_rings(PCIDevice *pci_dev, uint64_t= pdir_dma, *rings =3D sr; =20 /* Create send ring */ - sr->ring_state =3D (struct pvrdma_ring *) + sr->ring_state =3D (PvrdmaRingState *) rdma_pci_dma_map(pci_dev, tbl[0], TARGET_PAGE_SIZE); if (!sr->ring_state) { rdma_error_report("Failed to map to QP ring state"); @@ -639,7 +639,7 @@ static int create_srq_ring(PCIDevice *pci_dev, PvrdmaRi= ng **ring, r =3D g_malloc(sizeof(*r)); *ring =3D r; =20 - r->ring_state =3D (struct pvrdma_ring *) + r->ring_state =3D (PvrdmaRingState *) rdma_pci_dma_map(pci_dev, tbl[0], TARGET_PAGE_SIZE); if (!r->ring_state) { rdma_error_report("Failed to map tp SRQ ring state"); diff --git a/hw/rdma/vmw/pvrdma_dev_ring.c b/hw/rdma/vmw/pvrdma_dev_ring.c index f0bcde7..074ac59 100644 --- a/hw/rdma/vmw/pvrdma_dev_ring.c +++ b/hw/rdma/vmw/pvrdma_dev_ring.c @@ -22,11 +22,10 @@ #include "trace.h" =20 #include "../rdma_utils.h" -#include "standard-headers/drivers/infiniband/hw/vmw_pvrdma/pvrdma_ring.h" #include "pvrdma_dev_ring.h" =20 int pvrdma_ring_init(PvrdmaRing *ring, const char *name, PCIDevice *dev, - struct pvrdma_ring *ring_state, uint32_t max_elems, + PvrdmaRingState *ring_state, uint32_t max_elems, size_t elem_sz, dma_addr_t *tbl, uint32_t npages) { int i; @@ -73,48 +72,54 @@ out: =20 void *pvrdma_ring_next_elem_read(PvrdmaRing *ring) { - int e; - unsigned int idx =3D 0, offset; + unsigned int idx, offset; + const uint32_t tail =3D qatomic_read(&ring->ring_state->prod_tail); + const uint32_t head =3D qatomic_read(&ring->ring_state->cons_head); =20 - e =3D pvrdma_idx_ring_has_data(ring->ring_state, ring->max_elems, &idx= ); - if (e <=3D 0) { + if (tail & ~((ring->max_elems << 1) - 1) || + head & ~((ring->max_elems << 1) - 1) || + tail =3D=3D head) { trace_pvrdma_ring_next_elem_read_no_data(ring->name); return NULL; } =20 + idx =3D head & (ring->max_elems - 1); offset =3D idx * ring->elem_sz; return ring->pages[offset / TARGET_PAGE_SIZE] + (offset % TARGET_PAGE_= SIZE); } =20 void pvrdma_ring_read_inc(PvrdmaRing *ring) { - pvrdma_idx_ring_inc(&ring->ring_state->cons_head, ring->max_elems); + uint32_t idx =3D qatomic_read(&ring->ring_state->cons_head); + + idx =3D (idx + 1) & ((ring->max_elems << 1) - 1); + qatomic_set(&ring->ring_state->cons_head, idx); } =20 void *pvrdma_ring_next_elem_write(PvrdmaRing *ring) { - int idx; - unsigned int offset, tail; + unsigned int idx, offset; + const uint32_t tail =3D qatomic_read(&ring->ring_state->prod_tail); + const uint32_t head =3D qatomic_read(&ring->ring_state->cons_head); =20 - idx =3D pvrdma_idx_ring_has_space(ring->ring_state, ring->max_elems, &= tail); - if (idx <=3D 0) { + if (tail & ~((ring->max_elems << 1) - 1) || + head & ~((ring->max_elems << 1) - 1) || + tail =3D=3D (head ^ ring->max_elems)) { rdma_error_report("CQ is full"); return NULL; } =20 - idx =3D pvrdma_idx(&ring->ring_state->prod_tail, ring->max_elems); - if (idx < 0 || tail !=3D idx) { - rdma_error_report("Invalid idx %d", idx); - return NULL; - } - + idx =3D tail & (ring->max_elems - 1); offset =3D idx * ring->elem_sz; return ring->pages[offset / TARGET_PAGE_SIZE] + (offset % TARGET_PAGE_= SIZE); } =20 void pvrdma_ring_write_inc(PvrdmaRing *ring) { - pvrdma_idx_ring_inc(&ring->ring_state->prod_tail, ring->max_elems); + uint32_t idx =3D qatomic_read(&ring->ring_state->prod_tail); + + idx =3D (idx + 1) & ((ring->max_elems << 1) - 1); + qatomic_set(&ring->ring_state->prod_tail, idx); } =20 void pvrdma_ring_free(PvrdmaRing *ring) diff --git a/hw/rdma/vmw/pvrdma_dev_ring.h b/hw/rdma/vmw/pvrdma_dev_ring.h index 5f2a0cf..d231588 100644 --- a/hw/rdma/vmw/pvrdma_dev_ring.h +++ b/hw/rdma/vmw/pvrdma_dev_ring.h @@ -19,18 +19,23 @@ =20 #define MAX_RING_NAME_SZ 32 =20 +typedef struct PvrdmaRingState { + int prod_tail; /* producer tail */ + int cons_head; /* consumer head */ +} PvrdmaRingState; + typedef struct PvrdmaRing { char name[MAX_RING_NAME_SZ]; PCIDevice *dev; uint32_t max_elems; size_t elem_sz; - struct pvrdma_ring *ring_state; /* used only for unmap */ + PvrdmaRingState *ring_state; /* used only for unmap */ int npages; void **pages; } PvrdmaRing; =20 int pvrdma_ring_init(PvrdmaRing *ring, const char *name, PCIDevice *dev, - struct pvrdma_ring *ring_state, uint32_t max_elems, + PvrdmaRingState *ring_state, uint32_t max_elems, size_t elem_sz, dma_addr_t *tbl, uint32_t npages); void *pvrdma_ring_next_elem_read(PvrdmaRing *ring); void pvrdma_ring_read_inc(PvrdmaRing *ring); diff --git a/hw/rdma/vmw/pvrdma_main.c b/hw/rdma/vmw/pvrdma_main.c index 8593570..84ae802 100644 --- a/hw/rdma/vmw/pvrdma_main.c +++ b/hw/rdma/vmw/pvrdma_main.c @@ -85,7 +85,7 @@ static void free_dev_ring(PCIDevice *pci_dev, PvrdmaRing = *ring, rdma_pci_dma_unmap(pci_dev, ring_state, TARGET_PAGE_SIZE); } =20 -static int init_dev_ring(PvrdmaRing *ring, struct pvrdma_ring **ring_state, +static int init_dev_ring(PvrdmaRing *ring, PvrdmaRingState **ring_state, const char *name, PCIDevice *pci_dev, dma_addr_t dir_addr, uint32_t num_pages) { @@ -114,7 +114,7 @@ static int init_dev_ring(PvrdmaRing *ring, struct pvrdm= a_ring **ring_state, /* RX ring is the second */ (*ring_state)++; rc =3D pvrdma_ring_init(ring, name, pci_dev, - (struct pvrdma_ring *)*ring_state, + (PvrdmaRingState *)*ring_state, (num_pages - 1) * TARGET_PAGE_SIZE / sizeof(struct pvrdma_cqne), sizeof(struct pvrdma_cqne), diff --git a/include/standard-headers/drivers/infiniband/hw/vmw_pvrdma/pvrd= ma_ring.h b/include/standard-headers/drivers/infiniband/hw/vmw_pvrdma/pvrdm= a_ring.h deleted file mode 100644 index 7b4062a..0000000 --- a/include/standard-headers/drivers/infiniband/hw/vmw_pvrdma/pvrdma_ring= .h +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright (c) 2012-2016 VMware, Inc. All rights reserved. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of EITHER the GNU General Public License - * version 2 as published by the Free Software Foundation or the BSD - * 2-Clause License. This program is distributed in the hope that it - * will be useful, but WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * See the GNU General Public License version 2 for more details at - * http://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html. - * - * You should have received a copy of the GNU General Public License - * along with this program available in the file COPYING in the main - * directory of this source tree. - * - * The BSD 2-Clause License - * - * Redistribution and use in source and binary forms, with or - * without modification, are permitted provided that the following - * conditions are met: - * - * - Redistributions of source code must retain the above - * copyright notice, this list of conditions and the following - * disclaimer. - * - * - Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials - * provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED - * OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef __PVRDMA_RING_H__ -#define __PVRDMA_RING_H__ - -#include "standard-headers/linux/types.h" - -#define PVRDMA_INVALID_IDX -1 /* Invalid index. */ - -struct pvrdma_ring { - int prod_tail; /* Producer tail. */ - int cons_head; /* Consumer head. */ -}; - -struct pvrdma_ring_state { - struct pvrdma_ring tx; /* Tx ring. */ - struct pvrdma_ring rx; /* Rx ring. */ -}; - -static inline int pvrdma_idx_valid(uint32_t idx, uint32_t max_elems) -{ - /* Generates fewer instructions than a less-than. */ - return (idx & ~((max_elems << 1) - 1)) =3D=3D 0; -} - -static inline int32_t pvrdma_idx(int *var, uint32_t max_elems) -{ - const unsigned int idx =3D qatomic_read(var); - - if (pvrdma_idx_valid(idx, max_elems)) - return idx & (max_elems - 1); - return PVRDMA_INVALID_IDX; -} - -static inline void pvrdma_idx_ring_inc(int *var, uint32_t max_elems) -{ - uint32_t idx =3D qatomic_read(var) + 1; /* Increment. */ - - idx &=3D (max_elems << 1) - 1; /* Modulo size, flip gen. */ - qatomic_set(var, idx); -} - -static inline int32_t pvrdma_idx_ring_has_space(const struct pvrdma_ring *= r, - uint32_t max_elems, uint32_t *out_tail) -{ - const uint32_t tail =3D qatomic_read(&r->prod_tail); - const uint32_t head =3D qatomic_read(&r->cons_head); - - if (pvrdma_idx_valid(tail, max_elems) && - pvrdma_idx_valid(head, max_elems)) { - *out_tail =3D tail & (max_elems - 1); - return tail !=3D (head ^ max_elems); - } - return PVRDMA_INVALID_IDX; -} - -static inline int32_t pvrdma_idx_ring_has_data(const struct pvrdma_ring *r, - uint32_t max_elems, uint32_t *out_head) -{ - const uint32_t tail =3D qatomic_read(&r->prod_tail); - const uint32_t head =3D qatomic_read(&r->cons_head); - - if (pvrdma_idx_valid(tail, max_elems) && - pvrdma_idx_valid(head, max_elems)) { - *out_head =3D head & (max_elems - 1); - return tail !=3D head; - } - return PVRDMA_INVALID_IDX; -} - -#endif /* __PVRDMA_RING_H__ */ diff --git a/scripts/update-linux-headers.sh b/scripts/update-linux-headers= .sh index fa6f2b6..1050e36 100755 --- a/scripts/update-linux-headers.sh +++ b/scripts/update-linux-headers.sh @@ -215,8 +215,7 @@ sed -e '1h;2,$H;$!d;g' -e 's/[^};]*pvrdma[^(| ]*([^)]= *);//g' \ "$linux/drivers/infiniband/hw/vmw_pvrdma/pvrdma_verbs.h" > \ "$tmp_pvrdma_verbs"; =20 -for i in "$linux/drivers/infiniband/hw/vmw_pvrdma/pvrdma_ring.h" \ - "$linux/drivers/infiniband/hw/vmw_pvrdma/pvrdma_dev_api.h" \ +for i in "$linux/drivers/infiniband/hw/vmw_pvrdma/pvrdma_dev_api.h" \ "$tmp_pvrdma_verbs"; do \ cp_portable "$i" \ "$output/include/standard-headers/drivers/infiniband/hw/vmw_pvrdm= a/" --=20 2.7.4