smc: fix out of bound access in smc_nl_get_sys_info()
smc_clc_get_hostname() sets the host pointer to a buffer
which is not NULL-terminated (see smc_clc_init()).
Reported-by: syzbot+f4708c391121cfc58396@syzkaller.appspotmail.com
Fixes: 099b990bd1
("net/smc: Add support for obtaining system information")
Signed-off-by: Karsten Graul <kgraul@linux.ibm.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
parent
584c19f927
commit
25fe2c9c4c
|
@ -246,7 +246,8 @@ int smc_nl_get_sys_info(struct sk_buff *skb, struct netlink_callback *cb)
|
||||||
goto errattr;
|
goto errattr;
|
||||||
smc_clc_get_hostname(&host);
|
smc_clc_get_hostname(&host);
|
||||||
if (host) {
|
if (host) {
|
||||||
snprintf(hostname, sizeof(hostname), "%s", host);
|
memcpy(hostname, host, SMC_MAX_HOSTNAME_LEN);
|
||||||
|
hostname[SMC_MAX_HOSTNAME_LEN] = 0;
|
||||||
if (nla_put_string(skb, SMC_NLA_SYS_LOCAL_HOST, hostname))
|
if (nla_put_string(skb, SMC_NLA_SYS_LOCAL_HOST, hostname))
|
||||||
goto errattr;
|
goto errattr;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue