From patchwork Mon Oct 12 13:30:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 270272 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=-9.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham 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 5F3CBC43457 for ; Mon, 12 Oct 2020 13:54:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 224872074F for ; Mon, 12 Oct 2020 13:54:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1602510874; bh=HRDv39Xla1NMyf8uCl6RKkjVzCPjBkY8NBYynyoZq3g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=tOQvje8zBkGCNELViYOr7A8HsYkOycE6CZkfWMYekQRbdnC/dFyNPGueMmPq6PZ+9 uoFJXwTnaoYAbRXnt94xK1A76rEm3+NQKoJBVMbw8Sb2ZTVvJjT7SOvmkn1wC+z4ze 4owdqTG1Tk4waqNucXhYW9p2JBGhot6EQq5vizzY= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390153AbgJLNyd (ORCPT ); Mon, 12 Oct 2020 09:54:33 -0400 Received: from mail.kernel.org ([198.145.29.99]:48502 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389725AbgJLNpw (ORCPT ); Mon, 12 Oct 2020 09:45:52 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 CF17B22280; Mon, 12 Oct 2020 13:44:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1602510287; bh=HRDv39Xla1NMyf8uCl6RKkjVzCPjBkY8NBYynyoZq3g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wcNh0OGVrnmk5+cHZ+2UxgkxUBtdrLcMyyWHcmJlJA/bVPIscdE/LoLGlywYniNqI NRpUGil6RNjfzKIgwWK2ftSk8Vc1/pvUuDTNI8pVjqWS6ddl9Be60UWioUzm2Q9v/5 d5xL2ZSQkHzKzO+WnC6CbV6YBTMAUfoiIOxx38jk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Xiumei Mu , Sabrina Dubroca , Steffen Klassert Subject: [PATCH 5.8 035/124] espintcp: restore IP CB before handing the packet to xfrm Date: Mon, 12 Oct 2020 15:30:39 +0200 Message-Id: <20201012133148.549483577@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201012133146.834528783@linuxfoundation.org> References: <20201012133146.834528783@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Sabrina Dubroca commit 4eb2e13415757a2bce5bb0d580d22bbeef1f5346 upstream. Xiumei reported a bug with espintcp over IPv6 in transport mode, because xfrm6_transport_finish expects to find IP6CB data (struct inet6_skb_cb). Currently, espintcp zeroes the CB, but the relevant part is actually preserved by previous layers (first set up by tcp, then strparser only zeroes a small part of tcp_skb_tb), so we can just relocate it to the start of skb->cb. Fixes: e27cca96cd68 ("xfrm: add espintcp (RFC 8229)") Reported-by: Xiumei Mu Signed-off-by: Sabrina Dubroca Signed-off-by: Steffen Klassert Signed-off-by: Greg Kroah-Hartman --- net/xfrm/espintcp.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) --- a/net/xfrm/espintcp.c +++ b/net/xfrm/espintcp.c @@ -29,8 +29,12 @@ static void handle_nonesp(struct espintc static void handle_esp(struct sk_buff *skb, struct sock *sk) { + struct tcp_skb_cb *tcp_cb = (struct tcp_skb_cb *)skb->cb; + skb_reset_transport_header(skb); - memset(skb->cb, 0, sizeof(skb->cb)); + + /* restore IP CB, we need at least IP6CB->nhoff */ + memmove(skb->cb, &tcp_cb->header, sizeof(tcp_cb->header)); rcu_read_lock(); skb->dev = dev_get_by_index_rcu(sock_net(sk), skb->skb_iif);