Commit ce51f63e authored by Peilin Ye's avatar Peilin Ye Committed by David S. Miller

net/smc: Prevent kernel-infoleak in __smc_diag_dump()

__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: 4b1b7d3b ("net/smc: add SMC-D diag support")
Suggested-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: default avatarPeilin Ye <yepeilin.cs@gmail.com>
Signed-off-by: default avatarUrsula Braun <ubraun@linux.ibm.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 3e659a82
...@@ -170,13 +170,15 @@ static int __smc_diag_dump(struct sock *sk, struct sk_buff *skb, ...@@ -170,13 +170,15 @@ static int __smc_diag_dump(struct sock *sk, struct sk_buff *skb,
(req->diag_ext & (1 << (SMC_DIAG_DMBINFO - 1))) && (req->diag_ext & (1 << (SMC_DIAG_DMBINFO - 1))) &&
!list_empty(&smc->conn.lgr->list)) { !list_empty(&smc->conn.lgr->list)) {
struct smc_connection *conn = &smc->conn; struct smc_connection *conn = &smc->conn;
struct smcd_diag_dmbinfo dinfo = { struct smcd_diag_dmbinfo dinfo;
.linkid = *((u32 *)conn->lgr->id),
.peer_gid = conn->lgr->peer_gid, memset(&dinfo, 0, sizeof(dinfo));
.my_gid = conn->lgr->smcd->local_gid,
.token = conn->rmb_desc->token, dinfo.linkid = *((u32 *)conn->lgr->id);
.peer_token = conn->peer_token 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) if (nla_put(skb, SMC_DIAG_DMBINFO, sizeof(dinfo), &dinfo) < 0)
goto errout; goto errout;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment