From patchwork Thu Apr 4 19:13:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 785824 Delivered-To: patch@linaro.org Received: by 2002:adf:f001:0:b0:33e:7753:30bd with SMTP id j1csp995097wro; Thu, 4 Apr 2024 12:14:36 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUA0jBSur8l/vgWLxErlgc5ZESbz991u1/8F/v7LX/4zWQhE4Dhhy2DXMS/RnPcJPZgMwzc7CFCMmZrx+ED4sX9 X-Google-Smtp-Source: AGHT+IFkSwch8aUsSkRLMDS8If9AlPayQNcGpqLUzbns6QMWqdZQWWm30/LvX7mqfXUg4emwt1Ol X-Received: by 2002:a05:622a:1820:b0:431:5e0b:e5e1 with SMTP id t32-20020a05622a182000b004315e0be5e1mr919579qtc.4.1712258076418; Thu, 04 Apr 2024 12:14:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1712258076; cv=none; d=google.com; s=arc-20160816; b=vhXFkBqCnKVies0n0RK5xoJu2FwfO+KpZWP8aNzr5m3HKATrPhfVEsurxe2NRp84lC k0b68cOxl+vC4LPeyDfWAAZrNjmBC3mxbnwD0pRn7H4RhUjjej0+OIKJ5VU1ZnULdO3H JnaOGO8CvbbAdnZycSs6QqkFSfMaEGtZmG89hOR6MnlHRcVBclqpzTZerW3egUmLz+y+ HN6LeQK/Ax867JlIz728OfUmyoYN/ViYvDTQ6+Fc4CiUdr0HJGAT2qDG3aQj1acf6Kz4 8AniGMt/pE8/qywWhJSti21BBwO2l58wk4JFC1829BooA/Wlz6pL3OBq9k68MTyYNu9j 1fUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature; bh=8WchDuPu1BDvGE3LRF7qlJXcb6p6bszd96Mxn2SBD+U=; fh=IgWjBQE846jA7jrnvhZ0hLzTyLYirmOOtnItXRlZ4Ow=; b=kI3uOjCtHlUpI+cJciFySb5yFl63+Y77ivh0wzW16SLu8+1sEq/K+2su6G+LV/MjvB /HKSNhd42Di1KmEn0BntCQAYVQrQoJinjChUMV9eDrzXVZV1B0wRviSUGTeDS28Z/UPm ET9e57ckN9iGlxjpnZaxEdkgQbQWamjhTz0kJmG5ubDIJfMRf5oWWfqRpvjIb9XKl7ZS vcd1KBnK5lJdxQ4b/Nd5hIP+OIUVoB+TboU66sCKzQbQ7qhdogd/r8UZiJfkxTcUMN2k RfrAYrFLgTmDgql8e+9ROn9vVOmS4pACmHqX1QiGqNA0OkxdSfSSAuL05YvdWZLSzXlj 72wA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YmdncP4t; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id g11-20020ac85d4b000000b004343e82dd51si5674455qtx.135.2024.04.04.12.14.36 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 04 Apr 2024 12:14:36 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YmdncP4t; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rsSX6-00061C-3S; Thu, 04 Apr 2024 15:13:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rsSX2-00060w-E6 for qemu-devel@nongnu.org; Thu, 04 Apr 2024 15:13:52 -0400 Received: from mail-ed1-x531.google.com ([2a00:1450:4864:20::531]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rsSWv-0005Uh-4h for qemu-devel@nongnu.org; Thu, 04 Apr 2024 15:13:51 -0400 Received: by mail-ed1-x531.google.com with SMTP id 4fb4d7f45d1cf-565c6cf4819so4417040a12.1 for ; Thu, 04 Apr 2024 12:13:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712258022; x=1712862822; darn=nongnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=8WchDuPu1BDvGE3LRF7qlJXcb6p6bszd96Mxn2SBD+U=; b=YmdncP4tiGr7nd6EZ/xksBZ2+Cy7vMexpNnH+CQuDkT9s/mQKlaaisgI1xhYBUT3tH rQpoY3m5OUB9evom0U8vcjHJLVRK7Gz8iz2T5upQxboO5OttYRB6OW97NYqnSA5KB2KM lYDKjhdEHnTK/nydq6optPk3PaXjOEPyzSqRrSP8Hno573A0nEoYjQEbOXJbCX/Qzzl7 eolmCFe21f9ZbSa6t/A8XDe9Q4br8e9au6Xem4j+MzyLf2dJVhhSSeLe9Tu2nxCAaHHD 8SvcJp+3dhy4lfVOw/+34a39a+nQjSKxrKGJfeuW5sxVguhs4Qezg9EPraJ8LokFb6jo W85Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712258022; x=1712862822; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=8WchDuPu1BDvGE3LRF7qlJXcb6p6bszd96Mxn2SBD+U=; b=tVQNToj35srGbtbZRvcfaV48jHUcCFmkP9T7FJW5s1w58iyQe5k8+beVb/Z3dELPci CvU2JRLuO4Jjhc2XGowu6FjtkjdXcTy/AjLijMgotW8/9YP6UH/xS5wKiDS0iBvR0L1B W17x5qfv0FnK5uWRuh/4JL6HnJ4ABYeqIzPzF3gabCy+IEq8EizYhBLkQaH/ng9+tB3X +qZaAuQ95HNyh+/kus9KCw5paF/g6SAE0dU84xQ6hFWuuBs4TjYOI9LuX/gAtU1VUHZm 4oPMHcWnC4O4VRWahQQ3BdZGrPVw4T47EaECaWJF4/kRfJc7uXnCCVuC4NP5pmAxUn6k 5cxQ== X-Gm-Message-State: AOJu0YwLvsa2LXi5wYvMszuWIfsMUKAZQrJ7GVS9tBZlj5urWAM15Ard tdUsoRN2U4hi6/dK8xCP8FeVVaV42qrJv4AuYBPW9Tzzm3chxlJ+0KauiAq1tCHY+H+gHc0Qq+d g X-Received: by 2002:a17:906:fccc:b0:a4d:f8d7:8546 with SMTP id qx12-20020a170906fccc00b00a4df8d78546mr317940ejb.7.1712258022459; Thu, 04 Apr 2024 12:13:42 -0700 (PDT) Received: from m1x-phil.lan ([176.187.216.111]) by smtp.gmail.com with ESMTPSA id x11-20020a170906710b00b00a51973509afsm463533ejj.91.2024.04.04.12.13.40 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 04 Apr 2024 12:13:41 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Gerd Hoffmann , Amit Shah , "Michael S. Tsirkin" , Alexander Bulekov , "Gonglei (Arei)" , =?utf-8?q?Marc-Andr=C3=A9_Lurea?= =?utf-8?q?u?= , Laurent Vivier , Mauro Matteo Cascella , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH-for-9.0 0/4] hw/virtio: Protect from more DMA re-entrancy bugs Date: Thu, 4 Apr 2024 21:13:35 +0200 Message-ID: <20240404191339.5688-1-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::531; envelope-from=philmd@linaro.org; helo=mail-ed1-x531.google.com X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Gerd suggested to use the transport guard to protect the device from DMA re-entrancy abuses. Philippe Mathieu-Daudé (4): hw/virtio: Introduce virtio_bh_new_guarded() helper hw/display/virtio-gpu: Protect from DMA re-entrancy bugs hw/char/virtio-serial-bus: Protect from DMA re-entrancy bugs hw/virtio/virtio-crypto: Protect from DMA re-entrancy bugs include/hw/virtio/virtio.h | 7 +++++++ hw/char/virtio-serial-bus.c | 3 +-- hw/display/virtio-gpu.c | 6 ++---- hw/virtio/virtio-crypto.c | 4 ++-- hw/virtio/virtio.c | 10 ++++++++++ 5 files changed, 22 insertions(+), 8 deletions(-) Reviewed-by: Gerd Hoffmann