Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3787821ybi; Mon, 29 Jul 2019 12:37:36 -0700 (PDT) X-Google-Smtp-Source: APXvYqzdo1+u0UiW1ehQGhtp4zYYtg2vbPYkLdAx4PIN6k9IshetDNyMAs+EnE1SD4HAu4zZjkK4 X-Received: by 2002:a17:902:e703:: with SMTP id co3mr14535036plb.119.1564429055934; Mon, 29 Jul 2019 12:37:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564429055; cv=none; d=google.com; s=arc-20160816; b=G1sMaYGUUU4NHKCt0fy7eMFf8DfsAG8nAYQn0Jbi4utcCS2QQGm1gfNYz4ZeCwzNhH 4QKmv1+GhzFCUIEB8LHV+F/uTU9/Ll69Oa6nos9QXFDJDIcLkA0NriEsTXdklNCK9Wl0 FkOYKb1uRTdbKGzfrCZhEJ0sCZij/i6P+NLlMxRaQO4QGJdL5LvIi2aqqbDuJhwb2ZvT JMxbnrAhFvSaPt0Gm4ecH73AatHzSS2aEtHxheclslADmhi1W9rIrWni/FJdGr2Eym8+ k1cbVC8UZJXdp3lJe4L3XEJxSartKUdNYh5206FJEY/72ghGCzxody3f4E+Vf6ahmBp0 fw1Q== 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=AlNlgQDwk0lx7+WVj/ssxWVGcSWCqso/jkfewy9G+ww=; b=Nc+R3bDwzcuEg2xMjruN+dS2HXYWhpojnVdYMIkbxDoMth2LwicKxBHHw+9M8szPYe 9zIEgoeNBHZ/aZkvRAMe0q1/uNwnDM0Yi0YBONUJiMF6WmyL4pDesZOi2V0icCZuzsF6 kP7jlx3oStzFbG99rao2F+AAV69J6FLyYePkIhCbx7wQaql3Xf94oc3AvkRMG46kwFDP o70ZIJda1S2XJINMhffszTH0LGCa5Y5bxZjAyvmgG3Qs58uXqtKhb5aV808AsLHBjp6V 1GBd9hsR8N92jXhAX9Ib9ERref4M0OfhwsVYDGK/8pQTake03E79QKREAWfs/KWRpU8B zoIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ExzBdSyk; 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 m143si28445357pfd.224.2019.07.29.12.37.20; Mon, 29 Jul 2019 12:37:35 -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=ExzBdSyk; 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 S2388518AbfG2TfY (ORCPT + 99 others); Mon, 29 Jul 2019 15:35:24 -0400 Received: from mail.kernel.org ([198.145.29.99]:49728 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728886AbfG2TfX (ORCPT ); Mon, 29 Jul 2019 15:35:23 -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 8A0052171F; Mon, 29 Jul 2019 19:35:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564428922; bh=6VxoevqU13y+krWgCZOS1XIMk1y2SPkfoW4m36eNQLk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ExzBdSykKggISnzaZUWxFpzUtD24eg6/KOiXR4RmcnEXdaAKwbDL0+xrckT2OdSuz MU1U2rrN1aTJ7z2eRlSVDC3YAtj8k1MKfhW/JsNEA3XcUrhNE0RH041NjQXq0BSfyT 0AZhUi0KaSry+wTUNafG3HMHTwWSEwnMXnzGUxck= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, John Hurley , Jakub Kicinski , Simon Horman , Pravin B Shelar , "David S. Miller" Subject: [PATCH 4.14 189/293] net: openvswitch: fix csum updates for MPLS actions Date: Mon, 29 Jul 2019 21:21:20 +0200 Message-Id: <20190729190838.969560477@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190729190820.321094988@linuxfoundation.org> References: <20190729190820.321094988@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: John Hurley [ Upstream commit 0e3183cd2a64843a95b62f8bd4a83605a4cf0615 ] Skbs may have their checksum value populated by HW. If this is a checksum calculated over the entire packet then the CHECKSUM_COMPLETE field is marked. Changes to the data pointer on the skb throughout the network stack still try to maintain this complete csum value if it is required through functions such as skb_postpush_rcsum. The MPLS actions in Open vSwitch modify a CHECKSUM_COMPLETE value when changes are made to packet data without a push or a pull. This occurs when the ethertype of the MAC header is changed or when MPLS lse fields are modified. The modification is carried out using the csum_partial function to get the csum of a buffer and add it into the larger checksum. The buffer is an inversion of the data to be removed followed by the new data. Because the csum is calculated over 16 bits and these values align with 16 bits, the effect is the removal of the old value from the CHECKSUM_COMPLETE and addition of the new value. However, the csum fed into the function and the outcome of the calculation are also inverted. This would only make sense if it was the new value rather than the old that was inverted in the input buffer. Fix the issue by removing the bit inverts in the csum_partial calculation. The bug was verified and the fix tested by comparing the folded value of the updated CHECKSUM_COMPLETE value with the folded value of a full software checksum calculation (reset skb->csum to 0 and run skb_checksum_complete(skb)). Prior to the fix the outcomes differed but after they produce the same result. Fixes: 25cd9ba0abc0 ("openvswitch: Add basic MPLS support to kernel") Fixes: bc7cc5999fd3 ("openvswitch: update checksum in {push,pop}_mpls") Signed-off-by: John Hurley Reviewed-by: Jakub Kicinski Reviewed-by: Simon Horman Acked-by: Pravin B Shelar Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/openvswitch/actions.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) --- a/net/openvswitch/actions.c +++ b/net/openvswitch/actions.c @@ -174,8 +174,7 @@ static void update_ethertype(struct sk_b if (skb->ip_summed == CHECKSUM_COMPLETE) { __be16 diff[] = { ~(hdr->h_proto), ethertype }; - skb->csum = ~csum_partial((char *)diff, sizeof(diff), - ~skb->csum); + skb->csum = csum_partial((char *)diff, sizeof(diff), skb->csum); } hdr->h_proto = ethertype; @@ -267,8 +266,7 @@ static int set_mpls(struct sk_buff *skb, if (skb->ip_summed == CHECKSUM_COMPLETE) { __be32 diff[] = { ~(stack->label_stack_entry), lse }; - skb->csum = ~csum_partial((char *)diff, sizeof(diff), - ~skb->csum); + skb->csum = csum_partial((char *)diff, sizeof(diff), skb->csum); } stack->label_stack_entry = lse;