From patchwork Wed Jul 6 15:02: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: 12908212 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BB403C43334 for ; Wed, 6 Jul 2022 15:03:12 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 939F1113E37; Wed, 6 Jul 2022 15:03:02 +0000 (UTC) Received: from mout.gmx.net (mout.gmx.net [212.227.17.22]) by gabe.freedesktop.org (Postfix) with ESMTPS id 986451136C4 for ; Wed, 6 Jul 2022 15:02:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1657119774; bh=rQmS4yIj+Kq0oK+U8Ryv32tYGBvhOaSYofJZQWpZKAg=; h=X-UI-Sender-Class:From:To:Subject:Date:In-Reply-To:References; b=A+/0m88zrK6qAQaR6+7pIQQl2Y215QcZPWHe5boyZ6Uhh+WC4eQ2EXGwf5SD8EUbg 5SHbuFc8RvoYxZDVF9JPNNFhmJY3Mr0iD9tfzKXpizWlPT02sT+fve+82Inr4SnfnJ 34kkCRR2Q4Iqe7aMHbXrO+z/duaEFoOP+0D00XDE= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from p100.fritz.box ([92.116.134.81]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MrhUK-1nlqck3BAq-00nfeK; Wed, 06 Jul 2022 17:02:54 +0200 From: Helge Deller To: linux-fbdev@vger.kernel.org, daniel.vetter@ffwll.ch, dri-devel@lists.freedesktop.org, geert@linux-m68k.org Subject: [PATCH v3 1/4] fbcon: Disallow setting font bigger than screen size Date: Wed, 6 Jul 2022 17:02:50 +0200 Message-Id: <20220706150253.2186-2-deller@gmx.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220706150253.2186-1-deller@gmx.de> References: <20220706150253.2186-1-deller@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:oShNuyil0feMp05hW2usMgSVD8rYb4p7RsxBj5uoROaM4CEahi2 ObJSydSfqHH9gpBYSMpoHZ81lxTTlZXIjj0QZfiBnOClixGqysk4XfH8A4kkjFRuwddzltb cPCfeTRJpdMCW8dKifc/BTiW06FhPKOj14TaOZbN9OGVaBi4pCrTuEovbV0iAuoPZh4WH31 MuFku7YedEI6j0GwQRnLQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:inpeYIvy66s=:wOGmewbp7/ITwMjRoMhaDq UYND07/RmKGB/2fbsIeNJ29LYTpM9Bf2AIEcuTJPCkXITcAUaFcA4Zos68L+oKO/NylOr9ydm EKcmYClfpLatQ4kEnq0gP7CWqOCs0cKtGi+96i1+vCqzj8zzNM/MvVLY0L6Fnyklswk2seDzg d15rkIFG1SmkMFqTrGxlLJEDx83kZgb4JKNs2TZC/gNqdm5I1G7+nl9E/Tmkq2MYfBWZtfy4l yw5Tn9XMLdBejacOktrsw4k9eeAGAdNv2LLS2c/VrVrNdKz0nYyn5wziYQGsWLB2SW5UNc9X7 NFb0JdFg6DZPlmYdoaGNVXHeJ0JsRCsSNtLUl+Yv07viH08LaqOxVHMHqWrnCdWLCSAOxlfQf JORWtQIWLehGCdw3vaEthVcLH3ZeGZVttaJt2rHlz+yW1kUv4OkLdecWLibpO7h42CNa3bE0k auOffFoZ+LsQTSVufg6xvYB9v2283lL8hcrt7NVu6L0rdtTlvVEaxPAPbimBB03ATme95KP5Y wpzGlm0qzJlyhH37BGt1P5QEoJZn9DCVi8dFVFcaMoVeSdFQubF2HOW0aJ2MWOg7rbk395Cq+ ocWoHyA1izw/VFzVAbXIWKdWNKNTh5PyWXUgsdw9y1J10d85KtwgptY8MVp3XW1mKnbeFB+u3 VsN/z6t+OxN7uE6BRup3GdxxhuNPDQeHmLu7h8pgRRS/mYWq2tuwDLWNmI6zP0O2+vhp97JlB xUw/DTfqMkTWl3Ej2sYwUdv91PqexzmLNUuBipXInzdwEy7WWV5o2QPw4YFQm4G3pQaQL5KQw M6mqwkQdbKLVssEOc6BWRpLKAV2ysGTbNXnvbjyrzABmnJ+7XJmWQ2ZInmnqblFpXISv5CnNz Mxw9g5lHVZclRYO46rqiTa7seDse0mBj3v41Pij1e/YWeT3vb6JdU7hIW8lKUBa2GgC2cw0tI WIp9KaJwhZ84tXMk4HkF0+9OOm7BH2xSvtWM/jvanQvG1HvTBc0PMLSMYAIXccKUYc4idGFTL IqwJdS5Vw5Hc29K3oSjOLY+rCIx+by/gyi71fXT88BDwTMSyZAoIAq39LiEu5wg1KKMxWFxSw Yt9lZzmxhcyOa48XBm0qOL4Ax222IOG3wz/CC/UcHSQIFe/FoyptyEZtA== X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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 Wed Jul 6 15:02: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: 12908209 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 98B7BC433EF for ; Wed, 6 Jul 2022 15:03:01 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2546E113AC0; Wed, 6 Jul 2022 15:03:00 +0000 (UTC) Received: from mout.gmx.net (mout.gmx.net [212.227.17.22]) by gabe.freedesktop.org (Postfix) with ESMTPS id C6E4E113A0D for ; Wed, 6 Jul 2022 15:02:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1657119775; bh=aAI6MGei57ToZnfqLXmEk6O8X9Iu9nKAw4TPGrJ+zZw=; h=X-UI-Sender-Class:From:To:Subject:Date:In-Reply-To:References; b=UQXCk9VOh8MC38U13YmRH+oDLIyYbYMoekcu6/SxDmxCsto16359rHFgfHUYYGTv3 AdHyP55AmuY1Iq+YJz5odwDHBy4reKbKzcpUMNfmer9cGd6pItwHE+QM1WMTxqjV82 awr8vZNX5y2suon5GUj6b9t5uH9AI6X/mso40CfQ= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from p100.fritz.box ([92.116.134.81]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MUosT-1o04A33uEr-00QngL; Wed, 06 Jul 2022 17:02:55 +0200 From: Helge Deller To: linux-fbdev@vger.kernel.org, daniel.vetter@ffwll.ch, dri-devel@lists.freedesktop.org, geert@linux-m68k.org Subject: [PATCH v3 2/4] fbcon: Prevent that screen size is smaller than font size Date: Wed, 6 Jul 2022 17:02:51 +0200 Message-Id: <20220706150253.2186-3-deller@gmx.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220706150253.2186-1-deller@gmx.de> References: <20220706150253.2186-1-deller@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:l9wU75eBVCDkKqJs43pST5O/nc3vpHLDYyS4OlJ07y+DJXOGTUL mpIrzg2dP4h6jSvvWS3Ne/TMB0tGRZ4ljuHN9zVQULfvEGhiVHlvG+6GFtDynQN5Cb8DIKx 3ytIk0BCdhCRO0Z3xrbPEDaVPvbiC9qjTvXGzFhTVAFINLlSEjrIv5YcbvACVtbD7O9F6JN RgQEg6eyqAUapMdt3wubQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:totCYmyAkIs=:vWWIR74FuHGdFURhBJcwPf gu/sd0u5bz7wTzfK9r0GS87wvaU+CQ/ueO6ru9yDZ5gS5rDg3gOE6Q/sfN7yNXqc/4sajL4Vd SwxGTr6kAzajx4aPxssuqL4YY7neV8S5MhI+VHxnzB8/CFKoHoAw4JFMwCgO4IkwblBAM6260 dbxBnCPw5sP/Ay98SXSrjyjg6ToUPPLXGY9wziKIeEVBOfLOPIN3MpjKo0n75hhNJe8pV1fx5 cfTS0vR9sLcvrXiuEUViqkCduEAGYHkwOJmQyUZLKOPFKJze2ZjByHc641N+rpLC6H3dC6nfs DbDlwP59aeJENf8XbZTk1XdwOnLMzYcVQN/4OAdpwd9Tu/6ysVhvS0YzaF1HZG38KsEWv6sci j967a9HdQLKKdOxt4rXmAXGE6IrmrbBIBoRXJLnDBO69WSCjoIlWpU1MmUMqE5NQT/UA7S8q7 oCjnFPBz5ZkFDQR5p5ucVh2136EUK0M9vXPEJnKMY+cZyrZ28WbQ78Og6EeMSndpyjTrJfzTn hVPKOD0N+0xMTL/tKm40Hf7QKPzZT0fsIk2/Y/tJgfqbGR83LfJ8jkvQ2MQUt7aoPOoTYSzwz NKDD6C78o/lcEKgSVFJv/xLdNObqkxOf4fuY1Kf5R6F0yFG60L1J/8WJ+c4t46gZOXan4oeGH SKrVct0nvpap/hwGPlmJpXXkepAXk/wArpvX7sjlsTLtES2VVSoxb3e/hlKBYqHMqnYD5pSWY DPpc2waJeHVCVthrdYODy8UaMlVbPWbFWUhsafavTgEGDbnwAbV/vV4oK2pCIYvL53ufFsWgk VBhTb7O9JuWnDazDSe7WxIs47kxhaZe9sbk0/SBvhNuIGTUm/EfM417jBfqR3CBJvBDC1tzFa 2xH9al8OVXvmZqCRqJK2+v1p5yxX/WV97QHO0Fq8UJpVCzpkXg3UqKNH/BZ/VTjlCbp0hBZWX ePX4X7qaWNZd/bl2/MeH4nuijqlK//jzVV8YKxw6KyzaRaBBXxOud7OfuZ99f++6bkryBHqaE m1Vy+bRrSpm2DHAeCYtcl9zAoicQOqG2Y0TcdYgpE/agUi+Rkmw0/IHbAIKV3wBx3MNT8oNL6 2SqN39t6iIm1VtIG3yXbRxEz4GyxrwyHDA00wl3tlbMG8I90hSBBwrpaw== X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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+ Reviewed-by: Geert Uytterhoeven --- 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..5632870a9aeb 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; + unsigned int i; + + WARN_CONSOLE_UNLOCKED(); + + if (!ops) + return 0; + + /* 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_GPL(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 Wed Jul 6 15:02: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: 12908211 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 319C1C43334 for ; Wed, 6 Jul 2022 15:03:10 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 989B2113BD0; Wed, 6 Jul 2022 15:03:00 +0000 (UTC) Received: from mout.gmx.net (mout.gmx.net [212.227.17.22]) by gabe.freedesktop.org (Postfix) with ESMTPS id C8583113AC0 for ; Wed, 6 Jul 2022 15:02:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1657119775; bh=6nsnIbuD9mZnFTibCiOIJDiwvadf42q5xse7Z+WoK+w=; h=X-UI-Sender-Class:From:To:Subject:Date:In-Reply-To:References; b=ZapLm0vicn4SVzDEw3UV7LyGEnaPRP6H63+h36gNmsZT3NEB0kWsrSU1UkBDYcSzf EeCi9rBX9yqT17O6w8NWYmFuTz6V7qsqhLql2sktPtJK/lsb3u/QTxUdVs0LnHYYEF CtRAddwhemib80NC/bIFWBMHZmTbtlELuiMTAj68= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from p100.fritz.box ([92.116.134.81]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MdebB-1nZUoo0QL3-00ZdQ5; Wed, 06 Jul 2022 17:02:55 +0200 From: Helge Deller To: linux-fbdev@vger.kernel.org, daniel.vetter@ffwll.ch, dri-devel@lists.freedesktop.org, geert@linux-m68k.org Subject: [PATCH v3 3/4] fbmem: Check virtual screen sizes in fb_set_var() Date: Wed, 6 Jul 2022 17:02:52 +0200 Message-Id: <20220706150253.2186-4-deller@gmx.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220706150253.2186-1-deller@gmx.de> References: <20220706150253.2186-1-deller@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:SeCxky1SgBlGsDaUf6IAO5Vr8QY9AvIeAgdpQnv+NitNwtnCvfK C2ypOOAjGFp+lxWEH7bdu49Nz5BXPeOKQHQ2YdT9D/qPI6aYgWfgj8UNxLtCNVfPPCeL2nd agWNHhoKQAdWyJ1g67+KEmPnhp43bbqmWEMtvyfz3/XtWaLTMdhPMs0QC/3Ls7tGJWe3Ta5 KlmG8RZ4iWzveNVfT0RPg== X-UI-Out-Filterresults: notjunk:1;V03:K0:vxGlGaAHhZg=:dxsQ30NaMFZl6soXcCcAY8 hwHw0JmTZRfrrzZoUpiYORDcW9FoMuNvEipdUOD4Rn+OIOkn8p8e3RPOp3NDmWFKfHJ/Bdp2W v2qCSXcooGam7Z3gWZxQ8C23sIAFbQbdeQVXaE2oj0aUMbzNB7Mml2PGME7rgJoXagHMnPeBB St/YgRHRKlFehQ6xBVHZ56tRVJyZQwKoqSqOzBcyprBJvMhm2HSpszw0EeagZ6K0zlW0pg83e xp2e1haBDy8Se5x/F0iZEKbVA5Qpskz5kMVoiD5twU+xqnTWN+SvagetF6U6EIpIqh9ZK+JI4 UrOJdxdCLi6sj3tYG3DnHHuGfM4aanUJ4B2bSL02ffvzUiF7GWchKUBg+9rmZ9NSDulR7Mexg 0M1S4y8lZsSTX10CFs0H2xkARAa6ItIiS9K2dr7gfN5KSIyTc+4j4MYiAPNQnPQ1Y8Pbpx7/X wAzxeUBUBe9boHnw7Wdbruv0GLqP/66nZOiO+PGoRTOiDqskCb/uQf+/4De9IS9iNFBGWClu/ SmYxduRSXxDvREfi83t5jVrWB01JWqwtWjeqQMFbRjRENBvHF73QSF3hlHO7FdOcz+M5tjYil bC/xErCr8ebkZFWVCTUAQYLsJ6RdNrLoTX3XUuy/G0kXubae01ugAnQZuvvmMi44720UzfOEF n43WdaaG09u2aZHd6ZOLyyXaD3IbK0u75nx9S73d3/n6VwitCEBteuWpWmnnpjQROP1GKOIYl UNNYeRO1tBNZ6Ll4vxb7AW5SsQBYKzE0ujNtyY4lIRj1ILKTK3SzRjWssQDWhqrQSqfL2VmTt iOlzzMhAc2ymuLortl8qO1NaH+HtNS3VtCaR5iGeBJtXURcVBeDAcRlmlX5u5XJ6XEmUQSlWY P8NCARBln+wsScLCFnijF+H32slvPNExSAmUm5pkYSkAkx7H0isinmGG2A742l2/Wq9oTecmw ruG4Iovtnn8KTTXt5fJhmnVaFR0kMiehEw/J8HG+4hFj2rhI4Y5776MH8ThA9z5HpEp+YFgge mQHSCRvqwExYPn7WKJiFAQtChYtMmucueYx6cd0rCZQ9jcykpOEeMeW9rAg2/nFx2W8YGNMTE mobmSZFhUXzfT6AsNxVr/Z4JbK3Hxs5VoUAAfcYkU1W7ZIRmDjMWR2+AA== X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Verify that the fbdev or drm driver correctly adjusted the virtual screen sizes. On failure report the failing driver and reject the screen size change. Signed-off-by: Helge Deller Cc: stable@vger.kernel.org # v5.4+ Reviewed-by: Geert Uytterhoeven --- drivers/video/fbdev/core/fbmem.c | 11 +++++++++++ 1 file changed, 11 insertions(+) -- 2.35.3 diff --git a/drivers/video/fbdev/core/fbmem.c b/drivers/video/fbdev/core/fbmem.c index 160389365a36..612b54c23ac7 100644 --- a/drivers/video/fbdev/core/fbmem.c +++ b/drivers/video/fbdev/core/fbmem.c @@ -1016,6 +1016,17 @@ fb_set_var(struct fb_info *info, struct fb_var_screeninfo *var) if (ret) return ret; + /* verify that virtual resolution >= physical resolution */ + if (var->xres_virtual < var->xres || + var->yres_virtual < var->yres) { + pr_warn("WARNING: fbcon: Driver '%s' missed to adjust virtual" + " screen size (%dx%d vs. %dx%d)\n", + info->fix.id, + var->xres_virtual, var->yres_virtual, + var->xres, var->yres); + return -EINVAL; + } + if ((var->activate & FB_ACTIVATE_MASK) != FB_ACTIVATE_NOW) return 0; From patchwork Wed Jul 6 15:02:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Helge Deller X-Patchwork-Id: 12908213 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D5DBEC43334 for ; Wed, 6 Jul 2022 15:03:14 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8807A11A09B; Wed, 6 Jul 2022 15:03:04 +0000 (UTC) Received: from mout.gmx.net (mout.gmx.net [212.227.17.22]) by gabe.freedesktop.org (Postfix) with ESMTPS id C77EB113AA6 for ; Wed, 6 Jul 2022 15:02:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1657119775; bh=GW3DuzvuRwI9vrVmC4KBb72tQNP4bGts663a3KHyz1E=; h=X-UI-Sender-Class:From:To:Subject:Date:In-Reply-To:References; b=jH9/YzGPaAQs+tsZZ8+r+xjhooK8hqOEe8lnkh5xAOUlP5h3eb6MYq2PQHcghJQgY dbHnrJMqCZC/0Hwvimt0gdBY52AvmFS/7+iA/vkdc9Z2qU/YsBHSaHrM3GdYqGTuHw hsFYZ85gnP57ZjSdomJqmKjdgXav+IokXoXmPcoU= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from p100.fritz.box ([92.116.134.81]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1N3bSt-1nRHdk18aJ-010gSt; Wed, 06 Jul 2022 17:02:55 +0200 From: Helge Deller To: linux-fbdev@vger.kernel.org, daniel.vetter@ffwll.ch, dri-devel@lists.freedesktop.org, geert@linux-m68k.org Subject: [PATCH v3 4/4] fbcon: Use fbcon_info_from_console() in fbcon_modechange_possible() Date: Wed, 6 Jul 2022 17:02:53 +0200 Message-Id: <20220706150253.2186-5-deller@gmx.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220706150253.2186-1-deller@gmx.de> References: <20220706150253.2186-1-deller@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:rUXKDA1xr8he6K5j9xAxoe7qDkUxoxuinplCAnha+ol3fcZKoNA KZFd2GNFt4m2nT3+Fjti3DIC0M4sVCkMtd5MQa2lb7y7nCxmXgDg3M/as2E2UbcJaPbABJt /j96dX3Jv2oE+XnVdYgc8GcinxTo/NVSex9GjD5JP1SnF+WPjJELkg9qkTFsmWyfNV2w3ln nwRN09sIKCPFgpPhB/mYQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:EdIxMJLWgBk=:M9O/jsXDnOyzwBMYog6RLv y7+AAgmBZYIcokNw1zmVZT05NsgRYCu18tfCv4Omt8sScQI03EKYe03fLvAHznzEoUz48Z6SG sgMgJ7asdKlNnffO022fOadrZfEy93zj6VlEtIohvR5wXYI9cScVfdwpKeYB0WRJtnjYoG8vf jwqDvRq5R71j4cIji61EkB8bBVfnCWdyKkVQNGFOU7kg8fjnoFWWGvX7wtu/GeTnwYMxxDYGv yYm6QyTEuWfDEzOt8a2l9A+7ej5M2eXnKMdRGfAm5TLDw0EOqc2Q3BOIRa3eu7LJDakycu+nR 9DZOcaqzScegmvAQzUpHIxAcMVx9Nb2DEuv0gVD9HgQhgnYrxjNH3vYz2F2H2LeXL/ALbe6oM 0b0uV+99x8V+vlPGbj89WkDOC78T6EIZYcpHoYLPChQVN3Sh+X3+ljaAmeiu/kOUqTiVHrL4q W3mhzrUpsuXcrsorL9uqA4ukRwm2iQKAah1mw89vU5qcGTRRkgAn/R3rqTVItY416cM/4gvdf dvyP5Or8KtKkUDt8/lZtBTSdOBZdMqd0894MglP7Wgp30I8L9/b/ETChv+EVfzoYM8Af+o+s5 32yT8BIjmEyQVxfSBJNX1nQUJwx1Z6ffIA37VcU7+yOLGuwjZP1IUpCfp8FWVSbQG+c7lEeFa hN0S5uhz+QUx04eKJbQIuvfJVSJg2taBFTXDIGkSca5Rd+ygL8RWRrGXmto55ZwQII4Y+CGBB tBeHVBcJCYCAyPSwzKsZbpSOIiY83z+LIYwS3rykKdgSKdqRo6+VpVLo3Qhsv4MYgM0DFqLm8 kY5Y22fpIsnS26LmEcp7CgHStQaN5FUKtwV56qLRGQzIa9OAnHCp5ROGxGUJhYG5k7S8z14hY OApXbrXzxuBTnc+k/JsDswqZ8aAd9QrUb8F+FHay3g5X655lEgIkKaqfdS3wJbR8r94xcCTTf ox3v/ZY+fGHSqlTa7QRVEKDs5HWWfSvuoSOuI7LimYpO2e4jNu7EGCvdmhafqZpSut/IRmb0U 8qkrgx6VInZg5w1Q5aZZZsiymSZUkUa7klL8ELYBY7o8TilFEiNrgrumz1hekjWtbHM+cr9Pj sh4HTCM6WI+t1SMXv/YQQofMhIddk2QREn6qn9V0AXHX3ns+vpij/S17w== X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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 5632870a9aeb..1a9aa12cf886 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) ||