From: Karsten Graul <kgraul@linux.ibm.com>
To: Jakub Kicinski <kuba@kernel.org>, davem@davemloft.net
Cc: guvenc@linux.ibm.com, linux-s390@vger.kernel.org,
netdev@vger.kernel.org,
syzbot+f4708c391121cfc58396@syzkaller.appspotmail.com
Subject: Re: [PATCH net] smc: fix out of bound access in smc_nl_get_sys_info()
Date: Mon, 4 Jan 2021 12:53:49 +0100 [thread overview]
Message-ID: <4ca9487e-2834-1c45-68eb-a6be8be671d3@linux.ibm.com> (raw)
In-Reply-To: <20201230004841.1472141-1-kuba@kernel.org>
Thank you Jakub,
this patch solves the out of bounds access due to snprintf() copying size bytes first
and overwriting the last byte with null afterwards.
We will include your patch in our next series for the net tree soon.
Reviewed-by: Karsten Graul <kgraul@linux.ibm.com>
On 30/12/2020 01:48, Jakub Kicinski wrote:
> 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;
> }
>
--
Karsten
(I'm a dude)
prev parent reply other threads:[~2021-01-04 11:54 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
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 message]
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=4ca9487e-2834-1c45-68eb-a6be8be671d3@linux.ibm.com \
--to=kgraul@linux.ibm.com \
--cc=davem@davemloft.net \
--cc=guvenc@linux.ibm.com \
--cc=kuba@kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=syzbot+f4708c391121cfc58396@syzkaller.appspotmail.com \
/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