From nobody Mon Feb 9 14:50:46 2026 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1692371505; cv=none; d=zohomail.com; s=zohoarc; b=WvebN6kWifGOqkBW78nB3Ox5xV4TcFJiZ9XGxBqypCjitdo5rqZz5eTtiEh1M+gAdPhYIgruYGmAPIkf6A5Pzj72ZCz9/VoIxUJikyOlVD0n2+p4HHw3oaMq32VWmdvyHn+2w7fADzW1hYw3iBZujLICB8nG6WU8DnH4kMpVf1I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1692371505; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=zkt8qeBW+o4jPjnQtmwyry6dtMA1gn9lr1yNsAxm/7I=; b=ab6ZUymZgTjqealuDNHtnKrWgUAGcpgm7uJaW3shUAOmOmWA2utladPSnFGUq6JD6hO+xYv9FkCxLnI8HEu47FRfORQLPXd3iH5jP9GX+HUJ+gJebeE8If7Y/IcBq7aogSOqQBf5fG65VLh9dpUlt4ruUt5lhD65jdq73bs30Gg= 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+importer=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 1692371505155697.436244011617; Fri, 18 Aug 2023 08:11:45 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qX180-0006D6-JK; Fri, 18 Aug 2023 11:11:11 -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 1qX17w-0006Cj-CO for qemu-devel@nongnu.org; Fri, 18 Aug 2023 11:11:04 -0400 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qX17u-0007Yv-3C for qemu-devel@nongnu.org; Fri, 18 Aug 2023 11:11:04 -0400 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-3fe2ba3e260so10045375e9.2 for ; Fri, 18 Aug 2023 08:11:00 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id a26-20020a5d457a000000b00316eb7770b8sm3097631wrc.5.2023.08.18.08.10.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Aug 2023 08:10:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1692371459; x=1692976259; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=zkt8qeBW+o4jPjnQtmwyry6dtMA1gn9lr1yNsAxm/7I=; b=dBO3ez6iXfKSZWQ9wwStyk0pXwuQHhLJpRoDydIsRRXRLNiipDgtZ9u/kcCOv6mL25 M6ziks3ZBJAd/8dIhUA0XDQAihq0LJxDYqKz76lX6+BxVB5VmcpI0pyGC4kcS5uQ50vA sM8K/c2ZFm0uP+8EpFuvVAcg11dRklvNSwtm673WVmC+UqaAyMPs7+1BCi19KzWJ3XIA y9j6l3RH0zGNGhP6w6n6DgoJupJia+6SxTxGksv5DxswgbbI3st9FLIoM49J7PMGRpUv AvHkBZfo4mjm3lzM9LVcLPa5ifl2oFa8XYtlxmc1XJCI0K6hmmvan7GVJ2Z5zdCVsXne F3/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692371459; x=1692976259; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zkt8qeBW+o4jPjnQtmwyry6dtMA1gn9lr1yNsAxm/7I=; b=OjtOzXvHwZy/HWIKFLOWNBOkPYpR+/ufqKKBW4lQQCyfih5NGbJ4+JxwTlfUwalC7d BcRY7mMWnKdplAQ7g3It7YtIrT/H1tRVp2tQXRAe7mzO4V31xfEOFRcx4r7x9GDERRMM oiWsDH8vl5PhfUEGJee64pHF7lW/HFYLkSQ4vkdxom80UT9cpK9LHrvmcoCpvX5heMDA 85cLLTXt/6VButfM9c37E9LBapNN8J4iIygqaKeQ9UaafYHhM5RkDRyFpL4Xo/b10a5G NhAXlxXm6hGUgfh9cn9Ht32rREN92okmvkkwSw57WNx1zX0apes3qSmZmhAZC2v6EW0C AeTA== X-Gm-Message-State: AOJu0YxeJ6Go1BYJk9qAfmE1l9z0XYKEMtyhhs7BaUvAixapWiuPFf0J ckNYv9SKqrRdLm+5iSJtYDTvruVY6QJdXeol/Rg= X-Google-Smtp-Source: AGHT+IGvAmojPG58h09GVWaC11785t7b8un9f4G1FDITviLgCZnMtKKSOXAoS9Jcnax/kEyUdyADJw== X-Received: by 2002:a05:600c:365a:b0:3fb:b008:2003 with SMTP id y26-20020a05600c365a00b003fbb0082003mr2369243wmq.38.1692371459453; Fri, 18 Aug 2023 08:10:59 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Cc: Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH 1/3] ui/spice-display: Avoid dynamic stack allocation Date: Fri, 18 Aug 2023 16:10:55 +0100 Message-Id: <20230818151057.1541189-2-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230818151057.1541189-1-peter.maydell@linaro.org> References: <20230818151057.1541189-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::335; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x335.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1692371506523100003 Content-Type: text/plain; charset="utf-8" Use an autofree heap allocation instead of a variable-length array on the stack in qemu_spice_create_update(). The codebase has very few VLAs, and if we can get rid of them all we can make the compiler error on new additions. This is a defensive measure against security bugs where an on-stack dynamic allocation isn't correctly size-checked (e.g. CVE-2021-3527). Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- I was a little unsure about this allocation given that it's in the display_refresh callback, but the code already does a g_malloc() every time it calls qemu_spice_create_one_update() so one more presumably won't hurt. --- ui/spice-display.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ui/spice-display.c b/ui/spice-display.c index 3f3f8013d86..0e2fbfb17c1 100644 --- a/ui/spice-display.c +++ b/ui/spice-display.c @@ -189,7 +189,7 @@ static void qemu_spice_create_update(SimpleSpiceDisplay= *ssd) { static const int blksize =3D 32; int blocks =3D DIV_ROUND_UP(surface_width(ssd->ds), blksize); - int dirty_top[blocks]; + g_autofree int *dirty_top =3D NULL; int y, yoff1, yoff2, x, xoff, blk, bw; int bpp =3D surface_bytes_per_pixel(ssd->ds); uint8_t *guest, *mirror; @@ -198,6 +198,7 @@ static void qemu_spice_create_update(SimpleSpiceDisplay= *ssd) return; }; =20 + dirty_top =3D g_new(int, blocks); for (blk =3D 0; blk < blocks; blk++) { dirty_top[blk] =3D -1; } --=20 2.34.1