From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 1F9F7A0519 for ; Wed, 24 Jun 2020 22:01:42 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id AFFC71DA0D; Wed, 24 Jun 2020 22:01:41 +0200 (CEST) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by dpdk.org (Postfix) with ESMTP id 18DB21DA0D for ; Wed, 24 Jun 2020 22:01:40 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1593028899; 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: in-reply-to:in-reply-to:references:references; bh=beN6CX8nwU7ztGagA9kvLxTa3bftdfAuqaRPb9RlyCE=; b=jA5Qu/1ebgbJjpl0zMLRsjCqwLM5VpunLkbi/wb9F59wjpEcWANna3ncvJA3aMwxMh6te8 Mr0asWnWyk4NgAMcgqs55aznjX8wfN4giBfH+0+NxNPL0yoeCJaxdERg8cegnebVvVW+iS j9x8ot+2+W4OhvCvdLMXHuGhM/6oe/E= Received: from mail-vs1-f71.google.com (mail-vs1-f71.google.com [209.85.217.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-218-wsRvVx93NBmXxcF1YLU2fQ-1; Wed, 24 Jun 2020 16:01:37 -0400 X-MC-Unique: wsRvVx93NBmXxcF1YLU2fQ-1 Received: by mail-vs1-f71.google.com with SMTP id l19so1488669vsp.1 for ; Wed, 24 Jun 2020 13:01:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=beN6CX8nwU7ztGagA9kvLxTa3bftdfAuqaRPb9RlyCE=; b=OeN76ho3qpTRemd+0ifToUH5OYj1uMI199npWqJCgvNWFID+ykesp6fNM1wOuXGvZE llBCLpVPhThb5AnV9bT2YmoGjxzvn9DK+BEfeit3qV42yhNSWT5rQcE084LgCK988guy o1/AleERLrtjIs5ral/0Om3J2yj9y+q4FjtklrhK49U5w0EMyFyC4yxsgIygJFFpwG75 yw5tgqZnC90mJr0MPndLi5WDY5gAJPT1q2094xXiDUIfcAncaLwXKgky9x6nWwCjoDu2 qe1syimUX2h0rmqWBu3b7XxlvDmkz87taCc/sE/bQJOH0grD9aG5SJuHIaYV9P07GHon VNRw== X-Gm-Message-State: AOAM533IV2GUnAB+fG1+X82Ye1Bk6t1D0hQrqyfUR1/nhI9e3wQXVcq3 B064+FRH7/5dHcjHsvL03rGYfTIsUIG3UgavswhNg6ha5CwqzHKg68NDOGWBd9h+iyjxY2SWTUO suGPAKrH/CGcqlD+xdmB56Hs= X-Received: by 2002:a9f:3fc8:: with SMTP id m8mr7113631uaj.53.1593028897314; Wed, 24 Jun 2020 13:01:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJztWr1qVuA5cIMcpFJOY4BLEBhkhP30QzyRUpCmghjGH8+ZYAM6hZHJN/TIqUXOob3jdf+1bnCHzRpXiEkbbnM= X-Received: by 2002:a9f:3fc8:: with SMTP id m8mr7113523uaj.53.1593028896099; Wed, 24 Jun 2020 13:01:36 -0700 (PDT) MIME-Version: 1.0 References: <20200621174035.6858-1-haiyue.wang@intel.com> <20200622111351.101006-1-haiyue.wang@intel.com> In-Reply-To: <20200622111351.101006-1-haiyue.wang@intel.com> From: David Marchand Date: Wed, 24 Jun 2020 22:01:25 +0200 Message-ID: To: Haiyue Wang Cc: dev , "Burakov, Anatoly" , dpdk stable , Maxime Coquelin X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Subject: Re: [dpdk-stable] [dpdk-dev] [PATCH v3] bus/pci: fix VF bus error for memory access X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" On Mon, Jun 22, 2020 at 1:23 PM Haiyue Wang wrote: > > To fix CVE-2020-12888, the linux vfio-pci module will invalidate mmaps > and block MMIO access on disabled memory, it will send a SIGBUS to the > application: > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=abafbc551fddede3e0a08dee1dcde08fc0eb8476 > > When the application opens the vfio PCI device, the vfio-pci module will > enable the bus memory space through PCI read/write access. According to > the PCIe specification, the 'Memory Space Enable' is always zero for VF: > > Table 9-13 Command Register Changes > > Bit Location | PF and VF Register Differences | PF | VF > | From Base | Attributes | Attributes > -------------+--------------------------------+------------+----------- > | Memory Space Enable - Does not | | > | apply to VFs. Must be hardwired| Base | 0b > 1 | to 0b for VFs. VF Memory Space | | > | is controlled by the VF MSE bit| | > | in the VF Control register. | | > -------------+--------------------------------+------------+----------- > > Afterwards the vfio-pci will initialize its own virtual PCI config space > data ('vconfig') by reading the VF's physical PCI config space, then the > 'Memory Space Enable' bit in vconfig will always be 0b value. This will > make the vfio-pci treat the BAR memory space as disabled, and the SIGBUS > will be triggerred if access these BARs. triggered > > By investigation, the VF PCI device *passthrough* into the Guest OS by > QEMU has the 'Memory Space Enable' with 1b value. That's because every > PCI driver will start to enable the memory space, and this action will > be hooked by vfio-pci virtual PCI read/write to set the 'Memory Space > Enable' in vconfig space to 1b. So VF runs in guest OS has 'Mem+', but > VF runs in host OS has 'Mem-'. > > Align with PCI working mode in Guest/QEMU/Host, in DPDK, enable the PCI > bus memory space explicitly to avoid access on disabled memory. > > Fixes: 33604c31354a ("vfio: refactor PCI BAR mapping") > Cc: stable@dpdk.org > > Signed-off-by: Haiyue Wang Ouch, we just hit it. Thanks for fixing! Tested-by: David Marchand -- David Marchand