Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3E1CB3A6F17 for ; Mon, 22 Jun 2026 13:24:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782134689; cv=none; b=bBDd33sIzZdqZ1okiJ7zVVHwWzdB7WlWThtHcTonOV4NOK09v0csHHfsKdBNNTLveKIt8bjsZa6KYPxPv3NYEmYJlSUxp2WCwa7XAm44ll6E2GdyhAVqMljLyLcdY8UxoHr5c7bIWq8DNcl/ySe1X6ylFcEPdkcbqKw3qMPz1JQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782134689; c=relaxed/simple; bh=loNXJrgKy5QPoCKgSFkb4aKBjzG/BgvkpIVpXYbgFdM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PzJUQ6il8BnJUUlF+v3Vp5ky0I6z1cWV/tNN7X5fhPieOjF5rtUICyLjARp5a1EaPDeA6Jo8HnkcDv7RMO0UUKbCRFC/fuLT6kFKOk2PtZf6KQ5Sox0RCVGB13tpxEEX48Te1JfFHxLzQXFsButcjKugAyOsPZjdhubhS2+GIHU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; arc=none smtp.client-ip=195.135.223.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 57A1C75CFD; Mon, 22 Jun 2026 13:24:41 +0000 (UTC) Authentication-Results: smtp-out2.suse.de; none Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 14383779A8; Mon, 22 Jun 2026 13:24:41 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id WM/KA5k3OWpYIQAAD6G6ig (envelope-from ); Mon, 22 Jun 2026 13:24:41 +0000 From: Thomas Zimmermann To: javierm@redhat.com, treding@nvidia.com, maarten.lankhorst@linux.intel.com, mripard@kernel.org, airlied@gmail.com, simona@ffwll.ch, rayyan@ansari.sh Cc: dri-devel@lists.freedesktop.org, sashiko-reviews@lists.linux.dev, Thomas Zimmermann , stable@vger.kernel.org Subject: [PATCH v2 4/6] drm/sysfb: simpledrm: Improve stride validation Date: Mon, 22 Jun 2026 15:19:38 +0200 Message-ID: <20260622132433.722823-5-tzimmermann@suse.de> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260622132433.722823-1-tzimmermann@suse.de> References: <20260622132433.722823-1-tzimmermann@suse.de> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Rspamd-Queue-Id: 57A1C75CFD X-Spam-Flag: NO X-Spam-Score: -4.00 X-Spam-Level: X-Rspamd-Action: no action X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Spamd-Result: default: False [-4.00 / 50.00]; REPLY(-4.00)[] Validate the computed stride against the maximum value INT_MAX. Signed-off-by: Thomas Zimmermann Fixes: 7bfa5c7b28d6 ("drm/simpledrm: Compute linestride with drm_format_info_min_pitch()") Cc: # v6.1+ --- drivers/gpu/drm/sysfb/simpledrm.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/sysfb/simpledrm.c b/drivers/gpu/drm/sysfb/simpledrm.c index 709922ea656c..76b9a3f5c4ef 100644 --- a/drivers/gpu/drm/sysfb/simpledrm.c +++ b/drivers/gpu/drm/sysfb/simpledrm.c @@ -694,9 +694,15 @@ static struct simpledrm_device *simpledrm_device_create(struct drm_driver *drv, return ERR_PTR(-ENODEV); } if (!stride) { - stride = drm_format_info_min_pitch(format, 0, width); - if (drm_WARN_ON(dev, !stride)) + u64 pitch = drm_format_info_min_pitch(format, 0, width); + + if (drm_WARN_ON(dev, !pitch)) { + return ERR_PTR(-EINVAL); /* driver bug */ + } else if (pitch > INT_MAX) { + drm_warn(dev, "stride of %llu exceeds maximum\n", pitch); return ERR_PTR(-EINVAL); + } + stride = pitch; } sysfb->fb_mode = drm_sysfb_mode(width, height, width_mm, height_mm); -- 2.54.0