summaryrefslogtreecommitdiffstats
path: root/net/smc
diff options
context:
space:
mode:
authorPeilin Ye <yepeilin.cs@gmail.com>2020-08-20 16:30:52 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2020-09-03 11:24:17 +0200
commit7c8c02c99b25e491a8ac7ed21cbedb327a2d2728 (patch)
treea7e516c391a7a3661be3c6a30fb3719f1277c7e3 /net/smc
parent8a794b35f625761a24bf7b0b32ce94a266ff2729 (diff)
downloadlinux-stable-7c8c02c99b25e491a8ac7ed21cbedb327a2d2728.tar.gz
linux-stable-7c8c02c99b25e491a8ac7ed21cbedb327a2d2728.tar.bz2
linux-stable-7c8c02c99b25e491a8ac7ed21cbedb327a2d2728.zip
net/smc: Prevent kernel-infoleak in __smc_diag_dump()
[ Upstream commit ce51f63e63c52a4e1eee4dd040fb0ba0af3b43ab ] __smc_diag_dump() is potentially copying uninitialized kernel stack memory into socket buffers, since the compiler may leave a 4-byte hole near the beginning of `struct smcd_diag_dmbinfo`. Fix it by initializing `dinfo` with memset(). Fixes: 4b1b7d3b30a6 ("net/smc: add SMC-D diag support") Suggested-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Peilin Ye <yepeilin.cs@gmail.com> Signed-off-by: Ursula Braun <ubraun@linux.ibm.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'net/smc')
-rw-r--r--net/smc/smc_diag.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/net/smc/smc_diag.c b/net/smc/smc_diag.c
index 2379a02c319d..6c4a7a5938b7 100644
--- a/net/smc/smc_diag.c
+++ b/net/smc/smc_diag.c
@@ -169,13 +169,15 @@ static int __smc_diag_dump(struct sock *sk, struct sk_buff *skb,
(req->diag_ext & (1 << (SMC_DIAG_DMBINFO - 1))) &&
!list_empty(&smc->conn.lgr->list)) {
struct smc_connection *conn = &smc->conn;
- struct smcd_diag_dmbinfo dinfo = {
- .linkid = *((u32 *)conn->lgr->id),
- .peer_gid = conn->lgr->peer_gid,
- .my_gid = conn->lgr->smcd->local_gid,
- .token = conn->rmb_desc->token,
- .peer_token = conn->peer_token
- };
+ struct smcd_diag_dmbinfo dinfo;
+
+ memset(&dinfo, 0, sizeof(dinfo));
+
+ dinfo.linkid = *((u32 *)conn->lgr->id);
+ dinfo.peer_gid = conn->lgr->peer_gid;
+ dinfo.my_gid = conn->lgr->smcd->local_gid;
+ dinfo.token = conn->rmb_desc->token;
+ dinfo.peer_token = conn->peer_token;
if (nla_put(skb, SMC_DIAG_DMBINFO, sizeof(dinfo), &dinfo) < 0)
goto errout;