From: Phillip Potter <phil@philpotter.co.uk>
To: davem@davemloft.net
Cc: kuba@kernel.org, yhs@fb.com, ast@kernel.org,
johannes.berg@intel.com, rdunlap@infradead.org,
0x7f454c46@gmail.com, yangyingliang@huawei.com,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] netlink: netlink_sendmsg: memset unused tail bytes in skb
Date: Sun, 9 May 2021 13:18:58 +0100 [thread overview]
Message-ID: <20210509121858.1232583-1-phil@philpotter.co.uk> (raw)
When allocating the skb within netlink_sendmsg, with certain supplied
len arguments, extra bytes are allocated at the end of the data buffer,
due to SKB_DATA_ALIGN giving a larger size within __alloc_skb for
alignment reasons. This means that after using skb_put with the same
len value and then copying data into the skb, the skb tail area is
non-zero in size and contains uninitialised bytes. Wiping this area
(if it exists) fixes a KMSAN-found uninit-value bug reported by syzbot at:
https://syzkaller.appspot.com/bug?id=3e63bcec536b7136b54c72e06adeb87dc6519f69
Reported-by: syzbot+a73d24a22eeeebe5f244@syzkaller.appspotmail.com
Signed-off-by: Phillip Potter <phil@philpotter.co.uk>
---
net/netlink/af_netlink.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
index 3a62f97acf39..e54321b63f98 100644
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -1914,6 +1914,9 @@ static int netlink_sendmsg(struct socket *sock, struct msghdr *msg, size_t len)
goto out;
}
+ if (skb->end - skb->tail)
+ memset(skb_tail_pointer(skb), 0, skb->end - skb->tail);
+
err = security_netlink_send(sk, skb);
if (err) {
kfree_skb(skb);
--
2.30.2
next reply other threads:[~2021-05-09 12:19 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-09 12:18 Phillip Potter [this message]
2021-05-09 13:10 ` [PATCH] netlink: netlink_sendmsg: memset unused tail bytes in skb Florian Westphal
2021-05-11 22:17 ` Phillip Potter
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=20210509121858.1232583-1-phil@philpotter.co.uk \
--to=phil@philpotter.co.uk \
--cc=0x7f454c46@gmail.com \
--cc=ast@kernel.org \
--cc=davem@davemloft.net \
--cc=johannes.berg@intel.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=rdunlap@infradead.org \
--cc=yangyingliang@huawei.com \
--cc=yhs@fb.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;
as well as URLs for NNTP newsgroup(s).