From patchwork Sat Jun 25 22:06:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Helge Deller X-Patchwork-Id: 12895471 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 B049DC433EF for ; Sat, 25 Jun 2022 22:06:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233382AbiFYWGl (ORCPT ); Sat, 25 Jun 2022 18:06:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40272 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233356AbiFYWGk (ORCPT ); Sat, 25 Jun 2022 18:06:40 -0400 Received: from mout.gmx.net (mout.gmx.net [212.227.17.21]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B8F37120BD for ; Sat, 25 Jun 2022 15:06:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1656194792; bh=tRqvkgP3s46IORRaOk1LZP5YQEeJ21rrrTXuUbKXSvE=; h=X-UI-Sender-Class:From:To:Subject:Date:In-Reply-To:References; b=gVrFVJYj453sz98YflohNPOOQQZbth+K4YFhG9lefmk3XNgvdwmbNO/qJOp/qshBy kKrZkP+3H/DHYdhbbt3W5Aq3QGYdGYjO8kHn9HCVPHInPZL5BUwZgtHbe7OVImVsP3 LwCHAYn2QW5Y8wrvSY472rwPWkRUmSJ5HPL0Oa6c= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from p100.fritz.box ([92.116.162.44]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MrhUK-1nHdUB3Cdg-00nhHD; Sun, 26 Jun 2022 00:06:31 +0200 From: Helge Deller To: dri-devel@lists.freedesktop.org, daniel.vetter@ffwll.ch, linux-fbdev@vger.kernel.org Subject: [PATCH v3 1/4] fbcon: Disallow setting font bigger than screen size Date: Sun, 26 Jun 2022 00:06:27 +0200 Message-Id: <20220625220630.333705-2-deller@gmx.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220625220630.333705-1-deller@gmx.de> References: <20220625220630.333705-1-deller@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:FGIQ5xSaIVRGo4hp8yfX3n+NH29eA3bhr7z5zE4g+f3T5zRqYbJ zfitv+gynLV+29UqzuD1omCeWLTjBxw3URRCUruG5beTTpJwXPSVyPGU9rl9k3f2v72L3YI ryOvAP3NCpjrN2RbMJt1xe+4aqFrnRycUYXdJ1KpiKh4qTzCO0WNokFjJKttABzePmx0kau cYv3wRkBoZHFh0ifKVO5g== X-UI-Out-Filterresults: notjunk:1;V03:K0:w5twWS2oZ94=:TVJNx05VlhXQr756TbEvcH pouTt5mAlmU6YoVEz8v+dt1aKBllFcVDxvL2FoCtP4AgZlSn+SBDAKdmm90iKmZC7YwxWJav/ ga0hpPkd4loszDLRNTpUV1Q44Sr2Oe6Nn6LVs5E8qgLqIojTL/a1ZwA/kuJtUsypavAZgDFSH Hb6uo+Oj+chyHpfFJsyfTwoJ9K8ILT01UDcYxgtn1HYpfIIu2lA2qzyJkxBklplLlTc5O9li2 +uj6OELsF4RsoefT5FA4tUGuohvzEghHNTm8Eq7TldqacUUYTZDNg000EvPj7Khihi9QQ/UsR 3qhqqWRYxtp8whXauCQxsN6uUIghz+Ay5V9vlaXFJI+vbQ0s8q3Ht77kIWqamkr58e3RA5qVQ xTdEEiyFF5yqGvjREyJH4BLdDVkZw29TlNlMzmkHQk8P9E3DhLmAtIU38NM78V4bMagB2DU0y oEELu9hg8IopMVF/s9MPWnUJImwfCbHfvBUqsNvc4Q0Zta7xtvIlKIxKmZpPZTmD+NhMCDbRa 7MOnV0RQT642bmCJziLpWnEIbG2UDrkghWKQ/MhM18PJYriT7Q416Mi05khoi8WGoJe1XyfmQ zYK+aVAJDUuhDbaBU0kjy7/4FBoJEHgw6aT5/9VI/BiX0nSRxyEVMo87IgasA56agYJps+JXb yqXZVm6KAz0iOBjdYfqLHb+PGIuXcA8IKMaZ8YxLsN62FWr4QA29LfY9Nh9fcVJKySsDz5iw4 bTJ/8meRbQmO/FBmDYCcwhgxLEmoML8mmuekDSFiqki++zYxvDC/XUOld6A7A5aF4jjWATPoi OsrxpdFOOdwhugxigOE8rki1lZr1l7mBtZhQ+lufAApndehjsMgrHVv97vLyqjs9FCKmOo6YI W2wk+BMRagJM3BHLtUWcDs42Q3X5joVm1KQB/tO4zrSJdujk1DuJf0Gv0cq6qsTtbOF/m5Z67 bX7o8O2pgAfPcMNRU6r1l3We/nIgQ6YkRK6v8vc+UTaQhrY0GaFJjprfpLke7uqn4mIJ+JCPq JErl0QabZmvWlApkRbWBU2vkvc79uq8snDb1GUULgToAh1m8jJ/K/MauJLFCwNT+q7W+F08hc f0Cep3ceI5X6zfcHS6z3YDia0IrsruF4SFxQgpBcXA4CaSHwQfKCDkyyQ== 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 Sat Jun 25 22:06:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Helge Deller X-Patchwork-Id: 12895468 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 167DBC43334 for ; Sat, 25 Jun 2022 22:06:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233330AbiFYWGj (ORCPT ); Sat, 25 Jun 2022 18:06:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40252 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233356AbiFYWGi (ORCPT ); Sat, 25 Jun 2022 18:06:38 -0400 Received: from mout.gmx.net (mout.gmx.net [212.227.17.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 96233120A2 for ; Sat, 25 Jun 2022 15:06:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1656194792; bh=mfIE/8o3iwMRsFJsNJhA3Pd2VIEUX0hccvso4RX5yvg=; h=X-UI-Sender-Class:From:To:Subject:Date:In-Reply-To:References; b=WJHoAeSPlSYPNGbfAMaOlN2IUpzuW4qmkwj1Z6BCOzN4csh8I1mO/qYr3mJl3qDk7 bOUWdLXnzHGD+UYHBvOTMS+Lda34lPhe0RAvqA7kxRLQiHaPa1gPE8l8Hu+hiRvfB2 xVQmhCex9vEBx5CsjT0jMOFc82uSdHBN9UDzmLII= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from p100.fritz.box ([92.116.162.44]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MnakX-1nLkDS3m45-00jYPm; Sun, 26 Jun 2022 00:06:31 +0200 From: Helge Deller To: dri-devel@lists.freedesktop.org, daniel.vetter@ffwll.ch, linux-fbdev@vger.kernel.org Subject: [PATCH v3 2/4] fbcon: Add fbcon_modechange_possible() check Date: Sun, 26 Jun 2022 00:06:28 +0200 Message-Id: <20220625220630.333705-3-deller@gmx.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220625220630.333705-1-deller@gmx.de> References: <20220625220630.333705-1-deller@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:e+aos6YQxRDiH+Yn5SqvV3sqRII1FoViM9WVKEVVgoLWnKZVYm4 d9N3mCqhC8Sz6QnEvBFpLwuShwHoqsJNX/CpxCj7yG92vTX7nYOYPpk6rY/rW1Zjlo3dJza 2xYiVBlAA3Sjzt1IHIiIDUjNQ+kEvQZWdziWMyAAi6A/GtqqckgnlHOmwy7B/9hVVCpCqoP B3FDFfd2V46GU8RtB54TA== X-UI-Out-Filterresults: notjunk:1;V03:K0:2ShdSY/THac=:FbquMf56hrvbvSPduWiwHz nTPQZuAPtdClfucIggVA9/mBNDnddtrD/iSeKWLTs256Qk5wZyLNrdOQbgH52DGioPijiFDNG aa0YbN2cIneptduIkW3n2GqxZwhZpz620SGV19j6vQdKEUM/F3us7WwxQa7zU5+yrurp5peC+ Xgzv/kh7I/1UgB6FTA8SB5mQcB9BQ4gvIdN6MEmwml7jplOulrSe2azdWviAPObmyNYLV//Sb MEhx3+iM7DbQkQcAOD/LJ6A6y5M1XMmb1wXbEY2mkIUARKkKNT7pxv7ph/73L/gQyEYRwRZ99 PAZUlXXpX+byOrADBjTGfN4tU8A0XoLjrOF89EUbV/x6Nk/16sPy2cAnHeyCCYBj+M/5ceEbc aw8fqnwZWurFN/VmiNUxHXGIYV6/lfUAwjmI1RE9SgHHDClOPJa64Mhpxku9xELIAFZj/l+N1 V/TvsMtiGKj31uo+upJ34MAXp0EYhZ2Cg9vfKj1cvPQP/qWOwyB51fgCc/qFacNvsKDy0jmft WwsZqJ0NEalnfd7Vouqq+TUUUc9YOBX7/ApDXW6xAW/mDM8UvGSM1QQ6onkJ90tMTkXXAAvJT uCq+dBjAoKTVfAEqK3kJBevvq5j+B+jzNkifpTU7NT1mW8Vu6fPfgsQ74pRrVpzBBz+xddJhj gBMXoBjbrjUbOhZz263vxAwdd/wKeODcgEVdAgb5HZYPJXOlsJeZ2du+l+hWZ+hQsDDiCcRma rdg52IwWGlYmIaj3ziO78MlP9kIZfc3eCrNt+23td+YuZFJ3lBRpfnkc9NGo+5WKmW5tWBLGm zOcplZtmJcluivq16JwT2Q0KZ0WsmHST4W9PQe9+/A2v2ZaH9Ds+Yd/P0fB3OPVT7d5xmuihA s2xtFVnMVph5Ahz6nFQ65p9aSfWY6gUmg/8roo80ywnpjIBy2PbHqcObSdtuRR3Ux9u9Bq5dN JUnV5wjmRVU/49j+T7UWBRW8ileuV7xx6fJWH/QE+ei46OchdvAQm11TpdU8/aaDQgRFUgwnq 8I5REr5gCrj0VNcAtN17A9mKHDmvA6RdCPbP8ToteEBSWMTCZ7IBK9G9zOtHxM9eQOGdE7t+i Tw+qaIxXCkOoLdv9kCLzKmu8kTgYmfJgylJBv77RS8k8bl91UDwfK3+yA== 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 | 27 +++++++++++++++++++++++++++ include/linux/fbcon.h | 4 ++++ 2 files changed, 31 insertions(+) -- 2.35.3 diff --git a/drivers/video/fbdev/core/fbcon.c b/drivers/video/fbdev/core/fbcon.c index e162d5e753e5..2ab7515ac842 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 || fbcon_info_from_console(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/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 22:06:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Helge Deller X-Patchwork-Id: 12895467 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 97534C433EF for ; Sat, 25 Jun 2022 22:06:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233365AbiFYWGj (ORCPT ); Sat, 25 Jun 2022 18:06:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40246 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233330AbiFYWGi (ORCPT ); Sat, 25 Jun 2022 18:06:38 -0400 Received: from mout.gmx.net (mout.gmx.net [212.227.17.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 955CB11158 for ; Sat, 25 Jun 2022 15:06:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1656194792; bh=PMakGc1Xx8pWLUuhWgvPzqMjvPuAkCCgL2mFABbdBRg=; h=X-UI-Sender-Class:From:To:Subject:Date:In-Reply-To:References; b=H2U2KRXoYHZBkyLwCHWjwDeggkPTFw5mvNehZEky3T4W3XEyUF3tHcRrUV2pQ9Q8L q+k3xd64eutVsmLyDHlOvVMoDZxA6UCam97eUVEXjzg4mzTCxxAMHyGMcjpUQIk3Ex iVEqMaKGvE0jy1AiryqZQeH5XFKoRke0nQHb64M4= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from p100.fritz.box ([92.116.162.44]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1N8GQy-1naPKC08Bc-014Gip; Sun, 26 Jun 2022 00:06:32 +0200 From: Helge Deller To: dri-devel@lists.freedesktop.org, daniel.vetter@ffwll.ch, linux-fbdev@vger.kernel.org Subject: [PATCH v3 3/4] fbmem: Check screen resolution change against font size Date: Sun, 26 Jun 2022 00:06:29 +0200 Message-Id: <20220625220630.333705-4-deller@gmx.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220625220630.333705-1-deller@gmx.de> References: <20220625220630.333705-1-deller@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:s5v/qQunOpq3us49AGxcriWC5b51eFrJN40JCWcMOWgfk2AGVLB wipZ9W1IDXoS3Xid3swg5H2oL/R2hVw7uepIEVTEhI71ZeqHa3NYKNr0Z5mFF5wmmswrhqx 5XyFLU9J0pD/2eBnPl3/mUaJgHl7gaK9o83w5hCdJcrUDWNlttRXiYKFBonjwd8eYHU8w8/ GXqitBKH0Fx7qAaZnTLwQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:oD735pIe7V8=:IFgtWmEWedqlDobqBPEwXW ynAbbJUxXKXIVuHII3u6SCWfZVUZV7tBRRvTmet2wok93TgHlncpfSY8YyPFxh1Qr6tghyK2i o8DoN2gikhrbcm5gakuRswpTyLjVUUgIklRZ7eYv+8VXp1/eaIBjt7yUqkKDfNtTuk2uxHQ13 W4qaUNOtdSjkgAGHJrS6neDyKT1F0p1DDNGqWSuQvAYfATwHfZT/oiePz3e0UZyXftfW6Z7A2 tHAbN/U5l/UHrQUUjPdoJ1KptcEuJCyBk9wIyemJHAMMSq5B/CEamGfh3KXGnXDwou0ztktoP 0MB3adKFlGaV6tgBv+v8y6MVXglJ6M4TZ72GgwuvyhOriYWtvlXYCVPd6Pem8NGW3PmwfQQFD ETL+eQAgWD2cDgOJQzerYvLIJI6vILs8+RVdAC0mgkBFzXmrxfTctN577W3Vb3ow1RX5LALdv uGvJmtO0A0Nk+z9JTcuLaycVNx6l0RlbMgQAVZbTe/j/xgIVo6dUVS6mvxQ0HqFe2Nz5ftNX1 5fxWQ9sMWP4GpNkCLeiqSbpBSZvk9wWQ97/qksJ5UQPFnSISXAvP1xXxXvkdWVqvZjf1pDlHu hg2S97dY7NTmh+UggGjJNACAbsDlPHuIjHzGnsuLHQ34jAnwR6kpRPwM0NhrNXvjrpMLcUpJP 7PoHYKkp7U3jqZxFJrDIpRFSMk9Jy7bF26aO+UlngnH8YK/qvKBddHhIbrSh2oJtKfhpbHKn9 cKtGIHZLli3tQBxf22zgFnU6P+w5wO6F86KqGpzoP2yMnzBpcREw0kwyfKL/zidZ4TFoukQy9 4KdoBWd22+ntTXT8RUaBLORG5B983WMdrxBn/O1AKpWg8pHV6eJyLHWhjepSZA91MraKBbvSc 8R2Ts0u+monu5cCqaQ2AosSrnZrMZCRSC20OhVHofeEXYzuKacu06xSy2Xbfor1ETIEwE0Tpk gdjbiY2FLjepN2GkJYZt0PDcBsp6gXjI7XQRCvS8E04jG/G/TSEA+jtDpyrvxPeQtwGGkfw8g UD/MlgMe+lwmU08NwPUIExnxNcPbmkWNueuWKRNK9GpgKvb5g0boyM/IIGO+pLqxQdk6bgXuV +lqXloA9ai0VfwXeW86FrFd5M0zfM0CQTInDUeNLzl+j0lOEa+wec8bLw== Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Enhance the check in the FBIOPUT_VSCREENINFO ioctl handler to verify if the user-provided new screen size is bigger than the current font size. Signed-off-by: Helge Deller Cc: stable@vger.kernel.org # v5.4+ --- drivers/video/fbdev/core/fbmem.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) -- 2.35.3 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); From patchwork Sat Jun 25 22:06:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Helge Deller X-Patchwork-Id: 12895469 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 48734CCA481 for ; Sat, 25 Jun 2022 22:06:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233375AbiFYWGk (ORCPT ); Sat, 25 Jun 2022 18:06:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40260 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233386AbiFYWGj (ORCPT ); Sat, 25 Jun 2022 18:06:39 -0400 Received: from mout.gmx.net (mout.gmx.net [212.227.17.22]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B1D24120B9 for ; Sat, 25 Jun 2022 15:06:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1656194792; bh=cL0l7EYk7Gr+7cdvpNWmUqqHHHMGkB914fzT0oYSaE8=; h=X-UI-Sender-Class:From:To:Subject:Date:In-Reply-To:References; b=Z6NjoG3JehTfC3JD3q18GSY45JR1RQqK9LqKyNDUiU+75NZrRyH2xsInl41Y2Xi1Q qiGrSxUOlst8F+pCe1wArVyOFL9lAfyVANGADu/msg71XpDumeN4k4Pr9FFruhaOaY cxXfn0qQInqewJGv7gA7G0neIBR4eh2+dck3qUMs= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from p100.fritz.box ([92.116.162.44]) by mail.gmx.net (mrgmx105 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MVN6t-1oCCBL0eBT-00SR0G; Sun, 26 Jun 2022 00:06:32 +0200 From: Helge Deller To: dri-devel@lists.freedesktop.org, daniel.vetter@ffwll.ch, linux-fbdev@vger.kernel.org Subject: [PATCH v3 4/4] fbmem: Prevent invalid virtual screen sizes Date: Sun, 26 Jun 2022 00:06:30 +0200 Message-Id: <20220625220630.333705-5-deller@gmx.de> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220625220630.333705-1-deller@gmx.de> References: <20220625220630.333705-1-deller@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:gquswi0ApXZgSzlnh0iSNH95/VhiqmO6Gpcab5NAlqj7elPx4BP 5nXyjBNb59rvWQXoL8RIoB0B4Wj0EZjaDAsKRb8lVYPTApEn2Nf3wLtjBlS8VXkSAUa0QN+ DKrleacuIaruWpsW3dqzyAsKx1BwOAfLVpeRPFwcbux0XPW73AfNO6NJKpoudSOZ2Zl6BnM xfjzEdYLN2KUDUzitUrMg== X-UI-Out-Filterresults: notjunk:1;V03:K0:b1zdCS+WlXY=:6CtS0Iew/H9ZY79ULxuL9V /5W25kw/OB9HWWV+3uhaMFScvM6NigKE4fzwyE/uIYrVHwwCbvJMwHac1DC4LFpu0PJGK39h+ 8uWhhBTklv9OFVWXCCJKOH5nWyY+HD7lbVLlctzHyt0GgDcD9exaD72seoAM8d25Dy+A7nmnx 3blO6ls4hqBGiCohVh6sHZ/HLcnwQTvA2dt0KjNjhDuWNlrG4Z7IQoUm6rfvgtxuUASxbhLNh +nhSmkrbDPBwTi2joO2Q+Wl8T1nZfoDlUD7+TO1iEu2zMXfEJn9yrNnfBnV0lM1I3CNnhFxCa fLwn9o8HTCZU0gtEslk7jKEBfd+I/+8QS3mp9cFVfOrwfziY7iZvq9c09/vAieeggCwTbO1nx ETfilnhirEmDHHxPE7AW0WXn/c4PULCHWiANeE6IEEFHHDfXUxTTnox112lJ49p4/O6YNPmqX SmFwEyOQmKW3yfywFGySrA1j9/VlT5CWOyYTqjNQWPNRr8o6NRF/gGO+Piu7aU7IxM4Ngsa6q rKQUHzEhEcbjMtaTqwWfDsnSYL4dQTx/WiatpRsCn9jg/G0+gDbHNu3+/sIuo2TdVzrdg25CC p2m1zuVeu0sfB52Ufs8kOg/gTYe8BWht7GuxswSi+1e5YGJOWOYVvM/ERlKGMAw6OnTmZbQPN EZyIqUxqYfHnpZM0dpTekncrswcNr7bwXZ86vF+qHUVpEfSoSS1IhOkurLzV/3v4RH88ss4s1 BRTWh3P3Hrbp4qRUCkWyn0uTMO8mQH7TwlPIu6vpcaJQWJryAp4lhRgIF6/jMkwu8JAo4UIlR qFtEFeWmdfl5xDrbn6JJWW2HjNfssAD2LV2ImH/SlxWi4SoWlrk8j6p6bJ6UB2hDngyoPVQLs vjulhUa6MIktxI8qxIm04JG1X8ZqWSCPwI4AYnguZPv18r0HmJqCwDvuuDdvRDqy8bX71kZnt BItz6Rurl6p31SYNAx3fz+YeeODOc4UCYCB6gGG1JdvHS9qdJDLQWjrUaUZq+lAh3CbHKAmfs Ef1UKTilCR1uFRQFX3qHgEb9TJUeRAb2GlwBeStAd9drESk5vERCQbb9JlYqKEz75sOzBCagK 4Y4WQIXQ+NKcGhKlfFKtZux44CkRpUch4hn0cHzaG2JUWhL83e7I9mnFA== 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 get accesses outside of the graphics memory area. Signed-off-by: Helge Deller Cc: stable@vger.kernel.org # v5.4+ Reviewed-by: Daniel Vetter --- 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 160389365a36..b6e1d0f2b974 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))