Skip to content

Commit 2717769

Browse files
npitregregkh
authored andcommitted
vt: don't hardcode the mem allocation upper bound
The code in vc_do_resize() bounds the memory allocation size to avoid exceeding MAX_ORDER down the kzalloc() call chain and generating a runtime warning triggerable from user space. However, not only is it unwise to use a literal value here, but MAX_ORDER may also be configurable based on CONFIG_FORCE_MAX_ZONEORDER. Let's use KMALLOC_MAX_SIZE instead. Note that prior commit bb1107f ("mm, slab: make sure that KMALLOC_MAX_SIZE will fit into MAX_ORDER") the KMALLOC_MAX_SIZE value could not be relied upon. Signed-off-by: Nicolas Pitre <[email protected]> Cc: <[email protected]> # v4.10+ Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent abf42d2 commit 2717769

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/tty/vt/vt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1207,7 +1207,7 @@ static int vc_do_resize(struct tty_struct *tty, struct vc_data *vc,
12071207
if (new_cols == vc->vc_cols && new_rows == vc->vc_rows)
12081208
return 0;
12091209

1210-
if (new_screen_size > (4 << 20))
1210+
if (new_screen_size > KMALLOC_MAX_SIZE)
12111211
return -EINVAL;
12121212
newscreen = kzalloc(new_screen_size, GFP_USER);
12131213
if (!newscreen)

0 commit comments

Comments
 (0)