Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3412083rwa; Tue, 23 Aug 2022 04:28:15 -0700 (PDT) X-Google-Smtp-Source: AA6agR5Dat1aZq/dVHXE44UovzmKuaIkXRQK2uLMtwoNwL4LVZ9/CsMMYI7VWPdTWUvBpFmTGkcj X-Received: by 2002:a05:6a00:b53:b0:537:7f7:63a7 with SMTP id p19-20020a056a000b5300b0053707f763a7mr1682940pfo.2.1661254095456; Tue, 23 Aug 2022 04:28:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661254095; cv=none; d=google.com; s=arc-20160816; b=HWTqQjmGUj6lBEKjf8DIc/+qB+wcCIapfoqTFlZq3oPDkeylmL0Oy6Ip2M4sSBS8XE DgHagbv2iQz/Qh/fW1J7OMu7gwut5mTj1urp8gpTaSKWoz0BT8DDA1f78wZfZXHyOcDx gy04/W2f0/4AEFgqDEqBUhjpEUe8F+gWegScx1bFvyoBLx+0OfqXsXTt9Bi9xlNzYU0c 4Y0pw3R7Y+fwIpy71UlAkdBdHYk7oxh6NmQWMe5n3uNrEznfBntQYCrpX1/fRFBjpLAA N/ey0nYMZb59+BOg3vSDEFtyCmtRWwDAL9uQRxemHV/1d3cIg4L30co8o1/WwyOt6Kbv sQoQ== 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=rRY+llrAmbVVeOmxa/TD6rMezAtE/PQjfVbDGGlurJk=; b=d+T/7Jo4/vrf8M8hHoJKITBtMfC4GpOS4RiQGc2ftTcoqNzsGbZ2+ohhwaU1iPc6EJ zirgLDFcUx4XYUm7xMvN6k1OyoZOBQ6aPif2b8po65qRhpuY0xiEXphtHYV4m9GS7x6L uTuU41rk+zrDEq16IaYflUHy01V3Oh74ocV5wBkBq2ugAwFM722n9dsm9KSYTaowvNpo ifCrJKmd+Z+5vCXSPehZ9HuAGAe04lkqxjMLoIhQnusvVUZCfsWb31GdgtcCJZIKjH+k RnlTQm9yKYhDFfHp76zHlT+Qx9JodJt1KE9A8VqjnNZoN2yBPKtEXEdMvFvMwCXpi8xi QdpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=QGpf8Rkc; 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 o16-20020a170902d4d000b00170a752cae8si13169348plg.115.2022.08.23.04.28.04; Tue, 23 Aug 2022 04:28:15 -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=QGpf8Rkc; 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 S1355836AbiHWKsG (ORCPT + 99 others); Tue, 23 Aug 2022 06:48:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46718 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356316AbiHWKlw (ORCPT ); Tue, 23 Aug 2022 06:41:52 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DA1CC84ECB; Tue, 23 Aug 2022 02:09:25 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 1B4626010E; Tue, 23 Aug 2022 09:09:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0B256C433D7; Tue, 23 Aug 2022 09:09:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661245759; bh=dS14W8ecUphTKxvCQBorbBcTsP8koOnv//b1T3gJMZU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QGpf8RkcXZTNoNYH17f7mjDEelzmBqQxtklWyZufjOqyOoeNNcqi+eimD/4aqcRW3 koc03lrgxJKhPj+k0ClLvPvq9/ZEWBjL9/EMrxKO3l6I4zo/Q1j+vZIa+7vOIs0SHU U+NUYJaH3AkWaZ9lgq03Mh3SKyXTPe40fIGpB29Y= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Zheyu Ma , Helge Deller , Sasha Levin Subject: [PATCH 4.19 181/287] video: fbdev: vt8623fb: Check the size of screen before memset_io() Date: Tue, 23 Aug 2022 10:25:50 +0200 Message-Id: <20220823080106.880864909@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220823080100.268827165@linuxfoundation.org> References: <20220823080100.268827165@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: Zheyu Ma [ Upstream commit ec0754c60217248fa77cc9005d66b2b55200ac06 ] In the function vt8623fb_set_par(), the value of 'screen_size' is calculated by the user input. If the user provides the improper value, the value of 'screen_size' may larger than 'info->screen_size', which may cause the following bug: [ 583.339036] BUG: unable to handle page fault for address: ffffc90005000000 [ 583.339049] #PF: supervisor write access in kernel mode [ 583.339052] #PF: error_code(0x0002) - not-present page [ 583.339074] RIP: 0010:memset_orig+0x33/0xb0 [ 583.339110] Call Trace: [ 583.339118] vt8623fb_set_par+0x11cd/0x21e0 [ 583.339146] fb_set_var+0x604/0xeb0 [ 583.339181] do_fb_ioctl+0x234/0x670 [ 583.339209] fb_ioctl+0xdd/0x130 Fix the this by checking the value of 'screen_size' before memset_io(). Fixes: 558b7bd86c32 ("vt8623fb: new framebuffer driver for VIA VT8623") Signed-off-by: Zheyu Ma Signed-off-by: Helge Deller Signed-off-by: Sasha Levin --- drivers/video/fbdev/vt8623fb.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/video/fbdev/vt8623fb.c b/drivers/video/fbdev/vt8623fb.c index 5cac871db3ee..cbae9c510092 100644 --- a/drivers/video/fbdev/vt8623fb.c +++ b/drivers/video/fbdev/vt8623fb.c @@ -504,6 +504,8 @@ static int vt8623fb_set_par(struct fb_info *info) (info->var.vmode & FB_VMODE_DOUBLE) ? 2 : 1, 1, 1, info->node); + if (screen_size > info->screen_size) + screen_size = info->screen_size; memset_io(info->screen_base, 0x00, screen_size); /* Device and screen back on */ -- 2.35.1