Security
Headlines
HeadlinesLatestCVEs

Headline

CVE-2021-33656: vt-drop-old-font-ioctls.patch « 5.10.127 « releases - kernel/git/stable/stable-queue.git

When setting font with malicous data by ioctl cmd PIO_FONT,kernel will write memory out of bounds.

CVE
#linux#js#git#huawei#ssl

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307

From ff2047fb755d4415ec3c70ac799889371151796d Mon Sep 17 00:00:00 2001
From: Jiri Slaby <[email protected]>
Date: Tue, 5 Jan 2021 13:02:35 +0100
Subject: vt: drop old FONT ioctls

From: Jiri Slaby <[email protected]>

commit ff2047fb755d4415ec3c70ac799889371151796d upstream.

Drop support for these ioctls:
* PIO_FONT, PIO_FONTX
* GIO_FONT, GIO_FONTX
* PIO_FONTRESET

As was demonstrated by commit 90bfdeef83f1 (tty: make FONTX ioctl use
the tty pointer they were actually passed), these ioctls are not used
from userspace, as:
1) they used to be broken (set up font on current console, not the open
   one) and racy (before the commit above)
2) KDFONTOP ioctl is used for years instead

Note that PIO_FONTRESET is defunct on most systems as VGA_CONSOLE is set
on them for ages. That turns on BROKEN_GRAPHICS_PROGRAMS which makes
PIO_FONTRESET just return an error.

We are removing KD_FONT_FLAG_OLD here as it was used only by these
removed ioctls. kd.h header exists both in kernel and uapi headers, so
we can remove the kernel one completely. Everyone includeing kd.h will
now automatically get the uapi one.

There are now unused definitions of the ioctl numbers and "struct
consolefontdesc" in kd.h, but as it is a uapi header, I am not touching
these.

Signed-off-by: Jiri Slaby <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Cc: guodaxing <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
---
 drivers/tty/vt/vt.c       |   39 -----------
 drivers/tty/vt/vt_ioctl.c |  151 ----------------------------------------------
 include/linux/kd.h        |    8 --
 3 files changed, 3 insertions(+), 195 deletions(-)
 delete mode 100644 include/linux/kd.h

--- a/drivers/tty/vt/vt.c
+++ b/drivers/tty/vt/vt.c
@@ -4625,16 +4625,8 @@ static int con_font_get(struct vc_data *
 
    if (op->data && font.charcount > op->charcount)
        rc = -ENOSPC;
-   if (!(op->flags & KD_FONT_FLAG_OLD)) {
-       if (font.width > op->width || font.height > op->height) 
-           rc = -ENOSPC;
-   } else {
-       if (font.width != 8)
-           rc = -EIO;
-       else if ((op->height && font.height > op->height) ||
-            font.height > 32)
-           rc = -ENOSPC;
-   }
+   if (font.width > op->width || font.height > op->height)
+       rc = -ENOSPC;
    if (rc)
        goto out;
 
@@ -4662,7 +4654,7 @@ static int con_font_set(struct vc_data *
        return -EINVAL;
    if (op->charcount > 512)
        return -EINVAL;
-   if (op->width <= 0 || op->width > 32 || op->height > 32)
+   if (op->width <= 0 || op->width > 32 || !op->height || op->height > 32)
        return -EINVAL;
    size = (op->width+7)/8 * 32 * op->charcount;
    if (size > max_font_size)
@@ -4672,31 +4664,6 @@ static int con_font_set(struct vc_data *
    if (IS_ERR(font.data))
        return PTR_ERR(font.data);
 
-   if (!op->height) {      /* Need to guess font height [compat] */
-       int h, i;
-       u8 *charmap = font.data;
-
-       /*
-        * If from KDFONTOP ioctl, don't allow things which can be done
-        * in userland,so that we can get rid of this soon
-        */
-       if (!(op->flags & KD_FONT_FLAG_OLD)) {
-           kfree(font.data);
-           return -EINVAL;
-       }
-
-       for (h = 32; h > 0; h--)
-           for (i = 0; i < op->charcount; i++)
-               if (charmap[32*i+h-1])
-                   goto nonzero;
-
-       kfree(font.data);
-       return -EINVAL;
-
-   nonzero:
-       op->height = h;
-   }
-
    font.charcount = op->charcount;
    font.width = op->width;
    font.height = op->height;
--- a/drivers/tty/vt/vt_ioctl.c
+++ b/drivers/tty/vt/vt_ioctl.c
@@ -486,70 +486,6 @@ static int vt_k_ioctl(struct tty_struct
    return 0;
 }
 
-static inline int do_fontx_ioctl(struct vc_data *vc, int cmd,
-       struct consolefontdesc __user *user_cfd,
-       struct console_font_op *op)
-{
-   struct consolefontdesc cfdarg;
-   int i;
-
-   if (copy_from_user(&cfdarg, user_cfd, sizeof(struct consolefontdesc)))
-       return -EFAULT;
-
-   switch (cmd) {
-   case PIO_FONTX:
-       op->op = KD_FONT_OP_SET;
-       op->flags = KD_FONT_FLAG_OLD;
-       op->width = 8;
-       op->height = cfdarg.charheight;
-       op->charcount = cfdarg.charcount;
-       op->data = cfdarg.chardata;
-       return con_font_op(vc, op);
-
-   case GIO_FONTX:
-       op->op = KD_FONT_OP_GET;
-       op->flags = KD_FONT_FLAG_OLD;
-       op->width = 8;
-       op->height = cfdarg.charheight;
-       op->charcount = cfdarg.charcount;
-       op->data = cfdarg.chardata;
-       i = con_font_op(vc, op);
-       if (i)
-           return i;
-       cfdarg.charheight = op->height;
-       cfdarg.charcount = op->charcount;
-       if (copy_to_user(user_cfd, &cfdarg, sizeof(struct consolefontdesc)))
-           return -EFAULT;
-       return 0;
-   }
-   return -EINVAL;
-}
-
-static int vt_io_fontreset(struct vc_data *vc, struct console_font_op *op)
-{
-   int ret;
-
-   if (__is_defined(BROKEN_GRAPHICS_PROGRAMS)) {
-       /*
-        * With BROKEN_GRAPHICS_PROGRAMS defined, the default font is
-        * not saved.
-        */
-       return -ENOSYS;
-   }
-
-   op->op = KD_FONT_OP_SET_DEFAULT;
-   op->data = NULL;
-   ret = con_font_op(vc, op);
-   if (ret)
-       return ret;
-
-   console_lock();
-   con_set_default_unimap(vc);
-   console_unlock();
-
-   return 0;
-}
-
 static inline int do_unimap_ioctl(int cmd, struct unimapdesc __user *user_ud,
        bool perm, struct vc_data *vc)
 {
@@ -574,29 +510,7 @@ static inline int do_unimap_ioctl(int cm
 static int vt_io_ioctl(struct vc_data *vc, unsigned int cmd, void __user *up,
        bool perm)
 {
-   struct console_font_op op;  /* used in multiple places here */
-
    switch (cmd) {
-   case PIO_FONT:
-       if (!perm)
-           return -EPERM;
-       op.op = KD_FONT_OP_SET;
-       op.flags = KD_FONT_FLAG_OLD | KD_FONT_FLAG_DONT_RECALC; /* Compatibility */
-       op.width = 8;
-       op.height = 0;
-       op.charcount = 256;
-       op.data = up;
-       return con_font_op(vc, &op);
-
-   case GIO_FONT:
-       op.op = KD_FONT_OP_GET;
-       op.flags = KD_FONT_FLAG_OLD;
-       op.width = 8;
-       op.height = 32;
-       op.charcount = 256;
-       op.data = up;
-       return con_font_op(vc, &op);
-
    case PIO_CMAP:
                 if (!perm)
            return -EPERM;
@@ -605,20 +519,6 @@ static int vt_io_ioctl(struct vc_data *v
    case GIO_CMAP:
                 return con_get_cmap(up);
 
-   case PIO_FONTX:
-       if (!perm)
-           return -EPERM;
-
-       fallthrough;
-   case GIO_FONTX:
-       return do_fontx_ioctl(vc, cmd, up, &op);
-
-   case PIO_FONTRESET:
-       if (!perm)
-           return -EPERM;
-
-       return vt_io_fontreset(vc, &op);
-
    case PIO_SCRNMAP:
        if (!perm)
            return -EPERM;
@@ -1099,54 +999,6 @@ void vc_SAK(struct work_struct *work)
 
 #ifdef CONFIG_COMPAT
 
-struct compat_consolefontdesc {
-   unsigned short charcount;       /* characters in font (256 or 512) */
-   unsigned short charheight;      /* scan lines per character (1-32) */
-   compat_caddr_t chardata;    /* font data in expanded form */
-};
-
-static inline int
-compat_fontx_ioctl(struct vc_data *vc, int cmd,
-          struct compat_consolefontdesc __user *user_cfd,
-          int perm, struct console_font_op *op)
-{
-   struct compat_consolefontdesc cfdarg;
-   int i;
-
-   if (copy_from_user(&cfdarg, user_cfd, sizeof(struct compat_consolefontdesc)))
-       return -EFAULT;
-
-   switch (cmd) {
-   case PIO_FONTX:
-       if (!perm)
-           return -EPERM;
-       op->op = KD_FONT_OP_SET;
-       op->flags = KD_FONT_FLAG_OLD;
-       op->width = 8;
-       op->height = cfdarg.charheight;
-       op->charcount = cfdarg.charcount;
-       op->data = compat_ptr(cfdarg.chardata);
-       return con_font_op(vc, op);
-
-   case GIO_FONTX:
-       op->op = KD_FONT_OP_GET;
-       op->flags = KD_FONT_FLAG_OLD;
-       op->width = 8;
-       op->height = cfdarg.charheight;
-       op->charcount = cfdarg.charcount;
-       op->data = compat_ptr(cfdarg.chardata);
-       i = con_font_op(vc, op);
-       if (i)
-           return i;
-       cfdarg.charheight = op->height;
-       cfdarg.charcount = op->charcount;
-       if (copy_to_user(user_cfd, &cfdarg, sizeof(struct compat_consolefontdesc)))
-           return -EFAULT;
-       return 0;
-   }
-   return -EINVAL;
-}
-
 struct compat_console_font_op {
    compat_uint_t op;        /* operation code KD_FONT_OP_* */
    compat_uint_t flags;     /* KD_FONT_FLAG_* */
@@ -1223,9 +1075,6 @@ long vt_compat_ioctl(struct tty_struct *
    /*
     * these need special handlers for incompatible data structures
     */
-   case PIO_FONTX:
-   case GIO_FONTX:
-       return compat_fontx_ioctl(vc, cmd, up, perm, &op);
 
    case KDFONTOP:
        return compat_kdfontop_ioctl(up, perm, &op, vc);
--- a/include/linux/kd.h
+++ /dev/null
@@ -1,8 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-#ifndef _LINUX_KD_H
-#define _LINUX_KD_H
-
-#include <uapi/linux/kd.h>
-
-#define KD_FONT_FLAG_OLD       0x80000000  /* Invoked via old interface [compat] */
-#endif /* _LINUX_KD_H */

Related news

Red Hat Security Advisory 2023-3495-01

Red Hat Security Advisory 2023-3495-01 - Logging Subsystem 5.7.2 - Red Hat OpenShift. Issues addressed include cross site scripting and denial of service vulnerabilities.

Red Hat Security Advisory 2023-3356-01

Red Hat Security Advisory 2023-3356-01 - Red Hat Advanced Cluster Management for Kubernetes 2.5.9 images Red Hat Advanced Cluster Management for Kubernetes provides the capabilities to address common challenges that administrators and site reliability engineers face as they work across a range of public and private cloud environments. Clusters and applications are all visible and managed from a single console—with security policy built in. This advisory contains the container images for Red Hat Advanced Cluster Management for Kubernetes, which fix several bugs.

Red Hat Security Advisory 2023-3326-01

Red Hat Security Advisory 2023-3326-01 - Red Hat Advanced Cluster Management for Kubernetes 2.6.6 images. This advisory contains the container images for Red Hat Advanced Cluster Management for Kubernetes, which fix several bugs.

RHSA-2023:2951: Red Hat Security Advisory: kernel security, bug fix, and enhancement update

An update for kernel is now available for Red Hat Enterprise Linux 8. Red Hat Product Security has rated this update as having a security impact of Important. A Common Vulnerability Scoring System (CVSS) base score, which gives a detailed severity rating, is available for each vulnerability from the CVE link(s) in the References section.This content is licensed under the Creative Commons Attribution 4.0 International License (https://creativecommons.org/licenses/by/4.0/). If you distribute this content, or a modified version of it, you must provide attribution to Red Hat Inc. and provide a link to the original. Related CVEs: * CVE-2021-26341: A flaw was found in hw. This issue can cause AMD CPUs to transiently execute beyond unconditional direct branches. * CVE-2021-33655: An out-of-bounds write flaw was found in the Linux kernel’s framebuffer-based console driver functionality in the way a user triggers ioctl FBIOPUT_VSCREENINFO with malicious data. This flaw allows a local user to c...

RHSA-2023:2736: Red Hat Security Advisory: kernel-rt security and bug fix update

An update for kernel-rt is now available for Red Hat Enterprise Linux 8. Red Hat Product Security has rated this update as having a security impact of Important. A Common Vulnerability Scoring System (CVSS) base score, which gives a detailed severity rating, is available for each vulnerability from the CVE link(s) in the References section.This content is licensed under the Creative Commons Attribution 4.0 International License (https://creativecommons.org/licenses/by/4.0/). If you distribute this content, or a modified version of it, you must provide attribution to Red Hat Inc. and provide a link to the original. Related CVEs: * CVE-2021-26341: A flaw was found in hw. This issue can cause AMD CPUs to transiently execute beyond unconditional direct branches. * CVE-2021-33655: An out-of-bounds write flaw was found in the Linux kernel’s framebuffer-based console driver functionality in the way a user triggers ioctl FBIOPUT_VSCREENINFO with malicious data. This flaw allows a local user t...

CVE-2022-46756: DSA-2022-335: Dell VxRail Security Update for Multiple Third-Party Component Vulnerabilities

Dell VxRail, versions prior to 7.0.410, contain a Container Escape Vulnerability. A local high-privileged attacker could potentially exploit this vulnerability, leading to the execution of arbitrary OS commands on the container's underlying OS. Exploitation may lead to a system take over by an attacker.

Ubuntu Security Notice USN-5650-1

Ubuntu Security Notice 5650-1 - It was discovered that the framebuffer driver on the Linux kernel did not verify size limits when changing font or screen size, leading to an out-of- bounds write. A local attacker could use this to cause a denial of service or possibly execute arbitrary code. It was discovered that the virtual terminal driver in the Linux kernel did not properly handle VGA console font changes, leading to an out-of-bounds write. A local attacker could use this to cause a denial of service or possibly execute arbitrary code.

Ubuntu Security Notice USN-5605-1

Ubuntu Security Notice 5605-1 - Asaf Modelevsky discovered that the Intel 10GbE PCI Express Ethernet driver for the Linux kernel performed insufficient control flow management. A local attacker could possibly use this to cause a denial of service. It was discovered that the virtual terminal driver in the Linux kernel did not properly handle VGA console font changes, leading to an out-of-bounds write. A local attacker could use this to cause a denial of service or possibly execute arbitrary code.

Ubuntu Security Notice USN-5603-1

Ubuntu Security Notice 5603-1 - Asaf Modelevsky discovered that the Intel 10GbE PCI Express Ethernet driver for the Linux kernel performed insufficient control flow management. A local attacker could possibly use this to cause a denial of service. It was discovered that the virtual terminal driver in the Linux kernel did not properly handle VGA console font changes, leading to an out-of-bounds write. A local attacker could use this to cause a denial of service or possibly execute arbitrary code.

Ubuntu Security Notice USN-5597-1

Ubuntu Security Notice 5597-1 - It was discovered that the virtual terminal driver in the Linux kernel did not properly handle VGA console font changes, leading to an out-of-bounds write. A local attacker could use this to cause a denial of service or possibly execute arbitrary code.

Ubuntu Security Notice USN-5600-1

Ubuntu Security Notice 5600-1 - Asaf Modelevsky discovered that the Intel 10GbE PCI Express Ethernet driver for the Linux kernel performed insufficient control flow management. A local attacker could possibly use this to cause a denial of service. It was discovered that the virtual terminal driver in the Linux kernel did not properly handle VGA console font changes, leading to an out-of-bounds write. A local attacker could use this to cause a denial of service or possibly execute arbitrary code.

Ubuntu Security Notice USN-5598-1

Ubuntu Security Notice 5598-1 - It was discovered that the virtual terminal driver in the Linux kernel did not properly handle VGA console font changes, leading to an out-of-bounds write. A local attacker could use this to cause a denial of service or possibly execute arbitrary code.

Ubuntu Security Notice USN-5595-1

Ubuntu Security Notice 5595-1 - Asaf Modelevsky discovered that the Intel 10GbE PCI Express Ethernet driver for the Linux kernel performed insufficient control flow management. A local attacker could possibly use this to cause a denial of service. It was discovered that the virtual terminal driver in the Linux kernel did not properly handle VGA console font changes, leading to an out-of-bounds write. A local attacker could use this to cause a denial of service or possibly execute arbitrary code.

Ubuntu Security Notice USN-5591-4

Ubuntu Security Notice 5591-4 - It was discovered that the virtual terminal driver in the Linux kernel did not properly handle VGA console font changes, leading to an out-of-bounds write. A local attacker could use this to cause a denial of service or possibly execute arbitrary code.

Ubuntu Security Notice USN-5592-1

Ubuntu Security Notice 5592-1 - Asaf Modelevsky discovered that the Intel 10GbE PCI Express Ethernet driver for the Linux kernel performed insufficient control flow management. A local attacker could possibly use this to cause a denial of service. It was discovered that the virtual terminal driver in the Linux kernel did not properly handle VGA console font changes, leading to an out-of-bounds write. A local attacker could use this to cause a denial of service or possibly execute arbitrary code.

Ubuntu Security Notice USN-5591-3

Ubuntu Security Notice 5591-3 - It was discovered that the virtual terminal driver in the Linux kernel did not properly handle VGA console font changes, leading to an out-of-bounds write. A local attacker could use this to cause a denial of service or possibly execute arbitrary code.

Ubuntu Security Notice USN-5591-2

Ubuntu Security Notice 5591-2 - It was discovered that the virtual terminal driver in the Linux kernel did not properly handle VGA console font changes, leading to an out-of-bounds write. A local attacker could use this to cause a denial of service or possibly execute arbitrary code.

Ubuntu Security Notice USN-5591-1

Ubuntu Security Notice 5591-1 - It was discovered that the virtual terminal driver in the Linux kernel did not properly handle VGA console font changes, leading to an out-of-bounds write. A local attacker could use this to cause a denial of service or possibly execute arbitrary code.

Ubuntu Security Notice USN-5589-1

Ubuntu Security Notice 5589-1 - Asaf Modelevsky discovered that the Intel 10GbE PCI Express Ethernet driver for the Linux kernel performed insufficient control flow management. A local attacker could possibly use this to cause a denial of service. It was discovered that the virtual terminal driver in the Linux kernel did not properly handle VGA console font changes, leading to an out-of-bounds write. A local attacker could use this to cause a denial of service or possibly execute arbitrary code.

Ubuntu Security Notice USN-5580-1

Ubuntu Security Notice 5580-1 - It was discovered that the framebuffer driver on the Linux kernel did not verify size limits when changing font or screen size, leading to an out-of-bounds write. A local attacker could use this to cause a denial of service or possibly execute arbitrary code. It was discovered that the virtual terminal driver in the Linux kernel did not properly handle VGA console font changes, leading to an out-of-bounds write. A local attacker could use this to cause a denial of service or possibly execute arbitrary code.

CVE: Latest News

CVE-2023-50976: Transactions API Authorization by oleiman · Pull Request #14969 · redpanda-data/redpanda
CVE-2023-6905
CVE-2023-6903
CVE-2023-6904
CVE-2023-3907