Commit bd048df6 authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] con_font_default sanitized

->con_font_default() sanitized.  We copy font name (if any) from userland
in the caller and pass it explicitly.  We are also beginning to get rid
of console_font_op in method arguments.
Signed-off-by: default avatarAl Viro <viro@parcelfarce.linux.org.uk>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent a95b87ea
......@@ -100,6 +100,7 @@
#include <linux/workqueue.h>
#include <linux/bootmem.h>
#include <linux/pm.h>
#include <linux/font.h>
#include <asm/io.h>
#include <asm/system.h>
......@@ -3139,17 +3140,31 @@ int con_font_set(int currcons, struct console_font_op *op)
int con_font_default(int currcons, struct console_font_op *op)
{
struct console_font font = {.width = op->width, .height = op->height};
char name[MAX_FONT_NAME];
char *s = name;
int rc;
if (vt_cons[currcons]->vc_mode != KD_TEXT)
return -EINVAL;
if (!op->data)
s = NULL;
else if (strncpy_from_user(name, op->data, MAX_FONT_NAME - 1) < 0)
return -EFAULT;
else
name[MAX_FONT_NAME - 1] = 0;
acquire_console_sem();
if (sw->con_font_default)
rc = sw->con_font_default(vc_cons[currcons].d, op);
rc = sw->con_font_default(vc_cons[currcons].d, &font, s);
else
rc = -ENOSYS;
release_console_sem();
if (!rc) {
op->width = font.width;
op->height = font.height;
}
return rc;
}
......
......@@ -2272,24 +2272,21 @@ static int fbcon_set_font(struct vc_data *vc, struct console_font_op *op)
return fbcon_do_set_font(vc, op, new_data, 1);
}
static int fbcon_set_def_font(struct vc_data *vc, struct console_font_op *op)
static int fbcon_set_def_font(struct vc_data *vc, struct console_font *font, char *name)
{
struct fb_info *info = registered_fb[(int) con2fb_map[vc->vc_num]];
char name[MAX_FONT_NAME];
struct font_desc *f;
struct console_font_op crap;
if (!op->data)
if (!name)
f = get_default_font(info->var.xres, info->var.yres);
else if (strncpy_from_user(name, op->data, MAX_FONT_NAME - 1) < 0)
return -EFAULT;
else {
name[MAX_FONT_NAME - 1] = 0;
if (!(f = find_font(name)))
else if (!(f = find_font(name)))
return -ENOENT;
}
op->width = f->width;
op->height = f->height;
return fbcon_do_set_font(vc, op, f->data, 0);
crap.op = KD_FONT_OP_SET_DEFAULT;
crap.width = font->width = f->width;
crap.height = font->height = f->height;
return fbcon_do_set_font(vc, &crap, f->data, 0);
}
static u16 palette_red[16];
......
......@@ -52,7 +52,7 @@ static int xcurs_correction = 29;
static int newport_xsize;
static int newport_ysize;
static int newport_set_def_font(int unit, struct console_font_op *op);
static int newport_set_def_font(int unit, struct console_font *op);
#define BMASK(c) (c << 24)
......@@ -531,7 +531,7 @@ static int newport_set_font(int unit, struct console_font_op *op)
return 0;
}
static int newport_set_def_font(int unit, struct console_font_op *op)
static int newport_set_def_font(int unit, struct console_font *op)
{
if (font_data[unit] != FONT_DATA) {
if (--REFCOUNT(font_data[unit]) == 0)
......@@ -543,7 +543,7 @@ static int newport_set_def_font(int unit, struct console_font_op *op)
return 0;
}
static int newport_font_default(struct vc_data *vc, struct console_font_op *op)
static int newport_font_default(struct vc_data *vc, struct console_font *op, char *name)
{
return newport_set_def_font(vc->vc_num, op);
}
......
......@@ -19,6 +19,7 @@
struct vc_data;
struct console_font_op;
struct console_font;
struct module;
/*
......@@ -42,7 +43,7 @@ struct consw {
int (*con_blank)(struct vc_data *, int, int);
int (*con_font_set)(struct vc_data *, struct console_font_op *);
int (*con_font_get)(struct vc_data *, struct console_font_op *);
int (*con_font_default)(struct vc_data *, struct console_font_op *);
int (*con_font_default)(struct vc_data *, struct console_font *, char *);
int (*con_font_copy)(struct vc_data *, struct console_font_op *);
int (*con_resize)(struct vc_data *, unsigned int, unsigned int);
int (*con_set_palette)(struct vc_data *, unsigned char *);
......
......@@ -152,6 +152,12 @@ struct console_font_op {
unsigned char *data; /* font data with height fixed to 32 */
};
struct console_font {
unsigned int width, height; /* font size */
unsigned int charcount;
unsigned char *data; /* font data with height fixed to 32 */
};
#define KD_FONT_OP_SET 0 /* Set font */
#define KD_FONT_OP_GET 1 /* Get font */
#define KD_FONT_OP_SET_DEFAULT 2 /* Set font to default, data points to name / NULL */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment