From nobody Sun May 5 06:58:35 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1648979756; cv=none; d=zohomail.com; s=zohoarc; b=QwJ5pz9eCYZUZmjGq6CwWtohIzhuLBoBdVczFRNzaHIsOao9zTchLyuTaurKLLVTVlfp37q3dJBxIq3UiIXC/txfabSJgvnX4iYmTYzzn96xjdAEV+qp6uVZGZBKoaA8AaGzx8ECgJH1FhyBS2MCNWC2Tgt2qUrvu480VrN5kwk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1648979756; h=Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=x0uqxdLPrjHgY49PDES4xM7M8hh2w1B9x+ITezH2sqU=; b=eqnN7fYBsjo6r3h7J0bf2qmjxZ2J9ICN8Mm21xI4slrXa40geGATmv1xRpq9kPmAZCDcQTxGxhmewOPR1V8uYrPDKAlowO7s64ySKchQa7Y2S4Qml/zBT4Bh1RanOXFNwcYpfHkN0EVtkIz/tjDexLczwCw+oytCYNGUPcgaLZA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1648979756448404.1315763513212; Sun, 3 Apr 2022 02:55:56 -0700 (PDT) Received: from localhost ([::1]:39928 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nawxe-00088R-FI for importer2@patchew.org; Sun, 03 Apr 2022 05:55:54 -0400 Received: from eggs.gnu.org ([209.51.188.92]:38696) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nawwV-0007S3-TW for qemu-devel@nongnu.org; Sun, 03 Apr 2022 05:54:44 -0400 Received: from [2a00:1450:4864:20::536] (port=45907 helo=mail-ed1-x536.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nawwU-0000vs-C9 for qemu-devel@nongnu.org; Sun, 03 Apr 2022 05:54:43 -0400 Received: by mail-ed1-x536.google.com with SMTP id u28so1416086eda.12 for ; Sun, 03 Apr 2022 02:54:41 -0700 (PDT) Received: from localhost.localdomain ([5.29.20.198]) by smtp.gmail.com with ESMTPSA id c13-20020a17090654cd00b006e0db351d01sm3068631ejp.124.2022.04.03.02.54.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Apr 2022 02:54:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=x0uqxdLPrjHgY49PDES4xM7M8hh2w1B9x+ITezH2sqU=; b=QHwWorLGhAf+efhtxu3f1g4wS6Jc/r8i1YSYbTxTXJZ1lzSQT2TMrDDPdFX2sH+aV4 ZnlYbXaHaqOr9B4561Xrmz2pRWvgPB0e2Nec5xGVt+gUELoQJCc4jUCHV8m7MEC6AXKv wq9yjGGHf+WKFREpZk0gAuGo+1UvH3n03ZjUiasbzvIU0XKfefqpzBZv79KZM6cbwkw7 DD+ziw/zSvOgssxVzYmB4VbYnMsNZpXweeVip0ddTLlUO9lPEl3idJ4ihov2gytXeZGE OLorcyRYfN6tGYq56oYgFgPAr1MJ1BnWW6Ekc9ivaEcbTMBDILPuAiPfd4Ur+mnHRyO/ JOLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=x0uqxdLPrjHgY49PDES4xM7M8hh2w1B9x+ITezH2sqU=; b=jAdLwyTqw9HRsjLdFrx6k9HAMjPHu95bLSdiCmG6qHi3FexvW5/ulI1NOEqv/9d4+h AsbKM0EytKe8QsUgvwAjDarCM6wNn+ssW/Ldki3+sF3OgGzjXD6YbaNknmUuoRZ7tS3x BXbnFSPQUgMwudKwbe4TztRlgfylPmTCRUALaT5QLuaSiTS7j4kzRCg996SDoOZiMF+I mbu5DLbNPcQHBO1RsrFs9Ef8qA3wFPlYlWMACCy9SLrddCVR6jgcNghLH2fV5wpe+3MR cQhyV3xDqNWZjP7FE/qxPvomhTPEYGrXiEWVNJv8zH70SUQqx44azKMxtCDWcBdzlxnR wf9Q== X-Gm-Message-State: AOAM532LDqPe09uQUNMKq2ox2yKegB/UqVdjpTYhiJK86zv6KoRLYMeK Om9JtVJiUY2vI9QKRMqhjHefxk2XQbI= X-Google-Smtp-Source: ABdhPJy5CRXZwA8LwMzXEhtQWwGA1//5f0ECizR8kdepyLIeulV0WQa9ikUDV2oXFBfYbeoYx3udCg== X-Received: by 2002:a05:6402:909:b0:415:cdbf:4748 with SMTP id g9-20020a056402090900b00415cdbf4748mr28033184edz.395.1648979679083; Sun, 03 Apr 2022 02:54:39 -0700 (PDT) From: Yuval Shaia To: qemu-devel@nongnu.org, yuval.shaia.ml@gmail.com, marcel.apfelbaum@gmail.com, mcascell@redhat.com, wxhusst@gmail.com Subject: [PATCH v3] hw/pvrdma: Protect against buggy or malicious guest driver Date: Sun, 3 Apr 2022 12:52:34 +0300 Message-Id: <20220403095234.2210-1-yuval.shaia.ml@gmail.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Host-Lookup-Failed: Reverse DNS lookup failed for 2a00:1450:4864:20::536 (failed) 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::536; envelope-from=yuval.shaia.ml@gmail.com; helo=mail-ed1-x536.google.com X-Spam_score_int: 23 X-Spam_score: 2.3 X-Spam_bar: ++ X-Spam_report: (2.3 / 5.0 requ) AC_FROM_MANY_DOTS=2.996, BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, PDS_HP_HELO_NORDNS=0.659, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1648979759776100001 Content-Type: text/plain; charset="utf-8" Guest driver might execute HW commands when shared buffers are not yet allocated. This could happen on purpose (malicious guest) or because of some other guest/host address mapping error. We need to protect againts such case. Fixes: CVE-2022-1050 Reported-by: Raven Signed-off-by: Yuval Shaia --- v1 -> v2: * Commit message changes v2 -> v3: * Exclude cosmetic changes --- hw/rdma/vmw/pvrdma_cmd.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/hw/rdma/vmw/pvrdma_cmd.c b/hw/rdma/vmw/pvrdma_cmd.c index da7ddfa548..89db963c46 100644 --- a/hw/rdma/vmw/pvrdma_cmd.c +++ b/hw/rdma/vmw/pvrdma_cmd.c @@ -796,6 +796,12 @@ int pvrdma_exec_cmd(PVRDMADev *dev) =20 dsr_info =3D &dev->dsr_info; =20 + if (!dsr_info->dsr) { + /* Buggy or malicious guest driver */ + rdma_error_report("Exec command without dsr, req or rsp buffer= s"); + goto out; + } + if (dsr_info->req->hdr.cmd >=3D sizeof(cmd_handlers) / sizeof(struct cmd_handler)) { rdma_error_report("Unsupported command"); --=20 2.20.1