From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BB6CEC04E87 for ; Wed, 15 May 2019 12:11:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 82A0F20657 for ; Wed, 15 May 2019 12:11:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1557922296; bh=TbtfVt5BJUBf/HcNkVKL3fzlo44vjaGOWci/mWz9tWo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=AesoJ6+B3wKEvhg9uElP0TzMU0QPYfy6h0NRizBljqkdz56UNIFiO98i/CrFh7MUC Eh1yQDfVGwJvoPI+Cl9EwTPAICqN3xl1JTpiJOHo8lGT/Cyt4ucwWLgZuMFEjfTabQ Yn5ghoOpQAwbktFv3gdEN28XNvbe+NprmpIHPDyo= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727837AbfEOLGc (ORCPT ); Wed, 15 May 2019 07:06:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:37342 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728379AbfEOLGc (ORCPT ); Wed, 15 May 2019 07:06:32 -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 2416C21734; Wed, 15 May 2019 11:06:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1557918391; bh=TbtfVt5BJUBf/HcNkVKL3fzlo44vjaGOWci/mWz9tWo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=INr3cJCoJYL0tusxrRw5nBsZanOemBlo4U7SO9Nrr8twuXCh8wPupDyrcYDjAwsTA SjPU1tXSWy92U5RtPPKdjwuLd5v5s/mNtd96GfAak1P7y+DT5cj3UNIO+Pp/QcPCko WAtsqdF1B8V8F20bUUJv02SQT+2978xhNYqc58F0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Shmulik Ladkani , "David S. Miller" Subject: [PATCH 4.4 111/266] ipv4: ip_do_fragment: Preserve skb_iif during fragmentation Date: Wed, 15 May 2019 12:53:38 +0200 Message-Id: <20190515090726.212559741@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190515090722.696531131@linuxfoundation.org> References: <20190515090722.696531131@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Shmulik Ladkani [ Upstream commit d2f0c961148f65bc73eda72b9fa3a4e80973cb49 ] Previously, during fragmentation after forwarding, skb->skb_iif isn't preserved, i.e. 'ip_copy_metadata' does not copy skb_iif from given 'from' skb. As a result, ip_do_fragment's creates fragments with zero skb_iif, leading to inconsistent behavior. Assume for example an eBPF program attached at tc egress (post forwarding) that examines __sk_buff->ingress_ifindex: - the correct iif is observed if forwarding path does not involve fragmentation/refragmentation - a bogus iif is observed if forwarding path involves fragmentation/refragmentatiom Fix, by preserving skb_iif during 'ip_copy_metadata'. Signed-off-by: Shmulik Ladkani Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/ipv4/ip_output.c | 1 + 1 file changed, 1 insertion(+) --- a/net/ipv4/ip_output.c +++ b/net/ipv4/ip_output.c @@ -475,6 +475,7 @@ static void ip_copy_metadata(struct sk_b to->pkt_type = from->pkt_type; to->priority = from->priority; to->protocol = from->protocol; + to->skb_iif = from->skb_iif; skb_dst_drop(to); skb_dst_copy(to, from); to->dev = from->dev;