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

[PATCH] sparse (compat_ioctl): font stuff

	Annotated, cleaned up, wholesale copying of structure with
subsequeunt casts from hell replaced with get_user()/put_user() on
the fields we really need.
parent ca861007
...@@ -1619,19 +1619,14 @@ struct consolefontdesc32 { ...@@ -1619,19 +1619,14 @@ struct consolefontdesc32 {
static int do_fontx_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg, struct file *file) static int do_fontx_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg, struct file *file)
{ {
struct consolefontdesc cfdarg; struct consolefontdesc32 __user *user_cfd = compat_ptr(arg);
struct console_font_op op; struct console_font_op op;
struct consolefontdesc32 *user_cfd = compat_ptr(arg); compat_caddr_t data;
int i, perm; int i, perm;
perm = vt_check(file); perm = vt_check(file);
if (perm < 0) return perm; if (perm < 0) return perm;
if (copy_from_user(&cfdarg, user_cfd, sizeof(struct consolefontdesc32)))
return -EFAULT;
cfdarg.chardata = compat_ptr(((struct consolefontdesc32 *)&cfdarg)->chardata);
switch (cmd) { switch (cmd) {
case PIO_FONTX: case PIO_FONTX:
if (!perm) if (!perm)
...@@ -1639,26 +1634,30 @@ static int do_fontx_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg, ...@@ -1639,26 +1634,30 @@ static int do_fontx_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg,
op.op = KD_FONT_OP_SET; op.op = KD_FONT_OP_SET;
op.flags = 0; op.flags = 0;
op.width = 8; op.width = 8;
op.height = cfdarg.charheight; if (get_user(op.height, &user_cfd->charheight) ||
op.charcount = cfdarg.charcount; get_user(op.charcount, &user_cfd->charcount) ||
op.data = cfdarg.chardata; get_user(data, &user_cfd->chardata))
return -EFAULT;
op.data = compat_ptr(data);
return con_font_op(fg_console, &op); return con_font_op(fg_console, &op);
case GIO_FONTX: case GIO_FONTX:
if (!cfdarg.chardata)
return 0;
op.op = KD_FONT_OP_GET; op.op = KD_FONT_OP_GET;
op.flags = 0; op.flags = 0;
op.width = 8; op.width = 8;
op.height = cfdarg.charheight; if (get_user(op.height, &user_cfd->charheight) ||
op.charcount = cfdarg.charcount; get_user(op.charcount, &user_cfd->charcount) ||
op.data = cfdarg.chardata; get_user(data, &user_cfd->chardata))
return -EFAULT;
if (!data)
return 0;
op.data = compat_ptr(data);
i = con_font_op(fg_console, &op); i = con_font_op(fg_console, &op);
if (i) if (i)
return i; return i;
cfdarg.charheight = op.height; if (put_user(op.height, &user_cfd->charheight) ||
cfdarg.charcount = op.charcount; put_user(op.charcount, &user_cfd->charcount) ||
((struct consolefontdesc32 *)&cfdarg)->chardata = (unsigned long)cfdarg.chardata; put_user((compat_caddr_t)(unsigned long)op.data,
if (copy_to_user(user_cfd, &cfdarg, sizeof(struct consolefontdesc32))) &user_cfd->chardata))
return -EFAULT; return -EFAULT;
return 0; return 0;
} }
......
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