Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp264819img; Mon, 18 Mar 2019 02:36:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqwBb7DLq2Hsyn5jV3YlU3sD5KNS43Dy3+zjkJrwG96RRjK+uCORD4KLaeAdkHBkiYFclg8f X-Received: by 2002:a17:902:8697:: with SMTP id g23mr19281230plo.30.1552901773499; Mon, 18 Mar 2019 02:36:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552901773; cv=none; d=google.com; s=arc-20160816; b=q5E8PthjKS2SPliLVXR8eKJxnd5aXKK+YjoIn+yMmwtZk1EA+S5Esn3VlaqYbDfOUO 505scKZ6pApUh4EvEZmbefSUkynrKL0wAmQqa82ckTb4TWitiHzjQpHBMdzNg5GpXMhX c9cuWSwVQ73qj4gpERiLGx0b/jC1Z9YyNMS7ycN3hQUDTbKlFbDKA6N6Ty2/X4LtBKRX DAnUjGIfXHmo4D0K+aPsLAPisbaqKSwEx2dvafoJGRgfQS7cwbyOV8ZEOMvwwEMlMB3i TG+5YaMSDGPbVCu36yQjfBMasYksmKmt5I3eQ77YsN8WlZMt74ZaFQW/WZPGuFf9Kr43 8HXA== 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=ByVKaaf/AlajLy0ceblDGX85GZ3wnFTKg7pqtL3XJ+I=; b=UJb+JNhxbQ7irQFoqSNUQ/GXI0kcheAVejxEZRgE/3WpaJ6p9YJ6VznIQyl6/X8gHl zTUABrW3eloAm4wH98RJxFXySUkN+imlJy2oHU4Yd3MdDpIGtTD8nojcjhnrWrNh8NfC ghQpgmUijF68ip7x88FCUrLD6BL6l7Sen8ICsolcoN3hourQWZZIQjoqgvWdvKxnEHE9 jjgUGFF7K2RdDZ+ZJidaAbZC2ih6XbPgpUPILifk7h+LT9TCfwzBfC0bo893lLIrcnAg zDmK6YhYVz+9K3knKWepkQxi31fajmDkW5O3myND1RyrTuuBTnGhwGjYAwgcz3vmZ8yr O0Kg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=kHrj86L8; 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 cm8si9363916plb.47.2019.03.18.02.35.58; Mon, 18 Mar 2019 02:36:13 -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=kHrj86L8; 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 S1729035AbfCRJej (ORCPT + 99 others); Mon, 18 Mar 2019 05:34:39 -0400 Received: from mail.kernel.org ([198.145.29.99]:43022 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728720AbfCRJeh (ORCPT ); Mon, 18 Mar 2019 05:34:37 -0400 Received: from localhost (5356596B.cm-6-7b.dynamic.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 06A5B21738; Mon, 18 Mar 2019 09:34:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1552901676; bh=RI+GfF52Hgb5adQNymfyqm42Z3L5Wo4va+TqPcXVqcM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kHrj86L8XdmArmf3MUd48n2ki0Gs0GrWY5Xp1txm+nOvdi/yJ9xeouSh0ZdF23eDL VwNb4FGxrfkO/fMhPWXR6jfNojr/Uf6UEdkIsNbtNF2VZ3DeMYufOSQu8BiApOSnRS TMKHOQEDIFj57fL7MwaV88xTfibT09gHr0y+PnT0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eric Dumazet , Christoph Paasch , "David S. Miller" Subject: [PATCH 4.14 15/34] tcp: Dont access TCP_SKB_CB before initializing it Date: Mon, 18 Mar 2019 10:25:39 +0100 Message-Id: <20190318084146.777565077@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190318084144.657740413@linuxfoundation.org> References: <20190318084144.657740413@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore 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 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Christoph Paasch [ Upstream commit f2feaefdabb0a6253aa020f65e7388f07a9ed47c ] Since commit eeea10b83a13 ("tcp: add tcp_v4_fill_cb()/tcp_v4_restore_cb()"), tcp_vX_fill_cb is only called after tcp_filter(). That means, TCP_SKB_CB(skb)->end_seq still points to the IP-part of the cb. We thus should not mock with it, as this can trigger bugs (thanks syzkaller): [ 12.349396] ================================================================== [ 12.350188] BUG: KASAN: slab-out-of-bounds in ip6_datagram_recv_specific_ctl+0x19b3/0x1a20 [ 12.351035] Read of size 1 at addr ffff88006adbc208 by task test_ip6_datagr/1799 Setting end_seq is actually no more necessary in tcp_filter as it gets initialized later on in tcp_vX_fill_cb. Cc: Eric Dumazet Fixes: eeea10b83a13 ("tcp: add tcp_v4_fill_cb()/tcp_v4_restore_cb()") Signed-off-by: Christoph Paasch Signed-off-by: Eric Dumazet Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/ipv4/tcp_ipv4.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) --- a/net/ipv4/tcp_ipv4.c +++ b/net/ipv4/tcp_ipv4.c @@ -1578,15 +1578,8 @@ EXPORT_SYMBOL(tcp_add_backlog); int tcp_filter(struct sock *sk, struct sk_buff *skb) { struct tcphdr *th = (struct tcphdr *)skb->data; - unsigned int eaten = skb->len; - int err; - err = sk_filter_trim_cap(sk, skb, th->doff * 4); - if (!err) { - eaten -= skb->len; - TCP_SKB_CB(skb)->end_seq -= eaten; - } - return err; + return sk_filter_trim_cap(sk, skb, th->doff * 4); } EXPORT_SYMBOL(tcp_filter);