OSDN Git Service

tty: vt: remove multi-fetch, derive font.height from font.data
authorMeng Xu <mengxu.gatech@gmail.com>
Wed, 4 Oct 2017 14:38:37 +0000 (10:38 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 20 Oct 2017 12:06:45 +0000 (14:06 +0200)
commit8ffb82094be8ade4f5e60996edcc8afbbcb4f1f4
tree195660244223deea7a400ef67051e2079c98abf9
parentdd076cffb8cd675a8973fc9b6cea0c04be6f0111
tty: vt: remove multi-fetch, derive font.height from font.data

In con_font_set(), when we need to guess font height (for
compat reasons?), the current approach uses multiple userspace
fetches, i.e., get_user(tmp, &charmap[32*i+h-1]), to derive
the height. This has two drawbacks:

1. performance: accessing userspace memory is less efficient than
directly de-reference the byte

2. security: a more critical problem is that the height derived
might not match with the actual font.data. This is because a user
thread might race condition to change the memory of op->data after
the op->height guessing but before the second fetch: font.data =
memdup_user(op->data, size). Leaving font.height = 32 while the
actual height is 1 or vice-versa.

This patch tries to resolve both issues by re-locating the height
guessing part after the font.data is fetched in. In this way, the
userspace data is fetched in one shot and we directly dereference
the font.data in kernel space to probe for the height.

Signed-off-by: Meng Xu <mengxu.gatech@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/vt/vt.c