From nobody Fri Oct 24 20:33:57 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 72FA0C25B0E for ; Mon, 15 Aug 2022 20:14:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346376AbiHOUOb (ORCPT ); Mon, 15 Aug 2022 16:14:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50012 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346064AbiHOUKo (ORCPT ); Mon, 15 Aug 2022 16:10:44 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D7B6A2AE4; Mon, 15 Aug 2022 11:56:37 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 81B20B8109E; Mon, 15 Aug 2022 18:56:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AB916C433C1; Mon, 15 Aug 2022 18:56:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660589795; bh=srz8143zkM9lvsMiZNve4c7EgZK6tCW2Vj7c/1l3Lv4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=h4fNn/jtTJe6G/tub84XLj2DDCB76NTr3VcvA4mERo7xCEN5T66C0tgs1IDIOTy/m 3b+hoGb8FDhAiW36fLOSnU3WIKMdt6fYXpsTU/26r0BNJR1Udemkuyutn/9rjfMddq jfaUuGNwORmc6UJcAtZjOcARZ6tkCMdXxkJmQopQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Daniel Vetter , Helge Deller Subject: [PATCH 5.18 0050/1095] fbcon: Fix boundary checks for fbcon=vc:n1-n2 parameters Date: Mon, 15 Aug 2022 19:50:49 +0200 Message-Id: <20220815180431.544474353@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180429.240518113@linuxfoundation.org> References: <20220815180429.240518113@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Helge Deller commit cad564ca557f8d3bb3b1fa965d9a2b3f6490ec69 upstream. The user may use the fbcon=3Dvc:- option to tell fbcon to take over the given range (n1...n2) of consoles. The value for n1 and n2 needs to be a positive number and up to (MAX_NR_CONSOLES - 1). The given values were not fully checked against those boundaries yet. To fix the issue, convert first_fb_vc and last_fb_vc to unsigned integers and check them against the upper boundary, and make sure that first_fb_vc is smaller than last_fb_vc. Cc: stable@vger.kernel.org # v4.19+ Reviewed-by: Daniel Vetter Signed-off-by: Helge Deller Link: https://patchwork.freedesktop.org/patch/msgid/YpkYRMojilrtZIgM@p100 Signed-off-by: Greg Kroah-Hartman --- drivers/video/fbdev/core/fbcon.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) --- a/drivers/video/fbdev/core/fbcon.c +++ b/drivers/video/fbdev/core/fbcon.c @@ -115,8 +115,8 @@ static int logo_lines; enums. */ static int logo_shown =3D FBCON_LOGO_CANSHOW; /* console mappings */ -static int first_fb_vc; -static int last_fb_vc =3D MAX_NR_CONSOLES - 1; +static unsigned int first_fb_vc; +static unsigned int last_fb_vc =3D MAX_NR_CONSOLES - 1; static int fbcon_is_default =3D 1;=20 static int primary_device =3D -1; static int fbcon_has_console_bind; @@ -464,10 +464,12 @@ static int __init fb_console_setup(char options +=3D 3; if (*options) first_fb_vc =3D simple_strtoul(options, &options, 10) - 1; - if (first_fb_vc < 0) + if (first_fb_vc >=3D MAX_NR_CONSOLES) first_fb_vc =3D 0; if (*options++ =3D=3D '-') last_fb_vc =3D simple_strtoul(options, &options, 10) - 1; + if (last_fb_vc < first_fb_vc || last_fb_vc >=3D MAX_NR_CONSOLES) + last_fb_vc =3D MAX_NR_CONSOLES - 1; fbcon_is_default =3D 0;=20 continue; }