Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp3300754ybb; Tue, 31 Mar 2020 02:25:33 -0700 (PDT) X-Google-Smtp-Source: ADFU+vvm+f2IzREExWhM41Hx2N2tmxPuU6CR6Pp2rwWFaNGOJ6YI9d22yHYKFvl7nJvtxOR7NJSS X-Received: by 2002:a9d:7a45:: with SMTP id z5mr10003744otm.181.1585646733137; Tue, 31 Mar 2020 02:25:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585646733; cv=none; d=google.com; s=arc-20160816; b=RNEDun29q6pbnYOv8DRrX1+lAiokRQ/vH9ejK9IiDpaS7fW0bP6rYQgBGdgzE0G8Po eFpIT2QpKB3brVMk0nrBtvI9V+r+8irZz1XPFVJ62UqB+d5OeI0PrV9U74bVupJ7ytF+ G4umYhBeo/R2XMGfgpLMY0lzzkGZFWHQF8yjteLNTJYBx3YAHSdhI0zDCvP0dBirmG10 /xeADT1GOhquE0V0YUo7IMcFdCJRH3j+FHTohTo8SAN3wOISltN30BDCeYOH0Lv/YjvZ XkPzrFIg34xPMk3050dc6I96bQXhziIX/QuJHTAs/r7DKAm4VsMmKHW0rS/ZAjZN18b4 5qeg== 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=jBDiqTaC4z9KsrH4Z9JNmy96/Q4jCYrmOmpkdCSnrOM=; b=nj2onNdHYRAorDc4KudGaJwF1N6csf1KfxRtAGaMKhDRJ8MBs9sFMiA5giC3oUCfQ4 ZN4w+0vAbV36RLWZ+DHifdFpJGnJNtWfwZ4/rUQePm5syVFr+J/2elB6Hq9gnvKFhexi 0lSv9dh+9EswyNtWwsACEEfgoM0vePDy+NMX5WNdDxWVsgq3hs5aE0zcYnHzSi6vwlzf 6xh6CUGWo4EPg73mN9sXAE3ut4p7evEyCvGDKdz3BRZzSwVAebiUkK9UY1RuZuCgI5Oo eiWRis4ZE9BBCKIPY2D6PU42B7bpAULjEJFlR7ZCPzzsWGHcpDFziVrjnAMotMC28Efk r5HQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=jeDbuQkp; 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 w9si8035949oti.216.2020.03.31.02.25.20; Tue, 31 Mar 2020 02:25:33 -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=jeDbuQkp; 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 S1730786AbgCaJDH (ORCPT + 99 others); Tue, 31 Mar 2020 05:03:07 -0400 Received: from mail.kernel.org ([198.145.29.99]:42744 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730566AbgCaJDG (ORCPT ); Tue, 31 Mar 2020 05:03:06 -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 C9839208E0; Tue, 31 Mar 2020 09:03:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1585645385; bh=WEq957zAfjyZHs7RPLZbxFpac6ucSHDGcB02beUwI1Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jeDbuQkpGvCAx0L5L7sy8TAV0JBzNkrKWRe2fXkKsrSfVsfKu9ToxIUCzctArRWuR 9Ob/O/M1TyrmjuPWaQVWipl2wYWyHgLvxsAwRbZMPlHgvWvB/cEhFA9a4dW05/kFnM T7CbYxsU+8KLFdmovBSjLY0Z0oKlCYqV4tumvP5A= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eric Dumazet , Martin Zaharinov , Florian Westphal , Pablo Neira Ayuso , "David S. Miller" Subject: [PATCH 5.5 037/170] tcp: ensure skb->dev is NULL before leaving TCP stack Date: Tue, 31 Mar 2020 10:57:31 +0200 Message-Id: <20200331085427.965229450@linuxfoundation.org> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200331085423.990189598@linuxfoundation.org> References: <20200331085423.990189598@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: Eric Dumazet [ Upstream commit b738a185beaab8728943acdb3e67371b8a88185e ] skb->rbnode is sharing three skb fields : next, prev, dev When a packet is sent, TCP keeps the original skb (master) in a rtx queue, which was converted to rbtree a while back. __tcp_transmit_skb() is responsible to clone the master skb, and add the TCP header to the clone before sending it to network layer. skb_clone() already clears skb->next and skb->prev, but copies the master oskb->dev into the clone. We need to clear skb->dev, otherwise lower layers could interpret the value as a pointer to a netdev. This old bug surfaced recently when commit 28f8bfd1ac94 ("netfilter: Support iif matches in POSTROUTING") was merged. Before this netfilter commit, skb->dev value was ignored and changed before reaching dev_queue_xmit() Fixes: 75c119afe14f ("tcp: implement rb-tree based retransmit queue") Fixes: 28f8bfd1ac94 ("netfilter: Support iif matches in POSTROUTING") Signed-off-by: Eric Dumazet Reported-by: Martin Zaharinov Cc: Florian Westphal Cc: Pablo Neira Ayuso Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/ipv4/tcp_output.c | 4 ++++ 1 file changed, 4 insertions(+) --- a/net/ipv4/tcp_output.c +++ b/net/ipv4/tcp_output.c @@ -1048,6 +1048,10 @@ static int __tcp_transmit_skb(struct soc if (unlikely(!skb)) return -ENOBUFS; + /* retransmit skbs might have a non zero value in skb->dev + * because skb->dev is aliased with skb->rbnode.rb_left + */ + skb->dev = NULL; } inet = inet_sk(sk);