From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 023C7314A98 for ; Thu, 14 May 2026 17:58:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778781529; cv=none; b=gdSoPRPr1z3C5ts1i0Lq8KbbS69FYNXkdEwPPS0gazwU4s8azMPpAz+j6M9fid0AFG9WptCnA4es7HE48QzW8PlcQIxErdY4DhJO0GOkwBQoMiFyIhyj64UYxlJHZxecHkYaX2EfKLHRqBVasX77Lqd6lCxj65aUQtkObpAsDSc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778781529; c=relaxed/simple; bh=tWYQex8LIhnHuurrtDwvSj14+eAYwsATFXsZtBrtNe8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=I38Acn1SLrwaVHxfu1Pv2/zyGXZones7xT87ook4jLiErMwm2tunAS+B0n+fbCSEOQcdYj36IJFmboeCeBsAMvWJ7gfjrp+HB2Rmb5sWdGsLrXMWem3XgvktKkd9q61a3tRKR1hoeMAzZ/lGzvpJxwgOuw/cviA6WRMlPxTsMw0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=LP77r3+G; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="LP77r3+G" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 69360C2BCC7; Thu, 14 May 2026 17:58:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1778781528; bh=tWYQex8LIhnHuurrtDwvSj14+eAYwsATFXsZtBrtNe8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LP77r3+GwZEgdj95PTf6vVXIaPe02j037y/GV4K/1sTKmqy9hi8xpgkNxICpzS4o5 rC6/NUV6DHmakFawoXpUjaYF1uzebFmDZqyFWpesgQfIR4RiEKUyGEY9iFuKperACf R58wtINUbXn+ave5dePsdvNeZj2eqp7FNhMr6jUSFNVFkA54zjeBq6VS218jUSvjQS cl7D8k73JSi2CsOz1xzoenY+v1xL9gMM00DpJ4m8J4vC2Uuq2OgzWwnR/BeXHlQaK+ GZYOumgjP8csCl0YyH2wIWMWzpJeIYK0Mexl8yVnqwVCt2GXS8vSu0mvoz22EqoeHM x9MJve1sJzKeQ== From: Sasha Levin To: stable@vger.kernel.org Cc: Thomas Zimmermann , Helge Deller , Sasha Levin Subject: [PATCH 6.18.y 2/2] fbcon: Avoid OOB font access if console rotation fails Date: Thu, 14 May 2026 13:58:45 -0400 Message-ID: <20260514175845.529279-2-sashal@kernel.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260514175845.529279-1-sashal@kernel.org> References: <2026051241-compacted-starless-59c8@gregkh> <20260514175845.529279-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Thomas Zimmermann [ Upstream commit e4ef723d8975a2694cc90733a6b888a5e2841842 ] Clear the font buffer if the reallocation during console rotation fails in fbcon_rotate_font(). The putcs implementations for the rotated buffer will return early in this case. See [1] for an example. Currently, fbcon_rotate_font() keeps the old buffer, which is too small for the rotated font. Printing to the rotated console with a high-enough character code will overflow the font buffer. v2: - fix typos in commit message Signed-off-by: Thomas Zimmermann Fixes: 6cc50e1c5b57 ("[PATCH] fbcon: Console Rotation - Add support to rotate font bitmap") Cc: stable@vger.kernel.org # v2.6.15+ Link: https://elixir.bootlin.com/linux/v6.19/source/drivers/video/fbdev/core/fbcon_ccw.c#L144 # [1] Signed-off-by: Helge Deller Signed-off-by: Sasha Levin --- drivers/video/fbdev/core/fbcon_rotate.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/video/fbdev/core/fbcon_rotate.c b/drivers/video/fbdev/core/fbcon_rotate.c index 380b2746451a1..a3f507825eed8 100644 --- a/drivers/video/fbdev/core/fbcon_rotate.c +++ b/drivers/video/fbdev/core/fbcon_rotate.c @@ -46,6 +46,10 @@ static int fbcon_rotate_font(struct fb_info *info, struct vc_data *vc) info->fbops->fb_sync(info); if (par->fd_size < d_cellsize * len) { + kfree(par->fontbuffer); + par->fontbuffer = NULL; + par->fd_size = 0; + dst = kmalloc_array(len, d_cellsize, GFP_KERNEL); if (dst == NULL) { @@ -54,7 +58,6 @@ static int fbcon_rotate_font(struct fb_info *info, struct vc_data *vc) } par->fd_size = d_cellsize * len; - kfree(par->fontbuffer); par->fontbuffer = dst; } -- 2.53.0