Skip to content

Commit d0fa6ea

Browse files
committed
Merge branch 'x86-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull x86 fixes from Thomas Gleixner: - Expand the space for uncompressing as the LZ4 worst case does not fit into the currently reserved space - Validate boot parameters more strictly to prevent out of bound access in the decompressor/boot code - Fix off by one errors in get_segment_base() * 'x86-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: x86/boot: Prevent faulty bootparams.screeninfo from causing harm x86/boot: Provide more slack space during decompression x86/ldt: Fix off by one in get_segment_base()
2 parents 3b62dc6 + fb1cc2f commit d0fa6ea

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

arch/x86/boot/compressed/misc.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,7 @@ void __putstr(const char *s)
116116
}
117117
}
118118

119-
if (boot_params->screen_info.orig_video_mode == 0 &&
120-
lines == 0 && cols == 0)
119+
if (lines == 0 || cols == 0)
121120
return;
122121

123122
x = boot_params->screen_info.orig_x;

arch/x86/boot/header.S

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -520,8 +520,14 @@ pref_address: .quad LOAD_PHYSICAL_ADDR # preferred load addr
520520
# the description in lib/decompressor_xxx.c for specific information.
521521
#
522522
# extra_bytes = (uncompressed_size >> 12) + 65536 + 128
523+
#
524+
# LZ4 is even worse: data that cannot be further compressed grows by 0.4%,
525+
# or one byte per 256 bytes. OTOH, we can safely get rid of the +128 as
526+
# the size-dependent part now grows so fast.
527+
#
528+
# extra_bytes = (uncompressed_size >> 8) + 65536
523529

524-
#define ZO_z_extra_bytes ((ZO_z_output_len >> 12) + 65536 + 128)
530+
#define ZO_z_extra_bytes ((ZO_z_output_len >> 8) + 65536)
525531
#if ZO_z_output_len > ZO_z_input_len
526532
# define ZO_z_extract_offset (ZO_z_output_len + ZO_z_extra_bytes - \
527533
ZO_z_input_len)

arch/x86/events/core.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2335,20 +2335,17 @@ static unsigned long get_segment_base(unsigned int segment)
23352335
#ifdef CONFIG_MODIFY_LDT_SYSCALL
23362336
struct ldt_struct *ldt;
23372337

2338-
if (idx > LDT_ENTRIES)
2339-
return 0;
2340-
23412338
/* IRQs are off, so this synchronizes with smp_store_release */
23422339
ldt = lockless_dereference(current->active_mm->context.ldt);
2343-
if (!ldt || idx > ldt->nr_entries)
2340+
if (!ldt || idx >= ldt->nr_entries)
23442341
return 0;
23452342

23462343
desc = &ldt->entries[idx];
23472344
#else
23482345
return 0;
23492346
#endif
23502347
} else {
2351-
if (idx > GDT_ENTRIES)
2348+
if (idx >= GDT_ENTRIES)
23522349
return 0;
23532350

23542351
desc = raw_cpu_ptr(gdt_page.gdt) + idx;

0 commit comments

Comments
 (0)