From patchwork Sat Jun 25 12:24:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Helge Deller X-Patchwork-Id: 585198 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 E8716CCA482 for ; Sat, 25 Jun 2022 12:25:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232939AbiFYMZO (ORCPT ); Sat, 25 Jun 2022 08:25:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57770 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232929AbiFYMZK (ORCPT ); Sat, 25 Jun 2022 08:25:10 -0400 Received: from mout.gmx.net (mout.gmx.net [212.227.15.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AFA0C1CFE1 for ; Sat, 25 Jun 2022 05:25:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1656159903; bh=Ay26CGk1aPsgjG95eVOHNR7bePSriIQn1aMGg2u+ms8=; h=X-UI-Sender-Class:From:To:Subject:Date:In-Reply-To:References; b=aC+l2dGY48+Vs++ByX+MJrYaK0KlOQx5peS7ugemKR4/Tk/k09Ltyo1K6QUavAazp xr6/QyGpXPc4IGPP/MF4IIJHnqFUMkQXZ08y0Q5t5tMW3wPiKycrhSTnk222Yx+GHe gK6KC9FztPX7E3jchEUdJmSyvqn31Pl2X4GJIkcw= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from p100.fritz.box ([92.116.162.44]) by mail.gmx.net (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MYNNo-1o8nxV1uyI-00VMvL; Sat, 25 Jun 2022 14:25:03 +0200 From: Helge Deller To: linux-fbdev@vger.kernel.org, daniel.vetter@ffwll.ch, dri-devel@lists.freedesktop.org, deller@gmx.de Subject: [PATCH v2 1/4] fbcon: Disallow setting font bigger than screen size Date: Sat, 25 Jun 2022 14:24:59 +0200 Message-Id: <20220625122502.68095-2-deller@gmx.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220625122502.68095-1-deller@gmx.de> References: <20220625122502.68095-1-deller@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:cANQeMXRFyLktZ9xQPHna/UWNDvfGoNjlnXhyc8ecEbkkxb8SnQ XpVabKoaEcTFuY+N1kzM4Q0M3eS3EBdcI5/gc8/2MICE7raiS6WKO29HW8jli5LAf+1VyeL dbG922eLXJavzFN7TseR4p3TkvzKOCYqjUzcxK82D/BFMxB1P4AaGRil8DJzI22DxPEmSBW QVYuVIGLws79rQ3Walewg== X-UI-Out-Filterresults: notjunk:1;V03:K0:Jz2D2RW9e8U=:e/KdQo8BBYzJu7BZNVQcoK PWkYGjJDGBcDP0FjuwOMFjoxLVvhFVEmWl/kN46D154zQSJMl9Hloxddquu3qtb2DS7+bFEtO SrA0she5s56MSfes7YYYwHUDtOfrPOx7O0ZV25Mt7isGjjeVKy1kgH8d2txwVZtt30htXbstF Pn0TIxtR4u6tVE6OFQZ2mgwblbIK/loXbE07bjnJGzjXSkLTwowhSOWOYngOeQ1FIC4Bxsl24 IxzNkqfwRWTVrMTbMQKOIaVAKqBSDxCivsqudlWJZLgwufEgr9bC0VQMjIY65kI1w1Hs7AigD PRGFSn6bllDdQj54qkj6E9g6aNTyZQWDZPG8r5tZ+g88LdqDrWdK177qGSy72EHuAdBYJilLP iZN0lCKo5sQDKZ5aFyZDGSvMmaeJJGb42BYPMcl/HlYzz5nMGx6pC++ix2R6YGx6RxF5PurGU tEN49wCtrF2wB2TCnIxTuE26tx/T53x+w/+avkeyGkBHKYWMbJjA6xoVG8HRGLrxUICghJdj0 YAso5zVUAb2OJpz5cp0bAnJdlI/FkbHWE3dLGK4lnlg00/ddxtpJBSsOVrZzpDpWX9E7fRcsr sr9nXEEL2y4it4Dv0jWqcRNwxluxBZYqeAdkSZLsDg8s2RG8QCPvlHubGvFtMohmC5gufc4ji DOHytej6Cj1mOznnMjtcOw2pwtX6J3FoUdtS+sXVeuzrKE9XP0eB7CekzK3EsOQRL+AVg8CDX 9vjLdDWFabQ/5S5B5i5HJPo7SRViGWAU6/L3ZsggktV6ahHJxGTXysA/kH79lR0gWMqDedOEh n4OklNtptmDNwQUeMirBM4ByKcJHYmVfmd6K2SD8getvLy/5BHFqXe6Tv3MpuaaqBh9Qvfu1A 3e0qwQC8PsbxjP3TqkTRaKJB1d9DQZbi5Mbn8apNvcIliG6zT4DE5fBjCRabuO/EsEd7g/5fI t+Lu9KohZPvLCykNT5vxnVPLHcmDI4Fgqn73JVrwDsQnNK+bSFa0yqLjuI0MYwIPHe+xTwqRP Vi1ZkLFMyFSQ6XoK1kPL5VjAGwUGeUMNqx/SpReSQSljm9S/+rYWfZSZPteFTRBQfrPhPjxzC 6/h4QAgArG3IAok9vsN2uSmrVZzuTLJjPDirP4X7A11c4dLPrIGTVshKQ== 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 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..e162d5e753e5 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 (font->width > FBCON_SWAP(info->var.rotate, info->var.xres, info->var.yres) || + font->height > 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 Sat Jun 25 12:25:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Helge Deller X-Patchwork-Id: 584994 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 5E73FCCA483 for ; Sat, 25 Jun 2022 12:25:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232724AbiFYMZO (ORCPT ); Sat, 25 Jun 2022 08:25:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57772 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232940AbiFYMZK (ORCPT ); Sat, 25 Jun 2022 08:25:10 -0400 Received: from mout.gmx.net (mout.gmx.net [212.227.15.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B03151CFF3 for ; Sat, 25 Jun 2022 05:25:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1656159903; bh=t70CimBb6l0u6Vi+5r/ENmuEcpUumwWJgoX4WVhyEoY=; h=X-UI-Sender-Class:From:To:Subject:Date:In-Reply-To:References; b=JPXjueRtIxX258BdSHZGmjSATpFL5jaeP8TrejOaLpr393j5cS8Qr07+fitDDQLde y/iRGzaAs+1AKkp7RQErSDWRXS6l5Lhcd00Bfkbu9+6Y7LoAEoEUPS8G3w2whNOnLj WdnNrVDLjypI4kRSD/JAJ4FlB0rW5Lm7UlctJY0M= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from p100.fritz.box ([92.116.162.44]) by mail.gmx.net (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MfpOd-1nTn9C2Ubx-00gLVY; Sat, 25 Jun 2022 14:25:03 +0200 From: Helge Deller To: linux-fbdev@vger.kernel.org, daniel.vetter@ffwll.ch, dri-devel@lists.freedesktop.org, deller@gmx.de Subject: [PATCH v2 2/4] fbcon: Add fbcon_modechange_possible() check Date: Sat, 25 Jun 2022 14:25:00 +0200 Message-Id: <20220625122502.68095-3-deller@gmx.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220625122502.68095-1-deller@gmx.de> References: <20220625122502.68095-1-deller@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:/OqXbgSKppxYJ14/66zoTizZ5YPaKvTHBEl5XxSwlIgfQXYMDMy Bv+DemUpypzr7LFLGGKMzor+whYSILThX7mEbNw3TW+Y2uLRBNzbM7tslBa/9Lx3xEDsRGo Rs5h439dIfODbN3zabcsB0g608dQ5xrCQgJVDKi+PavNzhkXMJQgi+Tkb7ydaJts3Oa4/VI v1xBKgR4Cb24o4dllVLrA== X-UI-Out-Filterresults: notjunk:1;V03:K0:OCxPORhHytI=:qCj7g7MTEZ1/GMuxQ+Yway EoXjAGXIi/skgHA6xHfqpLnUYwVMXHtyrRTeTIvm9mkpa4W2dwzcsrykLBCBZXp/GyQTXZWz1 IVMykoiS2Csjf6b+8wgmwGkmRshRLgFiVStoqL0rN21ZiOSuYaSsepLe+lyr7Rku6Iza2VwxJ htiniCEruXseXO/JGEw3l3WwfTwgl4fiIFilWJkKh6Tp75BvLY9tE6LYt9H4OBnpyWuh3uQhe BBo6dGAYBFxKQOY6ozJsIBZYpZRquAckSOOqQPgmQYvRhOWA4Oju6P5v2NJPRsRG0RmaIW5Ap +utuLdGEvnxAg9TL+faIIuUN5bXxExGNuZdUx0plr5TzXbJoXQkx6xGZumQfxdfNmI4EASh5K d0vXup/tyTHCKLsi55wEBgv+EG3+uf/rBYYS9tX0qfB5klfMcgHpHkPkT9Z5ZqIgvCtg+og6D w/1quD45/umqYkr75J/fDdeDpE+kUC6gzxeCnaSdK/fdrqQ/ozhmZkDBN7LK2Y0RJOeRSX8vB FkTjFWXMXRqfOKbSEPY0BiAf9AzgN8fCHCQDqmz53OtBygKrCTjMCEfEftPfgsJdlylhhqiwz sebCXbpmtkfi2x3GS9RAObB+QWdLvtajG80bglrQvd3M/ZXcoC4y7lBLys6xW+CUzki1uW9AU slMmCtB3q736cz8pMPHl2m/47XUVsHTQ1i3R1tWocrwcM5o5oSkGMP5r9bDyUp1zsI4sp0TzQ nfpn63yb2pvAcvmdq9p4im1ErYVDOEpaiiusbHqcJ1PqL1XY/oZ+M20oXRZUj+gUEleGp+cxg souVeqo8c8PF6bUUQXI32T1d6FOZQk6/rKJoJRjGzn99iYYQrZ1IP0p2he6XLG5qdSEU5966i jXnie0ggPftpDbbJzAlMi/BCmnuxCB07EbN+1wuEWpgZX73zVAJpSlRWtXHU5ul6Rp7OBDhWz bsjwU3w7h07VuyLheAAkulkSibc8AK0rioIaR17oA3zKiAod3ik/dV/gI0Uj9gRmrRpgfVq9g 79INSZI07sgpNGk05+YQ7uVV35pEzYqhrT420eCtDZFcVFEnUE2Rc0RL+VmLq3P8Hi7VIu/q/ /uq5YsRwhroJ0cE7fKhCuXt8MwywWQkSyMXFe5thxM60qYpYyxDeygi4g== 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 may be extended with other checks later if necessary. The new function will be called from the FBIOPUT_VSCREENINFO ioctl handler in fbmem.c, which will then return -EINVAL to the user if the new screen size is too small. Signed-off-by: Helge Deller Cc: stable@vger.kernel.org # v5.4+ --- drivers/video/fbdev/core/fbcon.c | 26 ++++++++++++++++++++++++++ include/linux/fbcon.h | 4 ++++ 2 files changed, 30 insertions(+) -- 2.35.3 diff --git a/drivers/video/fbdev/core/fbcon.c b/drivers/video/fbdev/core/fbcon.c index e162d5e753e5..e4cc4841ed7f 100644 --- a/drivers/video/fbdev/core/fbcon.c +++ b/drivers/video/fbdev/core/fbcon.c @@ -2736,6 +2736,32 @@ 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; + + if (!ops || ops->currcon < 0) + 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 || + fbcon_info_from_console(i) != info) + continue; + + if (FBCON_SWAP(var->rotate, var->xres, var->yres) < vc->vc_font.width || + FBCON_SWAP(var->rotate, var->yres, var->xres) < vc->vc_font.height) + return -EINVAL; + } + + return 0; +} +EXPORT_SYMBOL(fbcon_modechange_possible); + int fbcon_mode_deleted(struct fb_info *info, struct fb_videomode *mode) { 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 Sat Jun 25 12:25:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Helge Deller X-Patchwork-Id: 584995 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 E2012CCA479 for ; Sat, 25 Jun 2022 12:25:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232602AbiFYMZN (ORCPT ); Sat, 25 Jun 2022 08:25:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57764 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232724AbiFYMZK (ORCPT ); Sat, 25 Jun 2022 08:25:10 -0400 Received: from mout.gmx.net (mout.gmx.net [212.227.15.15]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A60091CB01 for ; Sat, 25 Jun 2022 05:25:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1656159903; bh=Wnq6p+d4InGf1wEYwUrelD14sX0XHJhP1IW1KPsYRwM=; h=X-UI-Sender-Class:From:To:Subject:Date:In-Reply-To:References; b=NW+j1aQ75KqxlsNCALZWLBxL7zNmtgc+mY1V44/K+/cQOWJ6Jy6oz2EgEL/dATLEa 0Udp9WMfkHNlHosICwsbsyiz47RtOmhbQ4snGAUx2iVLTowEYi3j1ym/amT5G+WRRN 71wW/PCAtYi9x5hOixGUViFjWNzpDmzd9TFTsrIg= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from p100.fritz.box ([92.116.162.44]) by mail.gmx.net (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1Mof5H-1nKxSY34un-00p6vw; Sat, 25 Jun 2022 14:25:03 +0200 From: Helge Deller To: linux-fbdev@vger.kernel.org, daniel.vetter@ffwll.ch, dri-devel@lists.freedesktop.org, deller@gmx.de Subject: [PATCH v2 3/4] fbmem: Fix input parameter checks for user-provided screen resolution changes Date: Sat, 25 Jun 2022 14:25:01 +0200 Message-Id: <20220625122502.68095-4-deller@gmx.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220625122502.68095-1-deller@gmx.de> References: <20220625122502.68095-1-deller@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:+NXCwtedkW7UnMcnTWz1RmraG/kMiUP51rYZeRfjHHYTKNIllcY tR9MyUPFfObHshIYx+rJsAHWBxu2zn/htbNhONqaEWB+kO5uWAt+V/Bt009BhAoo0O3sH+g 9jNhRmDLMHpvTR+EpE/+FwXeJkpxhOlu2e4Jw/EFOv4fuQI5esj5XBLEtPNy4Ko9/P3d0RI 7YAmVqq7A1PlB8iGlETXg== X-UI-Out-Filterresults: notjunk:1;V03:K0:/gZfrfcIOvY=:ZDyG0rsg7xLKq+3LE1ET1v g/npmexOg0aO4vA1bQ30/uXTM2NsxFl8XjzOsbFR91yih2y38v2qYzH841v4ubU7i4vW6C7eu 7igWul+LTZ9CrtFEBfnyRTN7UxSLu7Ng0gT7C7tNxaXGkokiWD3O2Drh0Ai33FdwDOgAoTf1b d49WxvCswQrw07dJKXXkel+quTfHL1buafx924X8QGEVY4dhU7X+Lvm+Prer/ocO3CRYHQthS 0D6RYsqe8350TbkOKiNNGrUucB9KGl3xn9Eyw8ENmleEx8JjSh9so5N/iRVCyE9w6UAmPsz4l n+MQ5ycbrFNZ97WuEMlNU+5puHMOXHSONb/xecFRle/s0fJ7q9k7+97gkbZgLMTNvDwhop4Er 1L8VafK8+9ztUYOvZ7zqu6jjwO1qMbdQAfdg7pW90/ZAVDcjCmBF/SOxKCA9kUFJCzCHqByg1 qt3Xv1wqg5kqo1vW/J9Qeb/CAjiIN1O9q192myBAKGiL1Pue+uHtk26I/SElzPAESsq41TzZo nDDn9MWtaBlPwzjJDIbD6e6bTzaHbTS01ml9LGWOSV5oLXY5Z0sANkP/LJJyPqqO6q0f5Xm11 a2hkb6imZk9u1Y8SULRZvIUfMeX8BwwTzXFUdUld1vt1u0iewEHShjqs+M8UMwxb83xbQtRs+ 2fIivXkHZTdM7U5oaMABMYzqsz4reLPa0WAj3NAsx+1RAHPGuoUAu3OcXXPNl6Kokuek8ice+ gB5AUfB0OedvSyH+8YtQkqonGZ9NKSD6X1CGlveLVkhIgF641MfBjgZP5TSZhKAn4g6Q0sh04 Q7ZWmviWeTrSft+CTYFK4iBdVqTgcy2AId7ZgLbByyRrRTrf9Mbw0HLczyqiOJ0EQ3Ny7Zwn9 h/L6Fp3op99L66yXfpLYXxzV7JJ/fhNRizAzT5z/WcoA2i5epcfqrgWJxPhDF4qRMZkID+Qe8 qeJrbnejnR0+ZwLX2oVExEr6XUbfAWm/VI/WqDRqROkL73a/0rLpw5K8VBzkIhnLsWS1C5gJE t+KEYu6SVHOAYHwydK2boXzj4vMQXaOS3KicDAv//9BJCV1TbgTYDHF8u4JOzEp9IkBRiMoqW yz5jx9XgE5X97kFqsM5/DCvX7Ch/t3GSMtVZui6Jn0uJ3EyMkzvwkuv0w== Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Enhance the checks in the FBIOPUT_VSCREENINFO ioctl handler to verify the user-provided new screen size for: a) virtual screen size >= physical screen size, and b) new screen size is bigger than currently configured console font size. Return -EINVAL on invalid input. Signed-off-by: Helge Deller Cc: stable@vger.kernel.org # v5.4+ --- drivers/video/fbdev/core/fbmem.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) -- 2.35.3 diff --git a/drivers/video/fbdev/core/fbmem.c b/drivers/video/fbdev/core/fbmem.c index afa2863670f3..50fb66b954d6 100644 --- a/drivers/video/fbdev/core/fbmem.c +++ b/drivers/video/fbdev/core/fbmem.c @@ -1106,7 +1106,13 @@ 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); + if (var.xres_virtual < var.xres || + var.yres_virtual < var.yres) + ret = -EINVAL; + if (!ret) + 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); From patchwork Sat Jun 25 12:25:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Helge Deller X-Patchwork-Id: 584996 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 621D3C43334 for ; Sat, 25 Jun 2022 12:25:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232944AbiFYMZM (ORCPT ); Sat, 25 Jun 2022 08:25:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57766 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232602AbiFYMZK (ORCPT ); Sat, 25 Jun 2022 08:25:10 -0400 Received: from mout.gmx.net (mout.gmx.net [212.227.15.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B04861E3CD for ; Sat, 25 Jun 2022 05:25:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1656159904; bh=XzWlqKg0tZRmkyyhAvOskP/AntTF8gQ4y3i07JTitN0=; h=X-UI-Sender-Class:From:To:Subject:Date:In-Reply-To:References; b=Wr7PGcBvGrftl27TdTYgD4sB1GXS4scvf+MKOVNTny3VJP0xPekV3HiEmKec73DOV 9Lo+3M8ABdGrds+AohjfpeuNyixW+hNhxVmbTa+JS0zgOJ0UNcu6GuIN43EW7GLjBV 4ADJOk0ByrfAaPNFZyxqVCx6IfT5BAv3htk7G4Qc= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from p100.fritz.box ([92.116.162.44]) by mail.gmx.net (mrgmx005 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MnakR-1nM4za3cCz-00ja5s; Sat, 25 Jun 2022 14:25:03 +0200 From: Helge Deller To: linux-fbdev@vger.kernel.org, daniel.vetter@ffwll.ch, dri-devel@lists.freedesktop.org, deller@gmx.de Subject: [PATCH v2 4/4] fbmem: Catch possible driver bugs regarding too small virtual screen size Date: Sat, 25 Jun 2022 14:25:02 +0200 Message-Id: <20220625122502.68095-5-deller@gmx.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220625122502.68095-1-deller@gmx.de> References: <20220625122502.68095-1-deller@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:W8cNngBMUBHHJUV7dXjFa42WjdXUhH2wea0EeF11rpP1tPAtcrj Vy4tmjTNURbq+eTLhYSJ3RbTSUqWcUOiJh6tMT8hIxIdAt+3g0UBYjPfsRHg+/1Jfvt6uSz tkKkaHPi3xNpb4hamxPTSKlGbLRmYfthkj0i72290nt7jfNHaTATIMH4bWHxHhjVPpEvCEP AKwv6u3Wv3lMQkKJHJsMA== X-UI-Out-Filterresults: notjunk:1;V03:K0:j0Cb/1I6yu4=:kKTYRcbYUs3HdoMx5WWEa9 PWTco1Zyie4e+8SCPHs7CfcbBKjiYeXfSiyuRZwqzSUXYBPKn+P4XMedgrbVbzx5sifvqZ4qT zs0guonrV/KGovkhFUlEP+ztrTYlqQODHsLqHImFx/151dDjauIpWizL471bVqUeLW/SnlZh6 RuFIatAIRoMkKxGEoKICfNV/EUL0P8MEQ7TNDQ1G+dojcBmxUSbWSQFUz+cx0u4ia2DPQRiiW 02I+/vZZCqmMUkb9i1ueAIY9LjARrAdSwTdyb4W6M8uCtg4CaIQfjtcXV8lx39lez1I2lYq08 C+KEnB+yk9tUVJ/FSn1ajoVXeJnXswos/BY+mjBdE3CBiZmPjb75NLbYWSu/0XeTiAz2tv8vS xm6l28aj0WyDSIhMcb+d6n6pWCq73CwATDnpq+FUS+X+8IJLSuRxSK5skIB3Dz3bIzRT7Q0sA /nlsd7a0XHhFOYglzzQ8fO7aRHftjDojl8HOKNFpyd99YGibUdYbogYkGejd7P/6PHaglxyCd g6N4AARSvp6lDOdH8nZTf1vkmhjU6SDeq2E2g+Mq4oNH02GzeBGyXXg1TbVZG1cNds54xoTtg J9P5HAOgSi5HQbP86inBoEfhHWhAP38R9uKHcroXAc63W1EdM8cPn7dN04WWyfR+P6yfE2yPX 0qdDK1FS+KcLlVeznK0LkpnzFltXUSz6E8tsMnLTQcbUCIXM3XX1vmE2q5mti26kn6u4oyL/n 5OaB4zD97mr7GuzJoWQAKSac/7cn6NFxaxAxMd0QMs+YyQxI8nNd1LwZD5bV7zYLjzbEFPrRe YHFffqT+1AxFrNWYeRXPpVO0lH8W/NTTUSdJPye5nUpyQY245VXYCmT7HIH07U7STPeJS6NJf dE4LdiB74KhARZVo9Nv1LIC7P8/MNV0QcZcNIFfEVzM7QNKpu/A5/xsJbURiWfjZqRY7Fl/1G h2+wn+frd5qJIaDnJDC/yGTljlPtPfKWT+LYqqyrNMsu6k8lIaF2EAFtn7Xt6yJ+ITK4TSd8Q 8V7RzQzK2is6145W5N7eA7Opk0Tab0mVS83NXmLep6rrHxHYqs99X4SdRURfnqUbfzSfpcM6S F5MV6LrRZH1GiVa9O/njI+G76d03bIV+fwNLv4ha9TZTusRXjlP2TwmCQ== Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Make sure that we catch, report and fix up fbdev and drm graphic drivers which got the virtual screen resolution smaller than the physical screen resolution. Signed-off-by: Helge Deller Cc: stable@vger.kernel.org # v5.4+ --- drivers/video/fbdev/core/fbmem.c | 6 ++++++ 1 file changed, 6 insertions(+) -- 2.35.3 diff --git a/drivers/video/fbdev/core/fbmem.c b/drivers/video/fbdev/core/fbmem.c index 50fb66b954d6..6d262e341023 100644 --- a/drivers/video/fbdev/core/fbmem.c +++ b/drivers/video/fbdev/core/fbmem.c @@ -1006,6 +1006,12 @@ fb_set_var(struct fb_info *info, struct fb_var_screeninfo *var) if (var->xres < 8 || var->yres < 8) return -EINVAL; + /* make sure virtual resolution >= physical resolution */ + if (WARN_ON(var->xres_virtual < var->xres)) + var->xres_virtual = var->xres; + if (WARN_ON(var->yres_virtual < var->yres)) + var->yres_virtual = var->yres; + /* Too huge resolution causes multiplication overflow. */ if (check_mul_overflow(var->xres, var->yres, &unused) || check_mul_overflow(var->xres_virtual, var->yres_virtual, &unused))