From patchwork Sun Jun 26 10:28: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: 12895683 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 E0F4BCCA482 for ; Sun, 26 Jun 2022 10:29:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230287AbiFZK3E (ORCPT ); Sun, 26 Jun 2022 06:29:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56860 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234198AbiFZK3B (ORCPT ); Sun, 26 Jun 2022 06:29:01 -0400 Received: from mout.gmx.net (mout.gmx.net [212.227.17.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F3D7E12614 for ; Sun, 26 Jun 2022 03:28:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1656239334; bh=tRqvkgP3s46IORRaOk1LZP5YQEeJ21rrrTXuUbKXSvE=; h=X-UI-Sender-Class:From:To:Subject:Date:In-Reply-To:References; b=Ra4rSnpZuBPKt0T+7+ep/XhqMxDoRbM4V/Fg2Hk9Hb+pCwm8P1wuKLop5B+hs5M8N sqYgms3IQreRxyTEcwFugI3pi5D/woXoxW0S37/fv6KmTW2k+14l933+3XQEZG+0kV txVMvo2EnD+7iOCuJiox9D9I6cH8WBuUiFbAxA5Q= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from p100.fritz.box ([92.116.135.166]) by mail.gmx.net (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1N7i8Y-1nbJnY1P2Q-014iK5; Sun, 26 Jun 2022 12:28:54 +0200 From: Helge Deller To: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, daniel.vetter@ffwll.ch Subject: [PATCH v6 1/4] fbcon: Disallow setting font bigger than screen size Date: Sun, 26 Jun 2022 12:28:50 +0200 Message-Id: <20220626102853.124108-2-deller@gmx.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220626102853.124108-1-deller@gmx.de> References: <20220626102853.124108-1-deller@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:YXfT7zBTXoZauOHSIJJTtz7WrDgEiNujTauyUxlFXnplbel6KY9 qYSqgWRSCpaiSZYIKE0Srf7hWVaUmMcKPPzmZgWL6UAR9v08TBXUVvrlSbVjYUuRx4kMORx K1oNsa8HaAwRuSmnyTnK1ozRnDlioAFxB+benIFiFaDtrjQMGevrBoWbN4bpC3I4gySLlSC IieF65HOrcXL/9fD8ewzg== X-UI-Out-Filterresults: notjunk:1;V03:K0:Fx/Iaz5Kofw=:K+AO7X+mA3SPcSwVthCBkV bx4etJAUsgLfxTe4eiO6ST5BA/DXYwyKoCSY2GfLpcPfhIvkZpBCt9pduPWLlTiND/yC/O2gp FzzFAjBuX/rUggohoWiq+LlmngSbg6k30HpaocrItsj+V0C2ZQX7huB+LkQwpld9mKNITrn1V l13yyTPLoib02OOOVvR5LfeanFP3svyQ7w3skAOBlckW28YcIgNBeKdOmD0QWQH4mtcLzx+3r m6Zb1AtG6fVMAbYGPRV+ktPEUnAnZBymLUSpBaYU+2k0y9v0hZ9OAD55KlzYRPuEhbRkV83ni fbVYb1c4dKNdIcE9stOg+QRNwRdeq9uag2JJc1+gS5I68ykYylOdyaos2ytVUqKPMQ+hMcPg5 6itZMi8iCK4H0MKc0Q6UWU2Br6rgjkGj7n2VlYiaZc5bTiwndKIWD1WlvaFSqyHmTJPtBdiUV FYsl73+FRVVgHWgW5MsVlaZtRXhDMycL7Idlak4x0GdZ7w4fyqPMYbeumKL78eRSFga8HeXHv Wf/xCluhU5KNSaMaexj1fjbJMCpBcRkM6jdpiDFJ5z4F7my/jBRF9IKQ20rF0D2AjbbKyG70n W5yfnV3fE9dyI0XPmW/b8hUS5x4mphHcUdkjYoICCHe/J0Jk/Ytv6ffetFwt6vNkkgtA2ED97 pMvstDWNMpWy2V/halSMhUatgEPA5GaMIKfJsYJf6HSTtY08mqfPPavfeWMswf4Sk/52MAg1N 1p6qsXNxzqWj+egeawklnA6vv9GplGEpkp2+EpmZV0QH9nv+6dT/AbS0ygqgjQUpWlTOuJTAr vO30CtvgwJsId5lWJzP8Uym/Toc7A0O9nNlVPdxu39xVDAxPrTV8RoWuEVRtk1DZxyekQlA1Q pjHRhIW+O9SOaqeG3tjyTko4y1UWlBdaheZoXB01sUj0lNxmDmADnLQzOGfm5rxFvTtQF1R4d fNxozEMFx99Z1X+w0TBOsuEvLJIt6LtOAB+ssM2tW7Y9HUiPbUL1mlq5O073GuDYjKTzOH1im MhXeeyLLu0OYsvl65gWe95lL/LPL9ZgA/FXZo5l9ewNHM28ERiY/S4NXEu8BigTtLNj6B0O8T stvhqMYzLKp1AHtSJT0V3BJMjDmt+ZUD/oIrdLS4azuvfMX2eiQqgCt8A== 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 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 Sun Jun 26 10:28: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: 12895680 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 B6677CCA47C for ; Sun, 26 Jun 2022 10:29:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234197AbiFZK3B (ORCPT ); Sun, 26 Jun 2022 06:29:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56830 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229565AbiFZK3A (ORCPT ); Sun, 26 Jun 2022 06:29:00 -0400 Received: from mout.gmx.net (mout.gmx.net [212.227.17.22]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E692D11C1F for ; Sun, 26 Jun 2022 03:28:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1656239334; bh=j6RW8ENNf5nsY/5nr46mKXkS2nQvtyKcQa5Jw27h/EY=; h=X-UI-Sender-Class:From:To:Subject:Date:In-Reply-To:References; b=gdC7CsUxlJWA4JVIObkzh6DyRIu4/gbv2MvLkvMnECxKyCnDYF8tVcurK4Auh1gbF SuYYPM/jiOet8g8AQbRdcDlCHkFCnw3kj28NLuZpivwnqeFpDuYfvIWm2dqgXretAS K1e0jlJnSvaatGdPzoYe2eISxeB01ExcKJcXCsMc= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from p100.fritz.box ([92.116.135.166]) by mail.gmx.net (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MhU9j-1nSlF71viF-00egyi; Sun, 26 Jun 2022 12:28:54 +0200 From: Helge Deller To: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, daniel.vetter@ffwll.ch Subject: [PATCH v6 2/4] fbmem: Prevent invalid virtual screen sizes Date: Sun, 26 Jun 2022 12:28:51 +0200 Message-Id: <20220626102853.124108-3-deller@gmx.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220626102853.124108-1-deller@gmx.de> References: <20220626102853.124108-1-deller@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:n5URlIHOFY7d2NEdKov4I9Kd6OV7R+J8BJVzbPUlME0OTNKYRH4 hPNdYn0EIERu7zSTAcno9eGSCqHmuqG+/JLi/EXlz9MVMMALyEQWQUtDvoLvKZsgROLPqui XEFmS6ggtGqtGm/0Bayfed06WVuGk7mzz6LDwUighkkzKClseUlBmB+ksQv7wHTblUMRvcj WY7r3t9WBpy1EQntiGERg== X-UI-Out-Filterresults: notjunk:1;V03:K0:OwgMb80HTNE=:rc4lA6kA80/hFrHtJAKOfq Erbotzd+0RQd6nqYPIFm6ize8Hv/9tiz/PtKgxDdnQjfb8w2jDK3ty2WoSJqIHgyTeSeh1JKM AHGj6ZdXUtrAUEybqwiBaxB2iVsIduSL0cLDPsXkbg9O7zReQ8bl3KU/MfDEdiVWY3gaMVw5k T5XAhFRCZD7C+QhdRrceXbF5jh0KlAarT53NmyhSW1MKOTRRTeYRw0012LpZrAmKxm2yy2uNn jAJYPKCh7Ub7RE2ETfOnUdME7RYGE+oycjDRbWxsPIms7BhnX3DAOBENsm6zu2JPQLK7haxo1 oIbdh8pUN60k5ps27PmKSio7DCKEJnbEE3MIlaXMk8R1nQUJZ3KbSm6pHkPh18lyoThadGpep xPjYFlnXf6dHH05+GdWusJQscOCriZuUnFrQc+Cb5ahJFNAZwoAm/86Qa8GNEiHqz/xU66k2w DpqDF1PI4KEjMY74fdcgwHvfKfFoMc+U4EmXKbrma3NzNi11Zj97i/cYUq4Hcxrgc/GcQvwE/ iqvlUt4P61PxLyb5PQ+wGRA+z+WX2WsU5LWrwEQahIOqZcmTzk5oid7jHy8ca3TxVWxlYa9B7 9fK6NtceCdHYVrWuyKmwYVbc47u6riH8FZw9IG52s1Ect14ygDVb8Rl1uReNtvsihs7xGWaQL MNGi091doEresePyXhze5XNmZyLBsYWXs1NN5TCTSrBVxPr4nbfQhfvX4Jn15H+18CEDjsYvn KGDzu63UWFMObkCaLHFY3JaEjl5nZ4LnYfdsqHrGTNMpyV8pmn5KiRZD8FHDm2xws3VO7ezNa W0XLaUmlKl5WiSIDXFPl9InK6UeZY0xPF10Wl4KPsDg3z63v+BtfGiQwbBTNpyu3fuOQQOaNa 1L2BBprqEEQy4qXy8oAhF144BNNCVgO01Wl2JINAmFLrSwgnHEjhNhGKPe1sYXQW4mFXxID1g WkowOwWb/uVLZRZqYQd7D4HHOOfs5dKt5qxGap30EjqsNZHMQqjTr0FuPAIlWbJbyuAHRAXRN /MZ1ZASikZueVEDj0RnbxD02EZ1fANoFLk2WjIb/RPA9WjerV2A2Io9xviPbuZMA9lps4uX1n Gso+mo4ogrm9B4vANqNPnLuloiMhLC/VTCJWqdHm2+VHWd9dLd+noQ72Q== Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Prevent that drivers or the user sets the virtual screen resolution smaller than the physical screen resolution. This is important, because otherwise we may access memory outside of the graphics memory area. Signed-off-by: Helge Deller Reviewed-by: Daniel Vetter 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 afa2863670f3..5dfa4bbee642 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 (var->xres_virtual < var->xres) + return -EINVAL; + if (var->yres_virtual < var->yres) + return -EINVAL; + /* 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)) From patchwork Sun Jun 26 10:28: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: 12895682 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 8E08BCCA481 for ; Sun, 26 Jun 2022 10:29:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229616AbiFZK3E (ORCPT ); Sun, 26 Jun 2022 06:29:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56862 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234227AbiFZK3B (ORCPT ); Sun, 26 Jun 2022 06:29:01 -0400 Received: from mout.gmx.net (mout.gmx.net [212.227.17.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0571C1261B for ; Sun, 26 Jun 2022 03:28:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1656239334; bh=3Sw82lkSjqZxNWiIpejvkxhMJNaG76mq4c20F06FLKg=; h=X-UI-Sender-Class:From:To:Subject:Date:In-Reply-To:References; b=DcZBE6Qsmeu2qj9Ym9F0Du83AHMv5/5hKzJu4nFeFhpK3Dx2mPljLQut6dtKOE8Ig +6iwL7S2F4iy4z/QJyngcVWsGhIEfd++gZTJwHFOy9TJrGIIAvlYXnqGSj8C5TeVUZ P6fZV/ZpJM+snBeCUyjXxoKwnjRFbtBCGF1gUMKI= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from p100.fritz.box ([92.116.135.166]) by mail.gmx.net (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1McH5Q-1nVFoQ2Ws8-00cjxr; Sun, 26 Jun 2022 12:28:54 +0200 From: Helge Deller To: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, daniel.vetter@ffwll.ch Subject: [PATCH v6 3/4] fbcon: Prevent that screen size is smaller than font size Date: Sun, 26 Jun 2022 12:28:52 +0200 Message-Id: <20220626102853.124108-4-deller@gmx.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220626102853.124108-1-deller@gmx.de> References: <20220626102853.124108-1-deller@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:R0ceq7+ogNGriXAIO0YtnBZPcu3UIWlsE4GLFTzJx2CtDdNn2DV CyuXHD3UAZUULPpTVO4DNYrBx/iobK8uLl+GHcagOvx/mMzfy0Z+6zJr/2+EBSKuHu9tuXz ZhpYhDXWNMJ9sPTH2UxHMfuKFm6XpqjINT8BKEIX8ZahGxH8tJfJMC0R8j4IcxWzha97Xeo ZtK5QU7Fs9cGMH1ThNsaw== X-UI-Out-Filterresults: notjunk:1;V03:K0:EyQ8h8phWkM=:ciNnxDzP8Po0Mfh3RR2C4N mP7Y/bST5N4D4f3QN7XXgWYnhfLeQq/fWtyQfzHwXKUi49mivy1kPCFyu3jNNqxt2XQRQZdDP 9nMQMe69JTM5D92TAJsjMcsOnbaUb0xqyUK56PR88RK4nqn1jzbVeNs+6GWAD/2db9HZfH3X5 ufUYq7GhzphbRi9Qy0vOXt+K38J8iqcNkYHkbI2S6kZeTKf8x9pAnSASEcP/hFHtJ42tDzuvi lVPBwxmE0xrZScFeeeJp0lODDZ1ua8706PRE4YWkELKHs4tckUfbN6Ac5Ky64zNHRPBQyGyum AlQR7bHRQfFKVIo9qqNeM6WA4S2XV/X6XGtGTYrIZHuoD0YOe7Co5VwcIiqX6Sh94XqV3GATQ UPUNvnWL6n3ycj7veSuvoZQx3v4N76GY3KPspb68Oh40d/vA9453Ib1VGTuBykR5pQ5iaMJ3E em4tCHpk/pEcQ1JmLLl00ofIS2kcNpdq12V1myC599cU2dzC5o2OIeoQHMsm0wzlBifcqIY0E +WtzUo82X4ZjvVLYXP/nZ9PirQE6i3aOozfUZEu7Jrr5E+haXibP1K5l4IcPPb0nwTVvEL+03 QiiKeXXvu2mepUfCBz7hKZrbIJseMd+tW5pqybI7l68gmM5sH8oY06/eeffY61ajmJMaQptX2 FUZ/cWAd6X/CAGXQpMyrBBI5rCYmkVrKCORILyXmPmsO04wuH9gG90HFy6Mru8vIJMBd/GKJa CqFEUhZdrbTlHbX39N7hPtTGkXmxOqyIs91aT/Q3+eRawZLwFQDMyNMAkWG7SVkg39TWLlFvA 828coDs36dnlk5DIeOeJIAnHRJXVFJLRmtPOwFVYyw001pjyZxSmyzwPa1Bk5onu3vnODDeer h/OCUkd4mThK1+rOYq/YbvYjjhA6SdrUK39z1QXmjN/23Uqo1eCQq5SWGmj4I696QKYZPyEb0 xqD6aio+jU224gWkou1auBIJizuPUZxJVb3lhJT5eYq+a9SiSq/9ml9R5kMAPodsMTbZPWenW uuJn75Il4zhcXEvWWgpFdUG3kVnvlAP02RUsIFXjQgaRVJhH93hYgZnGf8OA0aURTTKa/VT6t D2/NtPZHsDcgnG2PlZFoDpMDn5tYlmeDNtcZs0VC4NMo0pcIGsrrAv79w== 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 Reviewed-by: Daniel Vetter Cc: stable@vger.kernel.org # v5.4+ --- drivers/video/fbdev/core/fbcon.c | 27 +++++++++++++++++++++++++++ drivers/video/fbdev/core/fbmem.c | 4 +++- include/linux/fbcon.h | 4 ++++ 3 files changed, 34 insertions(+), 1 deletion(-) -- 2.35.3 diff --git a/drivers/video/fbdev/core/fbcon.c b/drivers/video/fbdev/core/fbcon.c index e162d5e753e5..69c7261ac334 100644 --- a/drivers/video/fbdev/core/fbcon.c +++ b/drivers/video/fbdev/core/fbcon.c @@ -2736,6 +2736,33 @@ 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 || 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 || 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 5dfa4bbee642..b6e1d0f2b974 100644 --- a/drivers/video/fbdev/core/fbmem.c +++ b/drivers/video/fbdev/core/fbmem.c @@ -1112,7 +1112,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 Sun Jun 26 10:28: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: 12895681 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 39C1AC433EF for ; Sun, 26 Jun 2022 10:29:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230147AbiFZK3D (ORCPT ); Sun, 26 Jun 2022 06:29:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56856 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234177AbiFZK3B (ORCPT ); Sun, 26 Jun 2022 06:29:01 -0400 Received: from mout.gmx.net (mout.gmx.net [212.227.17.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6592B11C31 for ; Sun, 26 Jun 2022 03:28:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1656239334; bh=zr6BXlxetCVyV/LHpmtsvDPJ6vcq7LcY9ZdBWidb2x8=; h=X-UI-Sender-Class:From:To:Subject:Date:In-Reply-To:References; b=b3XPrU9Z1VbS0rcRWeEaWbRkMb+EZyNSncaSp4uVvSTtsYBNhshMA/ydgUQk7hq0d NGrgMnLQQi9dTgzsl3pPjCRwm1iZMvJ8XxXxp/JE+1hXo3NzMkcj8Oqrz1wrRwcUjD IbUQwgtjqufD7fWte7xDz3usr2t0iltFy3S/+4S8= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from p100.fritz.box ([92.116.135.166]) by mail.gmx.net (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MTAFb-1oDybB36tT-00UWUC; Sun, 26 Jun 2022 12:28:54 +0200 From: Helge Deller To: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, daniel.vetter@ffwll.ch Subject: [PATCH v6 4/4] fbcon: Use fbcon_info_from_console() in fbcon_modechange_possible() Date: Sun, 26 Jun 2022 12:28:53 +0200 Message-Id: <20220626102853.124108-5-deller@gmx.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220626102853.124108-1-deller@gmx.de> References: <20220626102853.124108-1-deller@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:d62vnxq0gSwYN0NAZPzhYCuZEFpdMsDgaz1aXpBuXJBd348ZK4J D7HKnkH4f8CH5uQ7Ugc4jnO9LO1+undBCBAe4JnY7cDONbJ0FU6Nk/tuRGHbopkhr8bqRBB qJdWSlLE2bxzOaFye2ll/t0RIgc/rBYNrGlgUJld/uA25aLNGUbHa/eoPajLRGrOutExeq1 X+GZMC9et7HAKcwtbNP7w== X-UI-Out-Filterresults: notjunk:1;V03:K0:YS8qdbKo1co=:Owb/+23yCDWsbaPBnDlpqO kDqdXVF4cPAyy3pbUTu4bwjRCefzt9V/K0tqllLUX1VlLXe7+sxmm1h3+ZbLTIWO08kzlfHsL KYHXvGqu505p1zGggTfkY0q5CxSp+rKZCjqCVNS9OFQxsT8cK85DLGrKgb9xG3E9lw+KNxHtz ImTmtCpdtypjWXZ+Jn2xHEt2/C3x+7361/piqsrRmVkJimpkZzEgaY5pmraYm4VDMCH+l8zZv S1fpBN/u9LF3nWyRMhmAS47qR0suaYCyZZefKF5wbhg+62LIGQLXvXKGoLQmCFmtB1eAoJnqe 6AfCqXgS7GyQszbGDuYN3IG0Ynmnql6emsT9U/w4K1mmlOoVkfY6mvRaH+bvE+Y5K2Mj5p+B8 aOuZBjhXpRgcUoES+RRBi6dQ0dSe10X2IWZCl2QKITDr0FBqBi5nt+iuCGLByRc/hf3s9DnuF LkottlRW12jwzCDwtkxyiNjpkSVq9sd788T17ZPfWDw0DY2d3EzMpH1V/YgwluRzppsCl4n30 Kwcu16afchIEsUcsreM76ynESuqY/4THDlGKvwpuMVZpvvfHgWitQeWXmF/WRmAwJ2aR9VWa4 TmYTtXSHFnwwTPJFRJWaJUfq6Wj7rxzWb1/odCVqGkmlEVC/ETemoobwmXuu5IxuEtGzgjRMp CFAycgJiETpkTx65gC6m3eheG6KTOMNHOFXc7WHR0WrSu7b1r6h3nbLNl+KAqozke0ikG5GAY MeCUt89se3+74DvTyA6KOSHnTM2yPLKEt8Xb5dLqDc+7kxPQOi/XomLKnqOE+ljHv72DM12W4 vU05dbftKcsf+b9Rz93Xpen4bzxKP7mCAJgpTDGyfn5KALLtWiTbiyRp6xfzOMEeY/IwKpRt7 hJ0juWYzO3Snag66sh3oOC/QMF36hXv6+IwC8YiF1P7DQI2mBhBPok/h46PHaeU5XcyItxlGJ UuLJQ3fVAEskP+bvLAK6sIC1kIfqesFOKN5NTGJqRt/uJmWOunSJgOq3nLr8hsBfhnj1jeVKq aWoo0Sc66FuKrebOF4jbb9O1q3lKEnNDp3TNe6yup52KKyEzk+nc/gaitIoRn+lMrv3irflnM EFSj2a8EZSTR4wwU7cPyzeO90PJzLwEXwBzK6uLvqghQPEJ2RO9ci2Zcw== 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: Daniel Vetter --- 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 69c7261ac334..2ab7515ac842 100644 --- a/drivers/video/fbdev/core/fbcon.c +++ b/drivers/video/fbdev/core/fbcon.c @@ -2751,7 +2751,7 @@ int fbcon_modechange_possible(struct fb_info *info, struct fb_var_screeninfo *va /* 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 || registered_fb[con2fb_map[i]] != info) + if (!vc || fbcon_info_from_console(i) != info) continue; if (vc->vc_font.width > FBCON_SWAP(var->rotate, var->xres, var->yres) ||