Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2448980yba; Mon, 15 Apr 2019 11:52:20 -0700 (PDT) X-Google-Smtp-Source: APXvYqyxtCM9EP8/Q4Y3aVuUx3LQfVNtVMoTbpQW5SUa+XGg/3NHvR46agdITm0X3bB7pErtrshQ X-Received: by 2002:a63:6844:: with SMTP id d65mr72950298pgc.393.1555354340439; Mon, 15 Apr 2019 11:52:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555354340; cv=none; d=google.com; s=arc-20160816; b=l13zvnVQiVWfdkmreqA8FOnLUNsk13hJEiyDZY0kYpQETNJOsTzOik4TP6Jyu8lTnX m6cmuKz1ybBnamixA4EcdgbiX3CKJ0mJIQyxohB+dTojPYG3y4KpzrHQBVy9qFH2jPBr sDRXMk2EzIC2BQ++N2FB2N07Ru38lV3jX8q1rOIR7xDuFkVqoecBbjHeA3gBqcNqyBqD nIpcCjlYbbmHa6bvP7rRQItGE+CrvOO+jCHIr9iok+NNBjm/R02sBFD7sPiniww+oobx Kzf1P5UFpM75g+H5dvMj01pVO6Y3QDW2jjjmynZPuHgoDM8ytI6d3LtwpLDKrdolm4wA QaPQ== 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=xtSjOsiWVHRhwVehkNS4560TXd4IwVSyRXcavrFHOUM=; b=Ql7LWzfEZR9aVmJrYdxpHND2FNuE54BcZFwlWfN28Dxsp9XqHOSeUff7b73lngL+Wd UiHa+0LS/ZRWypIlc8N7lcHhsrWglGafwMUXsWZOx3NuegUeSg/msIO1EFLzIePeVisF ZogCwoAHgwnTkCbrmIKIdp3aKbftkiRt227SRIAtbyZc0PF37112B+kCKCuGhZkiXcan HXiCwjT7Q/RriQI+NurUce0lVJt14geHKaiqTtr+v7fbIvZuz0OWrdCzNfKpVfBowPCL zcq6ajqjzXkMBmEwkVkHhzJeOl+yHSEXQx9sPvSplAfRdm+d2SyQ5NW2Dsmztz6rP7sL qA9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="R/4nWANb"; 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 72si12344792plb.165.2019.04.15.11.52.04; Mon, 15 Apr 2019 11:52:20 -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="R/4nWANb"; 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 S1728867AbfDOSrS (ORCPT + 99 others); Mon, 15 Apr 2019 14:47:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:50402 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728860AbfDOSrQ (ORCPT ); Mon, 15 Apr 2019 14:47:16 -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 ACE53218D3; Mon, 15 Apr 2019 18:47:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1555354035; bh=zfzYwbAwJm0fglQB53WTUxwHsqz42lR02PfPzioo9gE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=R/4nWANb9wrVY35Y1pRl0ql5TFy0npYqF5TBLGTgL6dEyTGRwChCd/fZupvJsjSWp KuZvbTNCvPv0wixPkmuHycN19QP/tfySQmfoTJVeiwwCRT6TPi9CpZ2xcaUjlwCYTX P6lxOz5kB3ZjynU5278ZY7aPHP+csJAlUaRKKKpc= 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" Subject: [PATCH 4.9 48/76] ipv6: Fix dangling pointer when ipv6 fragment Date: Mon, 15 Apr 2019 20:44:12 +0200 Message-Id: <20190415183720.771455989@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190415183707.712011689@linuxfoundation.org> References: <20190415183707.712011689@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 From: Junwei Hu [ 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: Greg Kroah-Hartman --- net/ipv6/ip6_output.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/net/ipv6/ip6_output.c +++ b/net/ipv6/ip6_output.c @@ -592,7 +592,7 @@ int ip6_fragment(struct net *net, struct 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; @@ -603,6 +603,7 @@ int ip6_fragment(struct net *net, struct goto fail; hlen = err; nexthdr = *prevhdr; + nexthdr_offset = prevhdr - skb_network_header(skb); mtu = ip6_skb_dst_mtu(skb); @@ -637,6 +638,7 @@ int ip6_fragment(struct net *net, struct (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)) { int first_len = skb_pagelen(skb);