aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorColin Ian King <colin.king@canonical.com>2018-12-18 12:29:56 -0500
committerThomas Gleixner <tglx@linutronix.de>2018-12-18 18:00:16 -0500
commit32043fa065b51e0b1433e48d118821c71b5cd65d (patch)
tree094fdcdbc7efd6d5eca4287755face6de178256c
parent87ab4689ca6526079ab6f5150219ee88b42000ae (diff)
x86/mtrr: Don't copy uninitialized gentry fields back to userspace
Currently the copy_to_user of data in the gentry struct is copying uninitiaized data in field _pad from the stack to userspace. Fix this by explicitly memset'ing gentry to zero, this also will zero any compiler added padding fields that may be in struct (currently there are none). Detected by CoverityScan, CID#200783 ("Uninitialized scalar variable") Fixes: b263b31e8ad6 ("x86, mtrr: Use explicit sizing and padding for the 64-bit ioctls") Signed-off-by: Colin Ian King <colin.king@canonical.com> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Reviewed-by: Tyler Hicks <tyhicks@canonical.com> Cc: security@kernel.org Link: https://lkml.kernel.org/r/20181218172956.1440-1-colin.king@canonical.com
-rw-r--r--arch/x86/kernel/cpu/mtrr/if.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/arch/x86/kernel/cpu/mtrr/if.c b/arch/x86/kernel/cpu/mtrr/if.c
index 2e173d47b450..4d36dcc1cf87 100644
--- a/arch/x86/kernel/cpu/mtrr/if.c
+++ b/arch/x86/kernel/cpu/mtrr/if.c
@@ -165,6 +165,8 @@ mtrr_ioctl(struct file *file, unsigned int cmd, unsigned long __arg)
165 struct mtrr_gentry gentry; 165 struct mtrr_gentry gentry;
166 void __user *arg = (void __user *) __arg; 166 void __user *arg = (void __user *) __arg;
167 167
168 memset(&gentry, 0, sizeof(gentry));
169
168 switch (cmd) { 170 switch (cmd) {
169 case MTRRIOC_ADD_ENTRY: 171 case MTRRIOC_ADD_ENTRY:
170 case MTRRIOC_SET_ENTRY: 172 case MTRRIOC_SET_ENTRY: