vt: Don't exceed max_font_size on copy in con_font_get()
PATCH 1/1 vt: Don't exceed max_font_size on copy in con_font_get()
font.data is kmallocd with max_font_size (defined 65536). Below occurs a copy_to_user with `c' as a size argument. Ensure we don't copy too much.
--- drivers/char/vt.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)
If it is possible for c to be greater than 65536 then I think we may need this. Correct?
drivers/char/vt.c +4 -0
@@ -3861,6 +3861,10 @@ static int con_font_get(struct vc_data *vc, struct console_font_op *op) goto out; c = (font.width+7 )/8 *32 * font.charcount; +if (c > max_font_size) { + rc = -EINVAL ; + goto out; + }if (op->data && font.charcount > op->charcount) rc = -ENOSPC ;
Quoted 16 lines · On Mon, 23 Nov 2009 21:23:42 +0100 Roel Kluin <[email protected]> wrote:
font.data is kmallocd with
max_font_size(defined 65536). Below occurs acopy_to_userwith `c' as a size argument. Ensure we don't copy too much.Signed-off-by Roel Kluin <[email protected]>--- drivers/char/vt.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)If it is possible for c to be greater than 65536 then I think we may need this. Correct?
drivers/char/vt.c +0
-0
drivers/char/vt.c static int con_font_get(struct vc_data *vc, struct console_font_op *op) · line 3870
Quoted 10 lines
drivers/char/vt.c +4
-0@@ -3861,6 +3861,10 @@ static int con_font_get(struct vc_data *vc, struct console_font_op *op) goto out; c = (font.width+7 )/8 *32 * font.charcount; +if (c > max_font_size) { + rc = -EINVAL ; + goto out; + }if (op->data && font.charcount > op->charcount) rc = -ENOSPC ;
Perhaps it is impossible for `c' to exceed max_font_size here. The check in con_font_set() will prevent it.
There are probably other places in the kernel which initialise a console_font_op, and perhaps one of those is buggy - I didn't check.