Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp1863320rwb; Fri, 19 Aug 2022 10:38:17 -0700 (PDT) X-Google-Smtp-Source: AA6agR6uVVlNYS0Bi1Q5Zuu7k1HLJbqngXWqyx04UNKTeTkZNsceDZ+GGwBPAUpPmqjTRzDSDx1M X-Received: by 2002:a17:90a:4801:b0:1fa:98ec:fa2 with SMTP id a1-20020a17090a480100b001fa98ec0fa2mr9336852pjh.41.1660930697142; Fri, 19 Aug 2022 10:38:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660930697; cv=none; d=google.com; s=arc-20160816; b=udAwakbKQEKZ3vYGZULl6kUkdstkUfj5/vTTereailhkCg1tBnlMh5yGSWryy/CCkV C9fC0fdrr8NN+wB9B3OQS9RVdPfRaWxgbRSJsKimEwKOCOcpdcUKhQJYg/KstxD5TmtW MmAuSiYkxkWbU1hIzUORn94/yZQrtQidNpT3DGGX8etUUxwAvowqzaGPpYBvZxeYB383 g1jGr7eL32h+bL6FuvtXfupLNnVLp4DgKfxfY3C6J7Ub/66PfXavERNbA7OROXSQgo1u lKfVQvBxZaniOqNBt10MrS7Rq7cyWxCFQaeboGHEXdMvZ84g+ocE7CDRGyJU4L1fa0jJ 2/cA== 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=pp9pZVvLXGszoRWRI9qQ5kpe5sTU4RGYRgbcLZirxnU=; b=Ugs+aCqkJ7Y9oGPreXDJLU7Sh2HW2bai2NAIpvudb8kcrgqi8ufYiXVTXPXE8ad4c8 Ab1R7n0p7ZjabvfjZpe1hCHnHRN4ZAViFDHFVUZLunY95mL06mPuErMmgh8Rxd7GUTQ8 OoloOe7h/BVAegBR7+rOdyi5SHv84xQfpGQVAMU3ZUDjhsNT4cBT2+0ntEEaQrIK6FoB t92NQUFdhTsbrtYvH87JuR+eEPzzPqcg4D2bpF66H5ZYSkY8f1l7UjYDvRsAZfXmnTTX G7rZWST3/69jqtkYatx2LQxPjBxDoL79x9p3Q8jpbM+RMrE0LKcPCTEe8M/tvfkZZ1yI zz5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=TMPXUY0f; 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 e24-20020a637458000000b0042268f5eb68si4600887pgn.130.2022.08.19.10.38.06; Fri, 19 Aug 2022 10:38:17 -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=TMPXUY0f; 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 S1354002AbiHSQpj (ORCPT + 99 others); Fri, 19 Aug 2022 12:45:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55054 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353554AbiHSQmn (ORCPT ); Fri, 19 Aug 2022 12:42:43 -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 99266558C8; Fri, 19 Aug 2022 09:11:06 -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 EC97361888; Fri, 19 Aug 2022 16:09:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CE93CC433D6; Fri, 19 Aug 2022 16:09:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660925393; bh=THYaxhYxEtt5DwL3NnXBSqE1FH6qDsr39tfqXb4p+iA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TMPXUY0fxUR252LqFYU76InfDXCRawsqVicLQk22iC5fIorJlBAQuc6nhnKZSmCI1 8QGA+EnvHu6qehQMzSrERL3dohibnZX2cJM3cY/19Skv81vHO9D4EcIupaizZ97iZR bAafw7/8tjYYH1IjNrc0ernkgUDqOYzlYO/yMTK8= 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 5.10 438/545] video: fbdev: s3fb: Check the size of screen before memset_io() Date: Fri, 19 Aug 2022 17:43:28 +0200 Message-Id: <20220819153849.021915423@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220819153829.135562864@linuxfoundation.org> References: <20220819153829.135562864@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 6ba592fa014f21f35a8ee8da4ca7b95a018f13e8 ] In the function s3fb_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: [ 54.083733] BUG: unable to handle page fault for address: ffffc90003000000 [ 54.083742] #PF: supervisor write access in kernel mode [ 54.083744] #PF: error_code(0x0002) - not-present page [ 54.083760] RIP: 0010:memset_orig+0x33/0xb0 [ 54.083782] Call Trace: [ 54.083788] s3fb_set_par+0x1ec6/0x4040 [ 54.083806] fb_set_var+0x604/0xeb0 [ 54.083836] do_fb_ioctl+0x234/0x670 Fix the this by checking the value of 'screen_size' before memset_io(). Fixes: a268422de8bf ("fbdev driver for S3 Trio/Virge") Signed-off-by: Zheyu Ma Signed-off-by: Helge Deller Signed-off-by: Sasha Levin --- drivers/video/fbdev/s3fb.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/video/fbdev/s3fb.c b/drivers/video/fbdev/s3fb.c index 5c74253e7b2c..a936455a3df2 100644 --- a/drivers/video/fbdev/s3fb.c +++ b/drivers/video/fbdev/s3fb.c @@ -902,6 +902,8 @@ static int s3fb_set_par(struct fb_info *info) value = clamp((htotal + hsstart + 1) / 2 + 2, hsstart + 4, htotal + 1); svga_wcrt_multi(par->state.vgabase, s3_dtpc_regs, value); + if (screen_size > info->screen_size) + screen_size = info->screen_size; memset_io(info->screen_base, 0x00, screen_size); /* Device and screen back on */ svga_wcrt_mask(par->state.vgabase, 0x17, 0x80, 0x80); -- 2.35.1