From: Sasha Levin <sashal@kernel.org>
To: stable@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Colin Ian King <colin.king@canonical.com>,
Thomas Gleixner <tglx@linutronix.de>,
security@kernel.org, Sasha Levin <sashal@kernel.org>
Subject: [PATCH AUTOSEL 3.18 08/12] x86/mtrr: Don't copy uninitialized gentry fields back to userspace
Date: Wed, 26 Dec 2018 17:57:36 -0500 [thread overview]
Message-ID: <20181226225741.151608-8-sashal@kernel.org> (raw)
In-Reply-To: <20181226225741.151608-1-sashal@kernel.org>
From: Colin Ian King <colin.king@canonical.com>
[ Upstream commit 32043fa065b51e0b1433e48d118821c71b5cd65d ]
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
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
arch/x86/kernel/cpu/mtrr/if.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/arch/x86/kernel/cpu/mtrr/if.c b/arch/x86/kernel/cpu/mtrr/if.c
index a041e094b8b9..5598de02d2b4 100644
--- a/arch/x86/kernel/cpu/mtrr/if.c
+++ b/arch/x86/kernel/cpu/mtrr/if.c
@@ -173,6 +173,8 @@ mtrr_ioctl(struct file *file, unsigned int cmd, unsigned long __arg)
struct mtrr_gentry gentry;
void __user *arg = (void __user *) __arg;
+ memset(&gentry, 0, sizeof(gentry));
+
switch (cmd) {
case MTRRIOC_ADD_ENTRY:
case MTRRIOC_SET_ENTRY:
--
2.19.1
next prev parent reply other threads:[~2018-12-26 23:23 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-26 22:57 [PATCH AUTOSEL 3.18 01/12] powerpc: Fix COFF zImage booting on old powermacs Sasha Levin
2018-12-26 22:57 ` [PATCH AUTOSEL 3.18 02/12] checkstack.pl: fix for aarch64 Sasha Levin
2018-12-26 22:57 ` [PATCH AUTOSEL 3.18 03/12] xfrm: Fix bucket count reported to userspace Sasha Levin
2018-12-26 22:57 ` [PATCH AUTOSEL 3.18 04/12] Input: omap-keypad - fix idle configuration to not block SoC idle states Sasha Levin
2018-12-26 22:57 ` [PATCH AUTOSEL 3.18 05/12] USB: hso: Fix OOB memory access in hso_probe/hso_get_config_data Sasha Levin
2018-12-26 22:57 ` [PATCH AUTOSEL 3.18 06/12] bnx2x: Clear fip MAC when fcoe offload support is disabled Sasha Levin
2018-12-26 22:57 ` [PATCH AUTOSEL 3.18 07/12] w90p910_ether: remove incorrect __init annotation Sasha Levin
2018-12-26 22:57 ` Sasha Levin [this message]
2018-12-26 22:57 ` [PATCH AUTOSEL 3.18 09/12] xen/netfront: tolerate frags with no data Sasha Levin
2018-12-26 22:57 ` [PATCH AUTOSEL 3.18 10/12] vxge: ensure data0 is initialized in when fetching firmware version information Sasha Levin
2018-12-26 22:57 ` [PATCH AUTOSEL 3.18 11/12] net: netxen: fix a missing check and an uninitialized use Sasha Levin
2018-12-26 22:57 ` [PATCH AUTOSEL 3.18 12/12] serial/sunsu: fix refcount leak Sasha Levin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20181226225741.151608-8-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=colin.king@canonical.com \
--cc=linux-kernel@vger.kernel.org \
--cc=security@kernel.org \
--cc=stable@vger.kernel.org \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox