From nobody Fri Jul 24 21:53:57 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 5AEB041F353 for ; Fri, 24 Jul 2026 09:41:57 +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=1784886124; cv=none; b=b8RBbV/1IYaB0OlZZDFY8Y81Hg0s70FBVf0MFgYoiuq/fd9/XBYZkJzsICQSu7o5IZyEbXXxdDtLoXlUV43ErqXz9qdRKaI8qw/Sb33wLiGXslt0hzAiWvXBQ33SpforW69f2YsISVyngSHeTw7iFAdqQJoyVV/WLaY0qs0oiJY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784886124; c=relaxed/simple; bh=/KvO13/unw/Rk9kbDSG4Qtlz1/IT/6J6TZGctsNV4Xg=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=btR7ZDwmpIBxyGVSKoAvOM4TsUsF9cCIwxhdoQVNopHx2BCJEtD89E/Wrm93+MSAkrp7MBVDr32bj2X1pkUKXilG5UhferZCMPzUFnOJ/nD4CPAyr8zPfDSdHCkbMQYCV61Gz4ECyeuWgC8FTCxJ/pSx9E9P9fos1CaeuQKsEAA= 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=F6M6+64M; 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="F6M6+64M" 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=aC V0xcJhF9sainFF+i2yQuRfM8YBoageDdVMIyXtWA4=; b=F6M6+64Mj2oBLcJQkk 7tlxOsfB0aNlN8+CyvKAAfFF4ol1802fi8P6VglQXEfiCytozn5yAWgdB8mcnncA d+168YellCd6CElFJdYsVE9bfjcr7dq/V3Tv+JBng8Zi2AhqLwgvLV4GyyJZEGFj seZMgqgSxxxwfdHMZjIDJJuTQ= Received: from localhost.localdomain (unknown []) by gzga-smtp-mtada-g1-4 (Coremail) with SMTP id _____wAXQBk2M2Nq0GDcLg--.53080S2; Fri, 24 Jul 2026 17:41:10 +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.or, linux-kernel@vger.kernel.org, Shixiong Ou Subject: [PATCH] drm/sysfb: ofdrm: Fix integer overflow in fb_size calculation Date: Fri, 24 Jul 2026 17:41:08 +0800 Message-Id: <20260724094108.793720-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: _____wAXQBk2M2Nq0GDcLg--.53080S2 X-Coremail-Antispam: 1Uf129KBjvJXoW7WFyUWr1kZr1xXF15ZFyfCrg_yoW8XrykpF ZrCFy8Jrs5Gr4ftryjk3ZFyF45Xa9YqFW5KFW2k398u3s5Gw1qvrnYkryYy34DArZrGay3 ZFn8Jry8CFWDurJanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07j8yCJUUUUU= X-CM-SenderInfo: xrxvxxx0lr0wirqskqqrwthudrp/xtbC4hZNXGpjMzbFhAAA3o 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