From nobody Mon Sep 28 06:36:10 2026 Received: from m16.mail.163.com (m16.mail.163.com [117.135.210.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 580C63D16FB for ; Tue, 25 Aug 2026 10:42:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=117.135.210.5 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787654557; cv=none; b=Zqd88LVQ2Q06sabEUr4buQGI0NA3bB3/60WwrVZMvgbJkJzk6VQf/6KDWd48RrdCqoxRUyW358BQ65XFsJqXAw0i7JFRgjc8fUCJo4vAUzYRJfl3a/K6RnZH8MzJyK1OeksYbGog6EFWkYBJL95kafRJZeHQiakYXxjGLZbhaMM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787654557; c=relaxed/simple; bh=sRSXDDCHBzomfflTujvsaF3/p7zxpOo+IhqmR1ZatoA=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=m+mTkiK1fNjI5yD6ZKN1ai04C/jOlmwgZYB3YvZ5gYzh00NSOEHXZxTdP+9ocLsfqzu/HWgrSfO322Hr8H+uYHo3tTk1+gL3LrKc9KFaxdzumQC1sUeGtXoKTDxtxNwvBB0T9qJzhTU/hePdGWI3DTFoxN1PCaheTgDgQ11irB8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com; spf=pass smtp.mailfrom=163.com; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b=B+49dXoZ; arc=none smtp.client-ip=117.135.210.5 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=163.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b="B+49dXoZ" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:To:Subject:Date:Message-Id:MIME-Version; bh=I1 TBnbTaCrr7gDqaEBZkpcfpor59mesoJ+2EzuuW1EM=; b=B+49dXoZhRHnV4gZiU /QT3s4R9cFAkbeTKJe2Ah/gX4LuGvbXbDqE94kJ4Meh1WyG3Z/MFsvqTUGXwXwjy CDl3ZH8yQIwsp1MFkdbc3yzGXgC3lc+iwJNKs6lg9O3Qxhf5nFr3X8GFjaSHRjA+ a2thb1sKzu2r3mUOO/kvxqAlQ= Received: from localhost.localdomain (unknown []) by gzga-smtp-mtada-g1-3 (Coremail) with SMTP id _____wD3NzNgcY1qb+sxPg--.53870S2; Tue, 25 Aug 2026 18:41:37 +0800 (CST) From: oushixiong1025@163.com To: Thomas Zimmermann Cc: Javier Martinez Canillas , Maarten Lankhorst , Maxime Ripard , David Airlie , Simona Vetter , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Shixiong Ou Subject: [PATCH] drm/sysfb: ofdrm: Fix integer overflow in fb_size calculation Date: Tue, 25 Aug 2026 18:41:34 +0800 Message-Id: <20260825104134.669676-1-oushixiong1025@163.com> X-Mailer: git-send-email 2.25.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: _____wD3NzNgcY1qb+sxPg--.53870S2 X-Coremail-Antispam: 1Uf129KBjvJXoW7WFyUWr1kZr1xXF15ZFyfCrg_yoW8XFWDpF ZrCay8Jrs5Gr4Syryjk3ZFyF45Za9YqFWfKFW29398u3s5K34qvFnYkryYy34DArZrCay3 ZFn8Jry8CFWDurJanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07jnwIDUUUUU= X-CM-SenderInfo: xrxvxxx0lr0wirqskqqrwthudrp/xtbC-QFygWqNcWFFHgAA3j Content-Type: text/plain; charset="utf-8" From: Shixiong Ou The framebuffer size calculation `fb_size =3D linebytes * height` can overflow when both values are large (e.g., 46341 * 46341 > INT_MAX). Since linebytes and height are both int types, the multiplication is performed as int * int, which results in undefined behavior on overflow. Use check_mul_overflow() to detect and prevent this overflow, consistent with the approach used in simpledrm.c and corebootdrm.c. Signed-off-by: Shixiong Ou Reviewed-by: Thomas Zimmermann --- drivers/gpu/drm/sysfb/ofdrm.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/sysfb/ofdrm.c b/drivers/gpu/drm/sysfb/ofdrm.c index 819aed466727..a6dc34b9ec0f 100644 --- a/drivers/gpu/drm/sysfb/ofdrm.c +++ b/drivers/gpu/drm/sysfb/ofdrm.c @@ -2,6 +2,7 @@ =20 #include #include +#include #include #include #include @@ -913,7 +914,10 @@ static struct ofdrm_device *ofdrm_device_create(struct= drm_driver *drv, return ERR_PTR(-EINVAL); } =20 - fb_size =3D linebytes * height; + if (check_mul_overflow(linebytes, height, &fb_size)) { + drm_err(dev, "framebuffer size exceeds maximum\n"); + return ERR_PTR(-EINVAL); + } =20 /* * Try to figure out the address of the framebuffer. Unfortunately, Open --=20 2.25.1 No virus found Checked by Hillstone Network AntiVirus