From patchwork Fri Jul 1 20:23:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Helge Deller X-Patchwork-Id: 12903757 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 31DBDCCA479 for ; Fri, 1 Jul 2022 20:24:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231167AbiGAUYG (ORCPT ); Fri, 1 Jul 2022 16:24:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57864 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231862AbiGAUYD (ORCPT ); Fri, 1 Jul 2022 16:24:03 -0400 Received: from mout.gmx.net (mout.gmx.net [212.227.17.21]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3FC54387B1 for ; Fri, 1 Jul 2022 13:23:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1656707033; bh=rQmS4yIj+Kq0oK+U8Ryv32tYGBvhOaSYofJZQWpZKAg=; h=X-UI-Sender-Class:From:To:Subject:Date:In-Reply-To:References; b=fIOLdTnCwKdSF7QIxTmumraXGkfNUG0ClivcyASnedEIPIfK9MhHxNauXOXAW1Nw7 foY+RQl5EEiaYzBZWm4MIZfRM78rQlMArLqWC6AA5ngCeanzECZW3ZPNkeaaOMZ4zK cPTGeD+lt9v4lQk1EpDvJCI4IOFqfoQUYpzaslRY= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from p100.fritz.box ([92.116.182.192]) by mail.gmx.net (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MgNh1-1nPltG2fT5-00hz1f; Fri, 01 Jul 2022 22:23:53 +0200 From: Helge Deller To: geert@linux-m68k.org, dri-devel@lists.freedesktop.org, daniel.vetter@ffwll.ch, linux-fbdev@vger.kernel.org Subject: [PATCH v2 1/4] fbcon: Disallow setting font bigger than screen size Date: Fri, 1 Jul 2022 22:23:49 +0200 Message-Id: <20220701202352.559808-2-deller@gmx.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220701202352.559808-1-deller@gmx.de> References: <20220701202352.559808-1-deller@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:LHLDoqxvdfUun4EcG3tmI0dlKtgbAn1uYwunDECGEcGaabXAxNN Bs/x/xwEaj5rGknXyHB4AlMOUqfFfOIFITBzIQmNGDGw4Ingi2HTebkfNfjkiAbwSmPdZ6D dqrPPbGT8vVuZI+0qfZJNI1F7KNfCQ4leIA5+vOQCaaEmpxouuvIl1nj0ZidKW0bvKMhLZ6 eTYxUl2xqM+zWGSDsVuZw== X-UI-Out-Filterresults: notjunk:1;V03:K0:cB2/OJqA+lE=:QEDxZRbm+VSDc5BqF44nrB KL2bW+V+Q950YrP+hTgVPQNcuWwaiXcYaySC07CFbvOQGnAk1F0upBe7bGbBU7hlRRFZ5JZno Y/9bacluv/lopfOnozzFyrpUpa0nE6zXpujxSPePiwSUYShFMRx/DOpCUxm+y0CIrPb/Hk9Tx qAWmsgZGBeabUiuDjS9yRyITZ3dpFbkOSeihRglAN/bhGGUTsibTf8gfyke6Zg4I0ZizZJGSP LqBPge22derxF01P+pdFUPe3HbQMRAM5qJcW/AjO/rF1FEfEegR0pV4H7y+WyN0xUSPHTa0bF YOXnoKU2aE2r5gKiyvRUsqN5fcG8m+pvHTxy5D361CLwajww78O9qFcx1BUo7bycfELPb91OX eyBkgg9eM3FyFvZzVIJQ33JBsch/BTkriESHl2WoBSDVbIZ59BssIxJkFefMJc5zcKS53Hjhr p3iq9tsU5iEGpOXyvEC1LylTJmPT4TTNTIZKsaPfW6iw2rQavKJ57GqkFOuKVe8t02iIPCCR4 SRjSRHg4iaPHCq86FPrDjPCiThjiCsrSnHjUlcMfIuUBOg4CX42qhqjn2ZfPoz6MsjILMsMPr 7BWy14hJnP+/O21MrD3jWFzR3fMcJzAtwEjoA0pqNl4crxnflFT1LcBt8fp06/0ENTY4r45SZ LD3S2L7FtUehcTCsVXe5Lg1vWblkd+nvrvU/IjmXlyq/fudsxk0ydThGMmrfs5tZK3VDVjOqC nHBcUOSsgmUVlwQUPeDX6cae8ecmMOybbFXAnLuprUUXKgoPQfORBDvZ1JwF3QTHWqGCs5qQc yVoo4jCcvU+RUYCNUnJoxHl2g3I237j2xFqzcpAqu0pFybHpDSoEoZEeObeYp6IeThzxZylSS C/L25gU7BiwNpRNFlDUnb9WzKcnR5fC5wUNzUofvCDqfRaMbenRj+wGqtVY7Mjte49qEt8giD Tyt3JljEDxEobwiXDyPa3rAclHLBzl6eW2egbsHj4utPWVGhEEAk12dw53x872NfyS3ezmENs CYR/4yYBx6X7cE+RMpw9W3XH9r83yDGe+KBsHPVO/7+zqAOQ/g30ELAwRSkPFxlYI9YjMposA 1gup/fG89zgRtUM7t8vRcdEmg9IUePiJwMv2++R2bkm60OyaLzmitpY5w== Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Prevent that users set a font size which is bigger than the physical screen. It's unlikely this may happen (because screens are usually much larger than the fonts and each font char is limited to 32x32 pixels), but it may happen on smaller screens/LCD displays. Signed-off-by: Helge Deller Reviewed-by: Daniel Vetter Reviewed-by: Geert Uytterhoeven Cc: stable@vger.kernel.org # v4.14+ --- drivers/video/fbdev/core/fbcon.c | 5 +++++ 1 file changed, 5 insertions(+) -- 2.35.3 diff --git a/drivers/video/fbdev/core/fbcon.c b/drivers/video/fbdev/core/fbcon.c index c4e91715ef00..a33532564393 100644 --- a/drivers/video/fbdev/core/fbcon.c +++ b/drivers/video/fbdev/core/fbcon.c @@ -2469,6 +2469,11 @@ static int fbcon_set_font(struct vc_data *vc, struct console_font *font, if (charcount != 256 && charcount != 512) return -EINVAL; + /* font bigger than screen resolution ? */ + if (w > FBCON_SWAP(info->var.rotate, info->var.xres, info->var.yres) || + h > FBCON_SWAP(info->var.rotate, info->var.yres, info->var.xres)) + return -EINVAL; + /* Make sure drawing engine can handle the font */ if (!(info->pixmap.blit_x & (1 << (font->width - 1))) || !(info->pixmap.blit_y & (1 << (font->height - 1)))) From patchwork Fri Jul 1 20:23:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Helge Deller X-Patchwork-Id: 12903756 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 58FC5C43334 for ; Fri, 1 Jul 2022 20:24:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231545AbiGAUYF (ORCPT ); Fri, 1 Jul 2022 16:24:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57830 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231167AbiGAUYC (ORCPT ); Fri, 1 Jul 2022 16:24:02 -0400 Received: from mout.gmx.net (mout.gmx.net [212.227.17.22]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BC2B62ED5B for ; Fri, 1 Jul 2022 13:23:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1656707034; bh=rxU496Ea/xTjK7QokoK/CvWIPeV4p8ucxlEYuQxng1c=; h=X-UI-Sender-Class:From:To:Subject:Date:In-Reply-To:References; b=GyqwgUOV836pRDoRizlIXluIsdOvu32xv5SDibU8jYsvUhfHQYOgdaluGwsNTpX8a Qm9eg3TlKLm47nwbCMhu5LsHJEo2tlO+BS0y8/iB9iz0TWlPjiLcOg1xr2dINLAmU5 zFOmkfkR3FWJrGNs9YFerOsGY9nuxq2qMkYTgn5c= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from p100.fritz.box ([92.116.182.192]) by mail.gmx.net (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1Mnpnm-1nIO2d3Nd4-00pN1a; Fri, 01 Jul 2022 22:23:53 +0200 From: Helge Deller To: geert@linux-m68k.org, dri-devel@lists.freedesktop.org, daniel.vetter@ffwll.ch, linux-fbdev@vger.kernel.org Subject: [PATCH v2 2/4] fbcon: Prevent that screen size is smaller than font size Date: Fri, 1 Jul 2022 22:23:50 +0200 Message-Id: <20220701202352.559808-3-deller@gmx.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220701202352.559808-1-deller@gmx.de> References: <20220701202352.559808-1-deller@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:ZHYTlOGKyFeiwiZa2YYz4S0Wnm6R1fmU1XmicS4cmLNG0W7rv4T G/QJb0lvetmDVHjRM1rmOMzXWnWvwdsRas3Wc/l6o7mLiyztK1U8cPeDtLZyDOJDSCGuqIf Pc0bYbHR8MfUfsSWK7V7oK6FOyapwC/HYjjgzmyHqB85DJyoEkmXkHqeynFzJ6vdqvyuu12 03zLzYgcWQhfM/QGnQr5w== X-UI-Out-Filterresults: notjunk:1;V03:K0:TQhVhJaK0ks=:ZoWst0gtGN1bRV5t8yived vle+ooyvJswph8i1Re1hTZ3fahmnvv3uL5VKPXOrAGuBaIypBUDfhzO6T85x4Po1RzVGOreFp 32jGIpEtzBoUxCimNOMs0m7mXF62gU69gxB9c11NB58pnS9Q+Ta8TznMVhOD/Gh/msFYMEPjp rB7vtAREmwmyAVbsBccd2vjIiN1Rx1cCgzpSqor6Lk/pN15ecYfmgHUAwgHqS7NM2QacBkHyj jJHqfKHi+/Sxn72QrdYNDsx5Bm1Vy6MD9MoFW5lgTRqvGWccrK7n2TeiXDX/adZmCxItdI7xB WZ7fxSifXCDBZuCYHdoWl9Zpa1LY81Ws74ZBwoeeMCvGaK8QhAhZJ+UpkIndyZ85mn8TIJJAB dnDpKPuL9OySs2UbJNtFA+4kKGPR8pyvzcZ77qzfakQgZnq3JBKZMds6khKYb1mN+BKK0vZME P1K4LzB91zo3sm0hVupLzR2onwdJv8jLFWxxoxNt1mr8NttTq39nkU9sza2kJyfCCOy6tAfSf UWrv7QyBvjJ1SgysScXTw56jJWtwu2nZsgEuQ/kQd9lhpVRJaeTZImlZjKuEzjF1PGGLKN81G 3hYqdqXp7KSAWz/sK7QCBgC6ywF/11w3S2miw0wfVht0VK5FJn+kalEzLtQGImELvrblTCiYl 1u3TA4GtmSJ1sfpE8Q8uW+tcJP1sDKrb8+xOOuenz+KrbADQKI44Vp+ae7BfE6imPLtu4BEqu JSa83FeMsSEEi9vEIPQHmPXFNk9W3PJ6EIERf4GJl/G+xCuWBnaP4ukr/ttKPIpWlrDjFBLDj qdE4Kx3HcUgDGZ/EGJaHz0qcjcQ7cYsfJ4gHIx6Dq5UeewNYbxBItPYEGDdpx8LNFpCP0B2Fm 8Zn2SYqHDgPycEpNldyR9EZCEaEOp0hWvu1ysu2r+BMEtgStiP82sKz/LACxveaYXcCxTo0il Kf7S3ZAvZOXB8/L1FDFPfQTSePSs68am8uHjCEHrNCIz84Siz1Uq2KuHU8oMjfWf/fpG2+cYb yrEuE+e6a3Kt0J8OqU3Zv8zxLpu5k5JsxNjsARbWdsYDftOHifRzbFCLPZwSJAS/CHnFlXe3k q4ZCYb0ht4xVJh2u3+NYA/6HO4bpZZ5d1fIq+QkYN1fFJ9x6JIktBgi1w== Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org We need to prevent that users configure a screen size which is smaller than the currently selected font size. Otherwise rendering chars on the screen will access memory outside the graphics memory region. This patch adds a new function fbcon_modechange_possible() which implements this check and which later may be extended with other checks if necessary. The new function is called from the FBIOPUT_VSCREENINFO ioctl handler in fbmem.c, which will return -EINVAL if userspace asked for a too small screen size. Signed-off-by: Helge Deller Cc: stable@vger.kernel.org # v5.4+ --- drivers/video/fbdev/core/fbcon.c | 28 ++++++++++++++++++++++++++++ drivers/video/fbdev/core/fbmem.c | 4 +++- include/linux/fbcon.h | 4 ++++ 3 files changed, 35 insertions(+), 1 deletion(-) -- 2.35.3 diff --git a/drivers/video/fbdev/core/fbcon.c b/drivers/video/fbdev/core/fbcon.c index a33532564393..14b0ab51744f 100644 --- a/drivers/video/fbdev/core/fbcon.c +++ b/drivers/video/fbdev/core/fbcon.c @@ -2736,6 +2736,34 @@ void fbcon_update_vcs(struct fb_info *info, bool all) } EXPORT_SYMBOL(fbcon_update_vcs); +/* let fbcon check if it supports a new screen resolution */ +int fbcon_modechange_possible(struct fb_info *info, struct fb_var_screeninfo *var) +{ + struct fbcon_ops *ops = info->fbcon_par; + struct vc_data *vc; + int i; + + WARN_CONSOLE_UNLOCKED(); + + if (!ops) + return -EINVAL; + + /* prevent setting a screen size which is smaller than font size */ + for (i = first_fb_vc; i <= last_fb_vc; i++) { + vc = vc_cons[i].d; + if (!vc || vc->vc_mode != KD_TEXT || + registered_fb[con2fb_map[i]] != info) + continue; + + if (vc->vc_font.width > FBCON_SWAP(var->rotate, var->xres, var->yres) || + vc->vc_font.height > FBCON_SWAP(var->rotate, var->yres, var->xres)) + return -EINVAL; + } + + return 0; +} +EXPORT_SYMBOL(fbcon_modechange_possible); + int fbcon_mode_deleted(struct fb_info *info, struct fb_videomode *mode) { diff --git a/drivers/video/fbdev/core/fbmem.c b/drivers/video/fbdev/core/fbmem.c index afa2863670f3..160389365a36 100644 --- a/drivers/video/fbdev/core/fbmem.c +++ b/drivers/video/fbdev/core/fbmem.c @@ -1106,7 +1106,9 @@ static long do_fb_ioctl(struct fb_info *info, unsigned int cmd, return -EFAULT; console_lock(); lock_fb_info(info); - ret = fb_set_var(info, &var); + ret = fbcon_modechange_possible(info, &var); + if (!ret) + ret = fb_set_var(info, &var); if (!ret) fbcon_update_vcs(info, var.activate & FB_ACTIVATE_ALL); unlock_fb_info(info); diff --git a/include/linux/fbcon.h b/include/linux/fbcon.h index ff5596dd30f8..2382dec6d6ab 100644 --- a/include/linux/fbcon.h +++ b/include/linux/fbcon.h @@ -15,6 +15,8 @@ void fbcon_new_modelist(struct fb_info *info); void fbcon_get_requirement(struct fb_info *info, struct fb_blit_caps *caps); void fbcon_fb_blanked(struct fb_info *info, int blank); +int fbcon_modechange_possible(struct fb_info *info, + struct fb_var_screeninfo *var); void fbcon_update_vcs(struct fb_info *info, bool all); void fbcon_remap_all(struct fb_info *info); int fbcon_set_con2fb_map_ioctl(void __user *argp); @@ -33,6 +35,8 @@ static inline void fbcon_new_modelist(struct fb_info *info) {} static inline void fbcon_get_requirement(struct fb_info *info, struct fb_blit_caps *caps) {} static inline void fbcon_fb_blanked(struct fb_info *info, int blank) {} +static inline int fbcon_modechange_possible(struct fb_info *info, + struct fb_var_screeninfo *var) { return 0; } static inline void fbcon_update_vcs(struct fb_info *info, bool all) {} static inline void fbcon_remap_all(struct fb_info *info) {} static inline int fbcon_set_con2fb_map_ioctl(void __user *argp) { return 0; } From patchwork Fri Jul 1 20:23:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Helge Deller X-Patchwork-Id: 12903753 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 C63F9C43334 for ; Fri, 1 Jul 2022 20:24:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229846AbiGAUYE (ORCPT ); Fri, 1 Jul 2022 16:24:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57826 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230294AbiGAUYC (ORCPT ); Fri, 1 Jul 2022 16:24:02 -0400 Received: from mout.gmx.net (mout.gmx.net [212.227.17.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 062263AA6D for ; Fri, 1 Jul 2022 13:23:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1656707034; bh=dEefPiI9Wq3+N76bPKdFvUHz0EeUTEIRh3WCR7KXkgA=; h=X-UI-Sender-Class:From:To:Subject:Date:In-Reply-To:References; b=HEFt5iZDmNZf66zk+qkPjL3tW/l2Fg/mj39IwVLc9Udj7wk4mo3GOy8hvIzKNSMjZ 1gIakjLvxkq8vz/kDjPdv/khMXrT2wdDiBLpUteax/9On9UcojFbz6WKfb3RJBtpFX zKPl6vMnyG8dRvOH6jql54+NqKx8HkZPl5XNYvoU= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from p100.fritz.box ([92.116.182.192]) by mail.gmx.net (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MsHnm-1nn6Ad44zK-00ticg; Fri, 01 Jul 2022 22:23:54 +0200 From: Helge Deller To: geert@linux-m68k.org, dri-devel@lists.freedesktop.org, daniel.vetter@ffwll.ch, linux-fbdev@vger.kernel.org Subject: [PATCH v2 3/4] fbmem: Prevent invalid virtual screen sizes in fb_set_var() Date: Fri, 1 Jul 2022 22:23:51 +0200 Message-Id: <20220701202352.559808-4-deller@gmx.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220701202352.559808-1-deller@gmx.de> References: <20220701202352.559808-1-deller@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:Bf8VXfaa577fpq4acsmdWzYRjRzn9t3d4jS+k3688Br3xPNGmzP p53HnFCs0503W6wMD/41hpxfgpasIAVFfi+0BsK0Vaca5CnYMrAq92Vt4Tv+y1NmmzQs91o sVc5gGs3GeWTC2v0TTBIXaXv/f8fpwtPuDlMwKHBivevR9eRdM3KlUOT4Ma599iz18mKGA0 zulyQJ8I7gZN6XhQyLMUw== X-UI-Out-Filterresults: notjunk:1;V03:K0:Vw9SFYftwds=:rr4MBShpbjEyzFIUlufOTC c/MzOQWgDKdqqI6ErlQQSs7fvS6fRhtrRcuAtfnXFGwMl3llbzURBcbqajh2yuL4CnGqOY/im qxSAxrVThZlQNTnuErbRtOS5D1Ib4TobV9FaN8k2wSqNskvY/JdatfT9PwqyaCQbZ4JQ4y8u8 KNiSxIpYQ0qvVGYzwUG2PtUGoHYc9PAa7tBFoScRv9AuLwykZ2SUwCALRysMGJHo8RAMbojOw HCL6o+uJQd+sHpSCC9SnXktaDTJPklX8cJE67vWppHC40YA84O4GDdrcJUEhmxyTeGsmGJhbk 9OAd2RlR3kvKZSu7mPe+QPIoFj/v8MS2XaohZ+hQiR+GS7MhauN7cCcFRd+pM0baSQnnstYSC TRqfUD/QZ0xh8exiFubK/APbIr7nxJRxfPQxlI5NQctBPP/YJZlQuIeUN4Cozr2+0lnxs4Dsa oP1RdkF5V5RVEP1wpg56ZIpoJvA/LoiV5+HQ7Htn2r+0biNhPWEEyJ/hbhmhZTQcU3GhVPsJL jR+5Iujjv2NYaR17ipV61J7X+4yJPOUVvANCSvtbkcE+MRW/wqlUfYcWkxdBykhumrzqeqbQf YIt+mJS/8l5f6jZ+LzOuZ2gRoLQm2yfqyaFXQN0quCzF2l+OQErY7ZKU6HbfbIHey8vNqG1AX 75EpJwWfycUEiHmRrP9mkETt/kPVECtqnJJjNn32GXg4TRN6fAAfMRAOxJavcluEUuyal7EJz CJbnLMsB1UiwBif7hdyZ4+ttwl+EWWS59Uq0JFduXObZ0VAMthoMccSdRlYiT/vL6bTZjSNHy TEW34N4LBqpeXkMDScqnsQarwjqDFV60vsxC1FNemFWYS4FYHziLU4er5jAt+eyu6/zzbMlNG w8/ukmPmX4bUizk4xvTy7j60pICkSFog6EK5AYmaS51zyWZCU8ccJT6v4txKvxkLhx2z3A2s+ MYpXwZrMRyh+0uZWAbTHWv+wwT8dCmsclOjVRO6Y5aQlT7s14YkMvHsItJGuITDMtdKNvrF8o OMrCmoMZ6LK0Wh4HJUj6EB0qnDehIoyzoJJF4BNJEn64pDQP/A/73hTjkQmTRNcltxtbhPkIU 1M0pF0YtNlgIBkko68snz3nUE5vQLlK1s6jcdZZCFGh99qG760rPGZy/Q== Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Prevent that drivers configure a virtual screen resolution smaller than the physical screen resolution. This is important, because otherwise we may access memory outside of the graphics memory area. Give a kernel WARNing and show the driver name to help locating the buggy driver. Signed-off-by: Helge Deller Cc: stable@vger.kernel.org # v5.4+ Signed-off-by: Helge Deller --- drivers/video/fbdev/core/fbmem.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) -- 2.35.3 diff --git a/drivers/video/fbdev/core/fbmem.c b/drivers/video/fbdev/core/fbmem.c index 160389365a36..e8f06d26803c 100644 --- a/drivers/video/fbdev/core/fbmem.c +++ b/drivers/video/fbdev/core/fbmem.c @@ -1016,6 +1016,18 @@ fb_set_var(struct fb_info *info, struct fb_var_screeninfo *var) if (ret) return ret; + /* make sure virtual resolution >= physical resolution */ + if (WARN_ON(var->xres_virtual < var->xres)) { + pr_warn("fbcon: Fix up invalid xres %d for %s\n", + var->xres_virtual, info->fix.id); + var->xres_virtual = var->xres; + } + if (WARN_ON(var->yres_virtual < var->yres)) { + pr_warn("fbcon: Fix up invalid yres %d for %s\n", + var->yres_virtual, info->fix.id); + var->yres_virtual = var->yres; + } + if ((var->activate & FB_ACTIVATE_MASK) != FB_ACTIVATE_NOW) return 0; From patchwork Fri Jul 1 20:23:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Helge Deller X-Patchwork-Id: 12903754 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 D67A5CCA479 for ; Fri, 1 Jul 2022 20:24:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230294AbiGAUYE (ORCPT ); Fri, 1 Jul 2022 16:24:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57844 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231253AbiGAUYD (ORCPT ); Fri, 1 Jul 2022 16:24:03 -0400 Received: from mout.gmx.net (mout.gmx.net [212.227.17.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 39F393DA62 for ; Fri, 1 Jul 2022 13:24:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1656707034; bh=s8CRbVLDl822YwqtLOMoLmiiti7AwrtUoVUWnkJvUC8=; h=X-UI-Sender-Class:From:To:Subject:Date:In-Reply-To:References; b=UYjcTSR4SYnQByYvB0wwwK4cL0h9YEIImBNGlG9AqjSnZTGYMXinX0XoSgcVY4vYz JAeVPbs5MLtJssjjwzPTvHN7kYkk35McRfb5b5T+QHz2VxoI44YrWaeYxZhfjR59Xg zwK4HIpPbDLdni0//AX8Sj0DVgxmyZ3uVdIjAJOo= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from p100.fritz.box ([92.116.182.192]) by mail.gmx.net (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MTAFb-1oC0w90VGJ-00UWl1; Fri, 01 Jul 2022 22:23:54 +0200 From: Helge Deller To: geert@linux-m68k.org, dri-devel@lists.freedesktop.org, daniel.vetter@ffwll.ch, linux-fbdev@vger.kernel.org Subject: [PATCH v2 4/4] fbcon: Use fbcon_info_from_console() in fbcon_modechange_possible() Date: Fri, 1 Jul 2022 22:23:52 +0200 Message-Id: <20220701202352.559808-5-deller@gmx.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220701202352.559808-1-deller@gmx.de> References: <20220701202352.559808-1-deller@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:JlLS9An8ORqm99gZ3g8xrQRMSdmqUYZiGP99A8+AFH4NJ2CBlnH LDEYQPy+5IoyRbllFYZhnpoxFbbClTpc/MvvV9idwnZoRwTPxd2ed6gZw99OdqzXOc3zvIS gJh9bQVObGeoDWxSvIrvFieC7q/AazgLwqe3nT7X8wFdTnkL7xfjTrxBtYCzrR6EacQ0A+8 mHyYNXv3wjOkapFWk5aZQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:AwV6Ee3eOGA=:nwE2q14rcqA5wSPJOZWaCJ PMJ092+vDW4hFDuPZqf0Z47dkgHgrTXOzDoE8piKVD/v5xoVcn6IVcyqnwhv42EWwZ6168jHo 5/J5IDzuHAhL5t9wkqSrinkq6owZ3cnydQYZNxKZYcC7aD0gNG5UMmlj/UNMtbIthvnrRlSA0 Jr2vkIJZXrXZ09+5xgZsgCV1Zy/330Xh4zbyZpArumCYkJTGQx52B3F54jUcxenJcC2gM5QHz RmMBP2cqoiobES6weKFf7j06j+ZGKSa9dIdzE8cNqhUZ7M2d9zJozj3wWoH5L7W5GJwDiHpUK 8MPYbWxv0kaWG+wIi1qE8+Wv6uNV2MBrorrcNzCxbRvLtDMdjj+WvpFOvkpZcVYT4OvqDaSaN wS7PYC2lqQwrCJlqWUrcG1mAmqrUm6kwgXXYI5eyoY0//EdGb4YytM6lC3ZpOACYD231zodW6 QAykr+r6sCqnPBGcnbJRL7/6vq+iCyUfss0NjExl0u6EftyRfLDxF06HiAYYW2MnMUge8NgTQ rpf0MDeNDFlHsto/Obo51b8O0MSyEcj27APzUkreoLWH2piYFKD8Mx+gKEgCMtpDqbvZs3RXr pSwkYT0K9WDIueLxY109Gx5TmExKlWGLpEv80z/7Z1qgD2NlWXpwgamc2/sgsJe1S7wYl/70Y w+WJvUaeu+oCyqr4lsEVZtEF3F5imk4FsNn/mv+oF5kXLCZjFmIFKrOC4XjuHVm3/fKgxC36M c85n6fjz8eIS1bQq2Hh1mrWfMrOaUKqU1OHUm/JvrlwkFSBb5ck2yxImUmbE2P+5NXSL68CcZ 43HHM4Zf8jfV8A1ziKEaBUdvyJLnqygL02VIXHX6c6ZR2ugCTdXdYf1thy8BsrNQQb+E5Px7K yfrJCptC2MIbI5yvh9LcfJ2ze4eDtoblL0UXNuL2Tkt37VixSCe4m37aVhaDuvKhImyc9Q/MD KrGj/MoswhrQ0KAR2mKlCglahFOPUKjS6yU5K3EZ0gp7p9RUCRLUTBVLyrLY2cEL7FyffbGtX q9fh3Y6aljMkWJdlZvxEgCB4pHbbCSdRzYqBBfoir06APOzLmarT6805gvw4oX25gp1X5vgBE Fj4XYQFLIgZd9XdUs4FKbQwaju5FmqFk83c68j0MpzdxYvri7zJQEmETQ== Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Use the fbcon_info_from_console() wrapper which was added to kernel v5.19 with commit 409d6c95f9c6 ("fbcon: Introduce wrapper for console->fb_info lookup"). Signed-off-by: Helge Deller Reviewed-by: Geert Uytterhoeven --- drivers/video/fbdev/core/fbcon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.35.3 diff --git a/drivers/video/fbdev/core/fbcon.c b/drivers/video/fbdev/core/fbcon.c index 14b0ab51744f..7f2ebfa8a80a 100644 --- a/drivers/video/fbdev/core/fbcon.c +++ b/drivers/video/fbdev/core/fbcon.c @@ -2752,7 +2752,7 @@ int fbcon_modechange_possible(struct fb_info *info, struct fb_var_screeninfo *va for (i = first_fb_vc; i <= last_fb_vc; i++) { vc = vc_cons[i].d; if (!vc || vc->vc_mode != KD_TEXT || - registered_fb[con2fb_map[i]] != info) + fbcon_info_from_console(i) != info) continue; if (vc->vc_font.width > FBCON_SWAP(var->rotate, var->xres, var->yres) ||