2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
* font.h -- `Soft' font definitions
|
|
|
|
*
|
|
|
|
* Created 1995 by Geert Uytterhoeven
|
|
|
|
*
|
|
|
|
* This file is subject to the terms and conditions of the GNU General Public
|
|
|
|
* License. See the file COPYING in the main directory of this archive
|
|
|
|
* for more details.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _VIDEO_FONT_H
|
|
|
|
#define _VIDEO_FONT_H
|
|
|
|
|
|
|
|
#include <linux/types.h>
|
|
|
|
|
|
|
|
struct font_desc {
|
|
|
|
int idx;
|
2005-09-13 16:25:44 +08:00
|
|
|
const char *name;
|
2005-04-17 06:20:36 +08:00
|
|
|
int width, height;
|
2005-09-13 16:25:44 +08:00
|
|
|
const void *data;
|
2005-04-17 06:20:36 +08:00
|
|
|
int pref;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define VGA8x8_IDX 0
|
|
|
|
#define VGA8x16_IDX 1
|
|
|
|
#define PEARL8x8_IDX 2
|
|
|
|
#define VGA6x11_IDX 3
|
2005-06-22 08:17:06 +08:00
|
|
|
#define FONT7x14_IDX 4
|
|
|
|
#define FONT10x18_IDX 5
|
|
|
|
#define SUN8x16_IDX 6
|
|
|
|
#define SUN12x22_IDX 7
|
|
|
|
#define ACORN8x8_IDX 8
|
|
|
|
#define MINI4x6_IDX 9
|
2014-09-09 19:46:28 +08:00
|
|
|
#define FONT6x10_IDX 10
|
2018-12-06 07:56:37 +08:00
|
|
|
#define TER16x32_IDX 11
|
2020-08-20 16:21:37 +08:00
|
|
|
#define FONT6x8_IDX 12
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2005-09-13 16:25:44 +08:00
|
|
|
extern const struct font_desc font_vga_8x8,
|
2005-06-22 08:17:06 +08:00
|
|
|
font_vga_8x16,
|
|
|
|
font_pearl_8x8,
|
|
|
|
font_vga_6x11,
|
|
|
|
font_7x14,
|
|
|
|
font_10x18,
|
|
|
|
font_sun_8x16,
|
|
|
|
font_sun_12x22,
|
|
|
|
font_acorn_8x8,
|
2014-09-09 19:46:28 +08:00
|
|
|
font_mini_4x6,
|
2018-12-06 07:56:37 +08:00
|
|
|
font_6x10,
|
2020-08-20 16:21:37 +08:00
|
|
|
font_ter_16x32,
|
|
|
|
font_6x8;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* Find a font with a specific name */
|
|
|
|
|
2005-09-13 16:25:44 +08:00
|
|
|
extern const struct font_desc *find_font(const char *name);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* Get the default font for a specific screen size */
|
|
|
|
|
2007-05-08 15:39:11 +08:00
|
|
|
extern const struct font_desc *get_default_font(int xres, int yres,
|
|
|
|
u32 font_w, u32 font_h);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* Max. length for the name of a predefined font */
|
|
|
|
#define MAX_FONT_NAME 32
|
|
|
|
|
2020-09-24 21:40:53 +08:00
|
|
|
/* Extra word getters */
|
|
|
|
#define REFCOUNT(fd) (((int *)(fd))[-1])
|
|
|
|
#define FNTSIZE(fd) (((int *)(fd))[-2])
|
|
|
|
#define FNTCHARCNT(fd) (((int *)(fd))[-3])
|
|
|
|
#define FNTSUM(fd) (((int *)(fd))[-4])
|
|
|
|
|
|
|
|
#define FONT_EXTRA_WORDS 4
|
|
|
|
|
Fonts: Support FONT_EXTRA_WORDS macros for built-in fonts
syzbot has reported an issue in the framebuffer layer, where a malicious
user may overflow our built-in font data buffers.
In order to perform a reliable range check, subsystems need to know
`FONTDATAMAX` for each built-in font. Unfortunately, our font descriptor,
`struct console_font` does not contain `FONTDATAMAX`, and is part of the
UAPI, making it infeasible to modify it.
For user-provided fonts, the framebuffer layer resolves this issue by
reserving four extra words at the beginning of data buffers. Later,
whenever a function needs to access them, it simply uses the following
macros:
Recently we have gathered all the above macros to <linux/font.h>. Let us
do the same thing for built-in fonts, prepend four extra words (including
`FONTDATAMAX`) to their data buffers, so that subsystems can use these
macros for all fonts, no matter built-in or user-provided.
This patch depends on patch "fbdev, newport_con: Move FONT_EXTRA_WORDS
macros into linux/font.h".
Cc: stable@vger.kernel.org
Link: https://syzkaller.appspot.com/bug?id=08b8be45afea11888776f897895aef9ad1c3ecfd
Signed-off-by: Peilin Ye <yepeilin.cs@gmail.com>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/ef18af00c35fb3cc826048a5f70924ed6ddce95b.1600953813.git.yepeilin.cs@gmail.com
2020-09-24 21:42:22 +08:00
|
|
|
struct font_data {
|
|
|
|
unsigned int extra[FONT_EXTRA_WORDS];
|
|
|
|
const unsigned char data[];
|
|
|
|
} __packed;
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
#endif /* _VIDEO_FONT_H */
|