target/i386/tcg: Check for valid descriptor table before loading segment descriptor
PATCH 1/1 target/i386/tcg: Check for valid descriptor table before loading segment descriptor
LSL and LAR can cause segmentation faults in certain scenarios under QEMU. This occurs particularly when the base of either GDT or LDT depending on bit 2 of selector is NULL.
On real CPU, invalid LSL/LAR does nothing besides clearing ZF.
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1376
Signed-off-by Rayhan Faizel <[email protected]>
--- target/i386/tcg/seg_helper.c | 4 ++++ 1 file changed, 4 insertions(+)
target/i386/tcg/seg_helper.c +4 -0
@@ -78,6 +78,10 @@ static inline int load_segment_ra(CPUX86State *env, uint32_t *e1_ptr, }else { dt = &env->gdt; } +/* Check valid DT base before fetching segment descriptor*/ +if (!dt->base) { +return -1 ; + } index = selector & ~7 ;if ((index +7 ) > dt->limit) {return -1 ;
Signature · 1 line
2.41.0