OSDN Git Service

x86/mm/mem_encrypt: Fix erroneous sizeof()
authorPeng Hao <peng.hao2@zte.com.cn>
Sat, 29 Dec 2018 06:34:12 +0000 (14:34 +0800)
committerThomas Gleixner <tglx@linutronix.de>
Tue, 15 Jan 2019 10:41:58 +0000 (11:41 +0100)
commitbf7d28c53453ea904584960de55e33e03b9d93b1
tree64d3ba0f78a21c8db434101fb3e826d3b4c0a192
parente1812933b17be7814f51b6c310c5d1ced7a9a5f5
x86/mm/mem_encrypt: Fix erroneous sizeof()

Using sizeof(pointer) for determining the size of a memset() only works
when the size of the pointer and the size of type to which it points are
the same. For pte_t this is only true for 64bit and 32bit-NONPAE. On 32bit
PAE systems this is wrong as the pointer size is 4 byte but the PTE entry
is 8 bytes. It's actually not a real world issue as this code depends on
64bit, but it's wrong nevertheless.

Use sizeof(*p) for correctness sake.

Fixes: aad983913d77 ("x86/mm/encrypt: Simplify sme_populate_pgd() and sme_populate_pgd_large()")
Signed-off-by: Peng Hao <peng.hao2@zte.com.cn>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Cc: Tom Lendacky <thomas.lendacky@amd.com>
Cc: dave.hansen@linux.intel.com
Cc: peterz@infradead.org
Cc: luto@kernel.org
Link: https://lkml.kernel.org/r/1546065252-97996-1-git-send-email-peng.hao2@zte.com.cn
arch/x86/mm/mem_encrypt_identity.c