From patchwork Mon Nov 28 20:27:36 2022 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: 629007 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp3245014pvb; Mon, 28 Nov 2022 12:29:27 -0800 (PST) X-Google-Smtp-Source: AA0mqf4QTCySEmtXW/ltPcFjoNr7IPxWjb3gYAIbahR3QMOvAJ1ke5hsDOn/bujqNFiQojWy55RX X-Received: by 2002:ac8:6896:0:b0:3a5:6aa1:7cd6 with SMTP id m22-20020ac86896000000b003a56aa17cd6mr32713996qtq.146.1669667367591; Mon, 28 Nov 2022 12:29:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669667367; cv=none; d=google.com; s=arc-20160816; b=VZZu3V7LzB/oMeaWNKXhQR33vBLTpDkW98EuFm0nG9LybpiML7aa/xhtH6eRWytSKu RNkMDATV9ckij3hBlJsCXIaF5AmRAYicIH9c9nM0kEkF5l8GaQYWK3IeLq0jUnN8Dxgs 0S9Iwi4vm5bvPFPxJe3lDCNiQRM1F8V7Y2EMYDS2JzpszX1KKyGMjywvy7NCUAgmG/Fj 8M2MIAK1ce8Kt9HUSSL/+cq+8kuuyu92OZrPeAHWyTVqbRT2BjYThwBSGeZLQFmyvXYO IfMPiS7pkFygKsHiUzsojsgZplWrLakV0tRA4tnTTog90Gaewpl9pDdtOmyiUatC+3aw 4+jQ== 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=JOnbDGyVf5k/5lf6GMSnay/oOBUuU7F9b/x1tgkaw5Y=; b=pXqNym9LNYAeau2w4NHMGCzh6iMlp+jAUD4XhpuAbdrUosNOLKS7C92+/noqyIKjp2 LQhpT8qylSmQJ3JC/J142zd9jKdJANXZVQ3cDoIySAYSCfjrze9xwTAVVbXC6kaXDIcX Vulf04D4TuOP39DqKpDAsfDnnyaPRmur+X4h3pHmzSlLEaJJvnjqN0Ptg2PuPYBuBA3e LpvYsd51C6PaCzHM05BprTtfFcJJhKdaX1RjK7fy5YYtR6UXFGaFbMAoev65yWErlaUm 3RiVQ3BeV+i1QgCDNWKjYZSSPigyaTaTJ+QTz905Qd91gPkKtbFvuzpiVUjvnLwWP4GZ aV0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=yI4l9qYa; 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 i7-20020ad45c67000000b004c7053e52c8si1569988qvh.274.2022.11.28.12.29.27 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 28 Nov 2022 12:29:27 -0800 (PST) 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=yI4l9qYa; 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 1ozkjI-0002hl-0K; Mon, 28 Nov 2022 15:27:52 -0500 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 1ozkjE-0002e9-Aj for qemu-devel@nongnu.org; Mon, 28 Nov 2022 15:27:49 -0500 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ozkjC-00027J-GH for qemu-devel@nongnu.org; Mon, 28 Nov 2022 15:27:47 -0500 Received: by mail-wm1-x333.google.com with SMTP id t1so9386156wmi.4 for ; Mon, 28 Nov 2022 12:27:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=JOnbDGyVf5k/5lf6GMSnay/oOBUuU7F9b/x1tgkaw5Y=; b=yI4l9qYaztYlWqV8Ulkhzm8NkUlyq40m/hBv1oFCz/urIGz4I8ut5rTFo1JjjBXZv+ RR+9T+a1NohFX6TE3h95UucnoNPhpsxEF1jSfYyVF07GnUJgHoP8D4s3gttxBpVL7FCy yiBG93Hymm7twKVTd/KOKfFUxq/s8vQj35Sp/8E5tuZefNe+IwR0uL9lpPXq2o4qIx/g 6dpb0lSuFzVuO/gqNj/LUe5J5m9vC+36RLqHPNPT/8voLOuwNnnMc69SIZnHuyMmMNPJ +/Rwt6y5SaaweDg4g00Q5gWP4SDsAy4U3UaMqbzMg0SZsRXZC0NikPGr+TEhRwotTMgk 5wIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=JOnbDGyVf5k/5lf6GMSnay/oOBUuU7F9b/x1tgkaw5Y=; b=1JGHcKhPzZM6oSm+EoxiaVKJl7wpmMEMARYHwKEitLNxHaS3HChTkQVVqqIVyKKjLt Ywf/FPSuJYW1JJmw0IrP94RGvHjCR35qC44OQ62ayCyfQBVYk52y/lxDHFN2DUYVLnIJ FF2ZtQxv84sCi0UctbFEjsGep08f5Si6km3ef09g0UBIKlCVe9qGx3E0XlM4fqX+e9ai K5Ibf04XDphOhiVsbML0M8cmZll97I+v5HcviCZMpike0FHbMStN/bP3YbCOEnD3etDh l2/JfFoHmourq7VVkPDJOVtqXFXiQoaNR+ProJ2rqcsYbR31G0gUZkcjEKLBmy+JMynC 5LOA== X-Gm-Message-State: ANoB5pmztbaAt0KflG6TF0gwGpvgj6gBrztNoWslkGOXLvskSRjiLK5T uhQOCq9z+w7DXYdO3D4e9ITA27R+pf/j3w== X-Received: by 2002:a1c:7219:0:b0:3cf:77b7:61e6 with SMTP id n25-20020a1c7219000000b003cf77b761e6mr27827386wmc.162.1669667264083; Mon, 28 Nov 2022 12:27:44 -0800 (PST) Received: from localhost.localdomain ([185.126.107.38]) by smtp.gmail.com with ESMTPSA id u10-20020a05600c19ca00b003c5571c27a1sm20764242wmq.32.2022.11.28.12.27.42 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 28 Nov 2022 12:27:43 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, =?utf-8?q?Marc-Andr=C3=A9_Lureau?= Cc: Alexander Bulekov , Paolo Bonzini , Gerd Hoffmann , Peter Maydell , Mauro Matteo Cascella , =?utf-8?q?Philippe_Mathieu-Dau?= =?utf-8?q?d=C3=A9?= Subject: [RFC PATCH-for-7.2 v3 0/5] hw/display/qxl: Avoid buffer overrun in qxl_phys2virt() Date: Mon, 28 Nov 2022 21:27:36 +0100 Message-Id: <20221128202741.4945-1-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::333; envelope-from=philmd@linaro.org; helo=mail-wm1-x333.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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.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 Since v2: - Do not abort checking guest-provided addresses (Stefan) - Handle chunked QEMUCursor (Gerd) Since v1: - Moved overrun check in qxl_get_check_slot_offset (Marc-André) memory_region_get_ram_ptr() returns a host pointer for a MemoryRegion. Sometimes we do offset calculation using this pointer without checking the underlying MemoryRegion size. Wenxu Yin reported a buffer overrun in QXL. This series aims to fix it. I haven't audited the other _get_ram_ptr() uses (yet). Eventually we could rename it _get_ram_ptr_unsafe and add a safer helper which checks for overrun. Worth considering for 7.2? Regards, Phil. Philippe Mathieu-Daudé (5): hw/display/qxl: Have qxl_log_command Return early if no log_cmd handler hw/display/qxl: Document qxl_phys2virt() hw/display/qxl: Pass requested buffer size to qxl_phys2virt() hw/display/qxl: Avoid buffer overrun in qxl_phys2virt (CVE-2022-4144) hw/display/qxl: Assert memory slot fits in preallocated MemoryRegion hw/display/qxl-logger.c | 22 ++++++++++++++++++--- hw/display/qxl-render.c | 20 ++++++++++++++++---- hw/display/qxl.c | 42 ++++++++++++++++++++++++++++++++--------- hw/display/qxl.h | 23 +++++++++++++++++++++- 4 files changed, 90 insertions(+), 17 deletions(-)