From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 176FFC433FE for ; Sun, 20 Mar 2022 11:43:27 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id D4F0C839A8; Sun, 20 Mar 2022 12:43:24 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.b="O6Xhjknr"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 8A5A283ADC; Sun, 20 Mar 2022 12:41:50 +0100 (CET) Received: from mail-wm1-x34a.google.com (mail-wm1-x34a.google.com [IPv6:2a00:1450:4864:20::34a]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 06112838F0 for ; Sun, 20 Mar 2022 12:41:47 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=3-xI3YgYKBhYwEyG772AA270.yA8G-xAAF74EFE.z09J.z0@flex--ascull.bounces.google.com Received: by mail-wm1-x34a.google.com with SMTP id i127-20020a1c3b85000000b0038c9c48f1e7so1159820wma.2 for ; Sun, 20 Mar 2022 04:41:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:message-id:mime-version:subject:from:to:cc; bh=lMZh/9PTiTEMvCT9bqpO514W+346+wJ0/2xzDeOu/W8=; b=O6XhjknrrENvAE0OxTYflvVQgrK4jcoDx42RRptpkZCcMXdV9m04jYPq3gLFE7anJU v8Q6DF70TrI4ffv238YpXQo4ViE1vu2ZpWV6hDJWBbNa+aOjoAlYN6zTAk9ViTp0beDy S6+0VYb1yiJgWVcOEQ+dsUVkolB726F11XKq4FF3hg62bxdvY/s5Yr4RhVxhm8bt3OAJ 4MFUt31IzCtnUPRrovB4uwnA///9QKBdgglBxlcAeSICrYw1plwWdAljQcMvP18xhGQP xE1L30h1JiLCawXFejmz3HLqJB88SAqPwgT+fII0G3OvVSIeH9tTMVD5gG3kB/lEViDB hjkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=lMZh/9PTiTEMvCT9bqpO514W+346+wJ0/2xzDeOu/W8=; b=vNAWjo61ZrHDQXEeMjm68e0hWeAZt6Yk0zqgCjTrAQmUCRjJmbt1GJqhiTqLs9WXIl cfqBzhk78UtQcnUsMrznKe5qnl7zb0P+knV6eBhscU+iFNxw+7Hhne7eMOyqFpDOFiMw pyIr2rtQr3sX66NEi7ee5p3wJ+A5c4F/AtFEp8ssakkw+0SZsv19eHZVa+VLnuX/+DSt vJUyakqOGPMgfNzprA1GC6imKxvjZdVrw07tHzIhMkKN65dnYVQaVT1JsY/ypQjgDK+Q 9Q09atj4vYWNlY1gPWIneu9XLwMKRjR00RaoVkRfmtovNYTmOXUZLC5lf6EQv/AB9aVC 3Lww== X-Gm-Message-State: AOAM532UcBICuvWfuCWaUHJv98/Bv+5fcg2JF7i2bF5nj+2UmZ/zOPWr y6SHvNGFox3VdYf79uXiYOBsyNlaEO+3EHuo+IMGN3QDjsxHXHLZZZgkFb0cYKHjkJdrH4QjkLa wUiCFaXYfXjicPRcHswAclqt4QeG5ouY/2qfCMiStUxXXoKGraOhSO18/Voo= X-Google-Smtp-Source: ABdhPJwtgAnGse2CQkb7OEtprcjbf2VBUst6PCU7pbgTt9JO54oSdyH/Fn9Zp/xtIApDju2pDh6VfQtQqdk= X-Received: from ascull.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:1510]) (user=ascull job=sendgmr) by 2002:a5d:6d8f:0:b0:204:101e:753f with SMTP id l15-20020a5d6d8f000000b00204101e753fmr918283wrs.707.1647776507403; Sun, 20 Mar 2022 04:41:47 -0700 (PDT) Date: Sun, 20 Mar 2022 11:41:07 +0000 Message-Id: <20220320114118.2237795-1-ascull@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.35.1.894.gb6a874cedc-goog Subject: [PATCH 00/11] virtio: pci: Add and fix consistency checks From: Andrew Scull To: u-boot@lists.denx.de Cc: sjg@chromium.org, bmeng.cn@gmail.com, adelva@google.com, keirf@google.com, ptosi@google.com, Andrew Scull Content-Type: text/plain; charset="UTF-8" X-Mailman-Approved-At: Sun, 20 Mar 2022 12:43:23 +0100 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.5 at phobos.denx.de X-Virus-Status: Clean The virtio PCI drivers forgo a number of consistency checks, particularly around pointer validation and bounds checking. This series focuses on the modern driver to add those checks. The start of the series adds and fixes some basic bounds checks. Later patches ensure PCI addresses fall within the expected regions rather than any arbitrary address. The series applies atop v2022.04-rc4. I have been boot testing on the AOSP cuttlefish virtualized device and protected KVM as part of the Android Virtualization Framework (AVF). Andrew Scull (11): virtio: pci: Fix discovery of device config length virtio: pci: Bounds check device config access virtio: pci: Bounds check notification writes virtio: pci: Check virtio common config size virtio: pci: Check virtio capability is in bounds virtio: pci: Read entire capability into memory virtio: pci: Check virtio configs are mapped pci: Check region ranges are addressable pci: Add function to validate PCI address range virtio: pci: Check mapped range is in a PCI region virtio: pci: Allow exclusion of legacy driver drivers/pci/pci-uclass.c | 47 ++++++++- drivers/virtio/Kconfig | 9 ++ drivers/virtio/Makefile | 3 +- drivers/virtio/virtio_pci_modern.c | 147 ++++++++++++++++++++++------- include/pci.h | 16 ++++ 5 files changed, 184 insertions(+), 38 deletions(-) -- 2.35.1.894.gb6a874cedc-goog