Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp2829687pxb; Mon, 19 Apr 2021 15:21:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwYadWQ9eoGpJAwCWmomuq69JYFRcQAvkgxx63gch7AvPy5kfE5ygKUBKO78LLXUL4rqDxy X-Received: by 2002:a17:902:fe8c:b029:ec:a2ef:4e3f with SMTP id x12-20020a170902fe8cb02900eca2ef4e3fmr8131187plm.36.1618870911657; Mon, 19 Apr 2021 15:21:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618870911; cv=none; d=google.com; s=arc-20160816; b=B+Dq9ht1B4j/QsdcG0lTAltrRUnioslF6R7osiCso+Ux/0BSebBMSwp/YaAtcH4ERx 8YoDjURsyEfVU1/sxKS5dAG/JTEapXi29Aq7/kRpi2kuZ3RhF95mkz9+2CaXs6BTnprN NSvVJsZBivbnYr7FaNpnpPXqpgKV/kPoBI0fNgR3YQXus91QE202sknuzlc1oYtiUbm7 wnGsj5Q61kg5pTSQobbumWXvY13QeSDi6PmWT2X85qTUjOYxcBmws9CaJW4luXoYstBl ehoQ6m063xJgMMVJdazV+FeBmdfCFv7KQXJt8mBXwzu9HpCB5Z+KT+t7Ar/vboUCwxMP b5eg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=gXmwFh6Q0tnujjSkhhyNDfb+LF/wmJRVSFEKPAKLodw=; b=jaqFvF9grqUeq2qpo+EjTs2+ewj4n2G6buWxmIz/UNLsm86dDlFX96XeNmtXsLyemV hL6gjHNWans0qelyeMvf8kXfbSr74ywJRAxZRHgSI/bsHeIEXv732rHuYszIdIA4N5A/ OTBIObYy1WUTUpo+ns9Qw8rqFpech3pQV96BLXeF5fGq6xyDoKt2Uany3JrNE8exiuGC TtIrw+wxyeBHnzfjBtdvZISf7y6QwnNBr0Ug35+Cwfx0LhE8ZFjF6DN2V+BYy737hR08 4zuo1cI2QGvygc1W/5KxLdoAp6ldaAYMHcJEhVsnHwJT8aTdrd4XvcMXYdQzrk4oLNzi 3ZHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=s39Jmpj9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s15si19497364plg.84.2021.04.19.15.21.39; Mon, 19 Apr 2021 15:21:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=s39Jmpj9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242632AbhDSUpE (ORCPT + 99 others); Mon, 19 Apr 2021 16:45:04 -0400 Received: from mail.kernel.org ([198.145.29.99]:53992 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242366AbhDSUoa (ORCPT ); Mon, 19 Apr 2021 16:44:30 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id F178D613B0; Mon, 19 Apr 2021 20:43:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1618865040; bh=I5kr/ZJURQoJQ6ScNBJC0SibW9GWi8X8EIj3ro4wxSI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=s39Jmpj9eG715jRjRGHT/w4RRQrykMqYr0fKpYpP1uv231DU9LZLt8Ol0DzFlmzmT N9+FltWPZRKH3YX1+BEjpRqZTNveCHg87J09O08SeS49/QoZMD9o7jLGCreL6wS+tr x5uoYXdgCIs4C2G7dLKXNNLLBxbeC8aoimicCI/eNFEuep7nM29216h5rxhjdMK3Co 8FKxTKqkN5ubKTaooZziGpM44yhaEkyao7LmbrBLFbOViB9B5zcAY8rzDIEoDNmZEC MRP3HV5uwB8GB/9f/oyteuI3nyxq3VzrsrNEy3IbQGNYWTGNfgk1e9+FdD0zOl1xQy wzHJqf1HHY3kg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Phillip Potter , Eric Dumazet , syzbot+2e406a9ac75bb71d4b7a@syzkaller.appspotmail.com, "David S . Miller" , Sasha Levin , netdev@vger.kernel.org Subject: [PATCH AUTOSEL 5.11 11/23] net: geneve: check skb is large enough for IPv4/IPv6 header Date: Mon, 19 Apr 2021 16:43:30 -0400 Message-Id: <20210419204343.6134-11-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210419204343.6134-1-sashal@kernel.org> References: <20210419204343.6134-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Phillip Potter [ Upstream commit 6628ddfec7580882f11fdc5c194a8ea781fdadfa ] Check within geneve_xmit_skb/geneve6_xmit_skb that sk_buff structure is large enough to include IPv4 or IPv6 header, and reject if not. The geneve_xmit_skb portion and overall idea was contributed by Eric Dumazet. Fixes a KMSAN-found uninit-value bug reported by syzbot at: https://syzkaller.appspot.com/bug?id=abe95dc3e3e9667fc23b8d81f29ecad95c6f106f Suggested-by: Eric Dumazet Reported-by: syzbot+2e406a9ac75bb71d4b7a@syzkaller.appspotmail.com Signed-off-by: Phillip Potter Signed-off-by: Eric Dumazet Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/geneve.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/net/geneve.c b/drivers/net/geneve.c index f35b0b83fe85..040edc6fc560 100644 --- a/drivers/net/geneve.c +++ b/drivers/net/geneve.c @@ -891,6 +891,9 @@ static int geneve_xmit_skb(struct sk_buff *skb, struct net_device *dev, __be16 sport; int err; + if (!pskb_network_may_pull(skb, sizeof(struct iphdr))) + return -EINVAL; + sport = udp_flow_src_port(geneve->net, skb, 1, USHRT_MAX, true); rt = geneve_get_v4_rt(skb, dev, gs4, &fl4, info, geneve->cfg.info.key.tp_dst, sport); @@ -985,6 +988,9 @@ static int geneve6_xmit_skb(struct sk_buff *skb, struct net_device *dev, __be16 sport; int err; + if (!pskb_network_may_pull(skb, sizeof(struct ipv6hdr))) + return -EINVAL; + sport = udp_flow_src_port(geneve->net, skb, 1, USHRT_MAX, true); dst = geneve_get_v6_dst(skb, dev, gs6, &fl6, info, geneve->cfg.info.key.tp_dst, sport); -- 2.30.2