netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] smc: fix out of bound access in smc_nl_get_sys_info()
@ 2020-12-30  0:48 Jakub Kicinski
  2021-01-04 11:53 ` Karsten Graul
  0 siblings, 1 reply; 2+ messages in thread
From: Jakub Kicinski @ 2020-12-30  0:48 UTC (permalink / raw)
  To: davem
  Cc: kgraul, guvenc, linux-s390, netdev, Jakub Kicinski,
	syzbot+f4708c391121cfc58396

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: 099b990bd11a ("net/smc: Add support for obtaining system information")
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
 net/smc/smc_core.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/smc/smc_core.c b/net/smc/smc_core.c
index 59342b519e34..8d866b4ed8f6 100644
--- a/net/smc/smc_core.c
+++ b/net/smc/smc_core.c
@@ -246,7 +246,8 @@ int smc_nl_get_sys_info(struct sk_buff *skb, struct netlink_callback *cb)
 		goto errattr;
 	smc_clc_get_hostname(&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))
 			goto errattr;
 	}
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-01-04 11:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-12-30  0:48 [PATCH net] smc: fix out of bound access in smc_nl_get_sys_info() Jakub Kicinski
2021-01-04 11:53 ` Karsten Graul

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).