Skip to content
This repository was archived by the owner on Jun 4, 2020. It is now read-only.

Commit 80f5fba

Browse files
j00rugregkh
authored andcommitted
decnet: dn_rtmsg: Improve input length sanitization in dnrmg_receive_user_skb
[ Upstream commit dd0da17b209ed91f39872766634ca967c170ada1 ] Verify that the length of the socket buffer is sufficient to cover the nlmsghdr structure before accessing the nlh->nlmsg_len field for further input sanitization. If the client only supplies 1-3 bytes of data in sk_buff, then nlh->nlmsg_len remains partially uninitialized and contains leftover memory from the corresponding kernel allocation. Operating on such data may result in indeterminate evaluation of the nlmsg_len < sizeof(*nlh) expression. The bug was discovered by a runtime instrumentation designed to detect use of uninitialized memory in the kernel. The patch prevents this and other similar tools (e.g. KMSAN) from flagging this behavior in the future. Signed-off-by: Mateusz Jurczyk <mjurczyk@google.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 0d487bc commit 80f5fba

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

net/decnet/netfilter/dn_rtmsg.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,9 @@ static inline void dnrmg_receive_user_skb(struct sk_buff *skb)
104104
{
105105
struct nlmsghdr *nlh = nlmsg_hdr(skb);
106106

107-
if (nlh->nlmsg_len < sizeof(*nlh) || skb->len < nlh->nlmsg_len)
107+
if (skb->len < sizeof(*nlh) ||
108+
nlh->nlmsg_len < sizeof(*nlh) ||
109+
skb->len < nlh->nlmsg_len)
108110
return;
109111

110112
if (!netlink_capable(skb, CAP_NET_ADMIN))

0 commit comments

Comments
 (0)