Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2460794yba; Mon, 15 Apr 2019 12:07:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqz4m0q647hKJmYYfUnKGtOK6wbfADtvdUXVxovwGY/8vmI26M/3uN2saaSuv7pYY8GoK6OC X-Received: by 2002:a62:1f92:: with SMTP id l18mr78714003pfj.180.1555355243708; Mon, 15 Apr 2019 12:07:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555355243; cv=none; d=google.com; s=arc-20160816; b=gjBiepdjN1VEVmUSFE/fKo/gE9cUJU+pwRSsphVqglg8tCIO8CI041tqgRgs20NgEr H51k5vQBenfhkdwbEFAwAY1aPPiO08oI+wPk1+To5YzdMB/hAKGl+cQBmR81RJeuTZz4 rWkh/pOxsQuO51wPzpYnLw4TnVGwMdd2aCKkXSqN/0/wlKWzH0lYXUwshTsLrTXiPCcO aozeKdmIJ9C8VOeuoMwpnaMq5UecEwzZF+pePEmVZvZjx560eFdsEsSdDpQVB45UkpeN 11k89yfvsxGRiNqezHy0wf0p1VrjN5YFo5x7cidhqfixx8m6D5nkMamRhNWBbHotQwGR B0Dg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=81WqDFxFvwrBMroBkHExNK8ULnZfzYfBut/s7aLGxuE=; b=qhLKmY3S7MqpsRV/61Zm/g6QioWLqtLTAYd6U27k7ok/6iYSjLgl0HrBmD3acJRhQE E0P8u9zi93E81A0K6iTmtQLTm/+fWzKKVDeqBtSvEDuz6UX+xQkvQnIZKboITGbDSa50 ep8iOnWHBaMElH+H6NVXOiqhs6LHfS49B6Ag/SMWJ+/PBuGOLBIkCL7V25J07gu68v0R mBWg/qFU3zd2ZjQDYnV3VUHYDh4NSBZhieD1WT/d+L0xyfZtgPCI/LjbDFP3OZR5CPZF el7d10Gms4zNfyhAmrXDIj6hr2+OlhoqsFdyObfVA6/ta/y1xC8qQYUok+wY2zeOU3e1 q8yA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=IC+nQ4dB; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u193si46348044pgc.410.2019.04.15.12.07.07; Mon, 15 Apr 2019 12:07:23 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=IC+nQ4dB; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729694AbfDOTFO (ORCPT + 99 others); Mon, 15 Apr 2019 15:05:14 -0400 Received: from mail.kernel.org ([198.145.29.99]:38752 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729122AbfDOTFL (ORCPT ); Mon, 15 Apr 2019 15:05:11 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C60FB20880; Mon, 15 Apr 2019 19:05:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1555355111; bh=G/yjZiKaMCLx2+dCNufwb8saYUcU8/NrPJFHeuEmg8U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IC+nQ4dBBVhGEBzmxwaRbpTbZihn//IQcrXa65OPVKMMK5dvR7SP791cznencwolv 3Hk7JJjrVxaFnVFqgNaO6qQuxRFZluJCtBglIP5E3GhnjDFfYaEDaYjS3ujueVO2z6 dqgRNMaVDPoxJkevnIjJ7mLEyD/eXuuA20P2nOVA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Junwei Hu , Wenhao Zhang , syzbot+e8ce541d095e486074fc@syzkaller.appspotmail.com, Zhiqiang Liu , Martin KaFai Lau , "David S. Miller" , Sasha Levin Subject: [PATCH 4.19 007/101] ipv6: Fix dangling pointer when ipv6 fragment Date: Mon, 15 Apr 2019 20:58:05 +0200 Message-Id: <20190415183740.737225634@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190415183740.341577907@linuxfoundation.org> References: <20190415183740.341577907@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit ef0efcd3bd3fd0589732b67fb586ffd3c8705806 ] At the beginning of ip6_fragment func, the prevhdr pointer is obtained in the ip6_find_1stfragopt func. However, all the pointers pointing into skb header may change when calling skb_checksum_help func with skb->ip_summed = CHECKSUM_PARTIAL condition. The prevhdr pointe will be dangling if it is not reloaded after calling __skb_linearize func in skb_checksum_help func. Here, I add a variable, nexthdr_offset, to evaluate the offset, which does not changes even after calling __skb_linearize func. Fixes: 405c92f7a541 ("ipv6: add defensive check for CHECKSUM_PARTIAL skbs in ip_fragment") Signed-off-by: Junwei Hu Reported-by: Wenhao Zhang Reported-by: syzbot+e8ce541d095e486074fc@syzkaller.appspotmail.com Reviewed-by: Zhiqiang Liu Acked-by: Martin KaFai Lau Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- net/ipv6/ip6_output.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c index 0bb87f3a10c7..eed9231c90ad 100644 --- a/net/ipv6/ip6_output.c +++ b/net/ipv6/ip6_output.c @@ -587,7 +587,7 @@ int ip6_fragment(struct net *net, struct sock *sk, struct sk_buff *skb, inet6_sk(skb->sk) : NULL; struct ipv6hdr *tmp_hdr; struct frag_hdr *fh; - unsigned int mtu, hlen, left, len; + unsigned int mtu, hlen, left, len, nexthdr_offset; int hroom, troom; __be32 frag_id; int ptr, offset = 0, err = 0; @@ -598,6 +598,7 @@ int ip6_fragment(struct net *net, struct sock *sk, struct sk_buff *skb, goto fail; hlen = err; nexthdr = *prevhdr; + nexthdr_offset = prevhdr - skb_network_header(skb); mtu = ip6_skb_dst_mtu(skb); @@ -632,6 +633,7 @@ int ip6_fragment(struct net *net, struct sock *sk, struct sk_buff *skb, (err = skb_checksum_help(skb))) goto fail; + prevhdr = skb_network_header(skb) + nexthdr_offset; hroom = LL_RESERVED_SPACE(rt->dst.dev); if (skb_has_frag_list(skb)) { unsigned int first_len = skb_pagelen(skb); -- 2.19.1