Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3017922rwb; Mon, 15 Aug 2022 16:14:37 -0700 (PDT) X-Google-Smtp-Source: AA6agR4wjqOzANZQfBQtWqhg9zOc9jO6sEe1AVx71Lct5pib69I+f+Aij/+bN+FgM41gTLD8TQ5A X-Received: by 2002:aa7:da4b:0:b0:43d:cc2e:c097 with SMTP id w11-20020aa7da4b000000b0043dcc2ec097mr16514468eds.188.1660605277584; Mon, 15 Aug 2022 16:14:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660605277; cv=none; d=google.com; s=arc-20160816; b=aT1kCJA9SK4O9GlT/FjuaA2QdDOuol5kGoyIzhRC4DqMjEWE9PVDRHhHZBjgJPRkkf n+o+3EUhwjF9uRLduWi/8vFtVHCPOMYCBME9H2m1jZi3PnRHCP09un3XzZ8EbwXvnorS V/Oe8dOASawxxiagjzYX7oekPRhih+5q28wUrwmxMxQrwr4cWCiSuGKRfoI+Sr3hDMEp SmqGCL/iODJ9Ri1emS0+KX/8LdvCRca/H1besmXnAkREpA3rcQGPtSVctiv7M2sTwk30 leHPfc6MFci4hJrT2pmLdhh3Z3tF9Fy481xd6jrKjyBGloxXxdZmplWqwZ+YqpZdXvf/ kpPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=8i3zcXfLD5WPlmyzFO5h6SOw/b2qZlA/IbTI3r+UnaY=; b=e5Z2L7RCr1Ee817eNO3eXh94CDrrq+cQnvIbyUUTuyHTPlsTJJSxJJW1eHxhPiBgyW R45P8xROEmnDqy1xJti6YSPlwfHz9n8A6xLSv/98N4wPqnl55uySCTSrEsW2XfIRJrBY M6pheIYpYKsBrWDYzzm+HBhFTlv4Rzj7hq1E51NROGXRxOeSyGCwncl9wtvfSpQdLiXl FQOOWFEt8JQkwZDY2grwNrV8CGSIrPqgnW1GPjGwrCCd9sz9Fp0AicX9GOkh8NN67GJj BG4Yqa+UPY6EP9zT4Q7Qq/+5abQe+KmsrC5CdujJSQVhQzqpT4bYXRK5jiOD60YENUBl NzDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=x7ROkbjF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gc29-20020a1709072b1d00b007309b0ab2b4si6854478ejc.518.2022.08.15.16.14.12; Mon, 15 Aug 2022 16:14:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=x7ROkbjF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347248AbiHOWK0 (ORCPT + 99 others); Mon, 15 Aug 2022 18:10:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48594 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347979AbiHOWJU (ORCPT ); Mon, 15 Aug 2022 18:09:20 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 664D34BA5F; Mon, 15 Aug 2022 12:38:01 -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 79A4DB80EA9; Mon, 15 Aug 2022 19:37:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AF5C5C433D6; Mon, 15 Aug 2022 19:37:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660592278; bh=r30e+sMP6An9UM77h4Ctf06Aj0GohmynoqA4U+Q+tvQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=x7ROkbjFkyU/80zmAcKeXUgaJEmRIGcGT56dwXxRoHVvkuyPCOOVteTHx98SokYU5 dAFEfM6/EGITyywO7JjsS4Ol51ldMcYDdJnI0NsXg+8FGF+PW7VbUT67JDLPfiqGdw +dhjTEIQTBf5Q8N3uH/qnw6LR9pnxmlwTtddmvTk= 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.19 0056/1157] fbcon: Fix boundary checks for fbcon=vc:n1-n2 parameters Date: Mon, 15 Aug 2022 19:50:12 +0200 Message-Id: <20220815180441.708447948@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180439.416659447@linuxfoundation.org> References: <20220815180439.416659447@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Helge Deller commit cad564ca557f8d3bb3b1fa965d9a2b3f6490ec69 upstream. The user may use the fbcon=vc:- 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 @@ -125,8 +125,8 @@ static int logo_lines; enums. */ static int logo_shown = FBCON_LOGO_CANSHOW; /* console mappings */ -static int first_fb_vc; -static int last_fb_vc = MAX_NR_CONSOLES - 1; +static unsigned int first_fb_vc; +static unsigned int last_fb_vc = MAX_NR_CONSOLES - 1; static int fbcon_is_default = 1; static int primary_device = -1; static int fbcon_has_console_bind; @@ -440,10 +440,12 @@ static int __init fb_console_setup(char options += 3; if (*options) first_fb_vc = simple_strtoul(options, &options, 10) - 1; - if (first_fb_vc < 0) + if (first_fb_vc >= MAX_NR_CONSOLES) first_fb_vc = 0; if (*options++ == '-') last_fb_vc = simple_strtoul(options, &options, 10) - 1; + if (last_fb_vc < first_fb_vc || last_fb_vc >= MAX_NR_CONSOLES) + last_fb_vc = MAX_NR_CONSOLES - 1; fbcon_is_default = 0; continue; }