x86/insn-eval: Fix use-after-free access to LDT entry
authorJann Horn <jannh@google.com>
Sun, 2 Jun 2019 01:15:58 +0000 (03:15 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 11 Jun 2019 10:20:52 +0000 (12:20 +0200)
commitb598ddc7b9fc87b09bdadb63abf92b4ba46cd385
tree9c06b9ef789c0aa03f7224c58229afc3090a1aaa
parent4d166206cf418122ab01c4206b979d328e55e923
x86/insn-eval: Fix use-after-free access to LDT entry

commit de9f869616dd95e95c00bdd6b0fcd3421e8a4323 upstream.

get_desc() computes a pointer into the LDT while holding a lock that
protects the LDT from being freed, but then drops the lock and returns the
(now potentially dangling) pointer to its caller.

Fix it by giving the caller a copy of the LDT entry instead.

Fixes: 670f928ba09b ("x86/insn-eval: Add utility function to get segment descriptor")
Cc: stable@vger.kernel.org
Signed-off-by: Jann Horn <jannh@google.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/x86/lib/insn-eval.c