Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1769064imm; Thu, 27 Sep 2018 02:08:15 -0700 (PDT) X-Google-Smtp-Source: ACcGV62gNo1yZlltAVGYnF6wYXo+N8TUQOS7+Eq23nHsla0VyTDPGFO57cZbAQLoL3g/ZmuLjytC X-Received: by 2002:a17:902:6bc1:: with SMTP id m1-v6mr7798928plt.148.1538039295413; Thu, 27 Sep 2018 02:08:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538039295; cv=none; d=google.com; s=arc-20160816; b=Dfm+RCGGFLibBjZwm8o9kUuEoaTf8rn/qIrnZSrD/b9Gg/HZNoig6DQjYZQsFdw9iZ 9M4WfjoiUGMZ7RXRsrntCHHqceK81779usIPZiYp3zr7jQ5OSemWkh5dNhw0l1s0nBUe tR+ddLwO/VcqFj9KHuKSThO8BnCumHGBItWS7sG1Fkc15S64AmroyUPlyVNOpVuvBPw9 MLxH4mxAcFoxMikU4bSJ4LRz8DTxMNFRtVuO/YCduNDQYSgzmsZNpSbXcl0yI2KpuZdA lIoP359RFfEEmAFp9a9b7X3kBMAg4941IR12/fK5gxxb/BNi/UKjj1866SXX27pBoypj o3oA== 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; bh=lNY4Xcs4yCjfYZRHkae/VAijWoVaBAbNsuRo7nqWfP4=; b=RefAygmdyCjTNdgPpqPj7Rw4aNO91iNgus1P74yMlp8agCDmrRadfYaeiOEyPiqYIf b0Qan35paQGO4kj17ifrpYn+e8vFqxwTYHjzL4cYZh9CWncqM9XvzOqxwv7YXqN9vAZ4 hr58M9qm1OB+yRzL3vC7ACfipM5nml35aebKtYwKCVmK0ihjUzH7vvrsapsMiVdkR/+j Ds5ZsEHkJX5V4j/uAW8LNPtjtK65YqeAdva2cijmHEH2DjDRmdv/iveRb5YKc2gzYkZt Fm0CAz6QBoTveJeoiGUBw43zVrnLc46FlQDNbywSU/yBQHQ/UGH1ZI3n0NlqENtfV2fY dMqQ== ARC-Authentication-Results: i=1; mx.google.com; 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 61-v6si1500626plq.11.2018.09.27.02.08.00; Thu, 27 Sep 2018 02:08:15 -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; 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 S1727579AbeI0PYu (ORCPT + 99 others); Thu, 27 Sep 2018 11:24:50 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:54858 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727483AbeI0PYu (ORCPT ); Thu, 27 Sep 2018 11:24:50 -0400 Received: from localhost (ip-213-127-77-73.ip.prioritytelecom.net [213.127.77.73]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 178411112; Thu, 27 Sep 2018 09:07:34 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Paolo Abeni , "David S. Miller" Subject: [PATCH 4.18 07/88] udp4: fix IP_CMSG_CHECKSUM for connected sockets Date: Thu, 27 Sep 2018 11:02:48 +0200 Message-Id: <20180927090301.435535838@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180927090300.631426620@linuxfoundation.org> References: <20180927090300.631426620@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review 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.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Paolo Abeni [ Upstream commit 2b5a921740a55c00223a797d075b9c77c42cb171 ] commit 2abb7cdc0dc8 ("udp: Add support for doing checksum unnecessary conversion") left out the early demux path for connected sockets. As a result IP_CMSG_CHECKSUM gives wrong values for such socket when GRO is not enabled/available. This change addresses the issue by moving the csum conversion to a common helper and using such helper in both the default and the early demux rx path. Fixes: 2abb7cdc0dc8 ("udp: Add support for doing checksum unnecessary conversion") Signed-off-by: Paolo Abeni Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/ipv4/udp.c | 49 ++++++++++++++++++++++++++----------------------- 1 file changed, 26 insertions(+), 23 deletions(-) --- a/net/ipv4/udp.c +++ b/net/ipv4/udp.c @@ -2128,6 +2128,28 @@ static inline int udp4_csum_init(struct inet_compute_pseudo); } +/* wrapper for udp_queue_rcv_skb tacking care of csum conversion and + * return code conversion for ip layer consumption + */ +static int udp_unicast_rcv_skb(struct sock *sk, struct sk_buff *skb, + struct udphdr *uh) +{ + int ret; + + if (inet_get_convert_csum(sk) && uh->check && !IS_UDPLITE(sk)) + skb_checksum_try_convert(skb, IPPROTO_UDP, uh->check, + inet_compute_pseudo); + + ret = udp_queue_rcv_skb(sk, skb); + + /* a return value > 0 means to resubmit the input, but + * it wants the return to be -protocol, or 0 + */ + if (ret > 0) + return -ret; + return 0; +} + /* * All we need to do is get the socket, and then do a checksum. */ @@ -2174,14 +2196,9 @@ int __udp4_lib_rcv(struct sk_buff *skb, if (unlikely(sk->sk_rx_dst != dst)) udp_sk_rx_dst_set(sk, dst); - ret = udp_queue_rcv_skb(sk, skb); + ret = udp_unicast_rcv_skb(sk, skb, uh); sock_put(sk); - /* a return value > 0 means to resubmit the input, but - * it wants the return to be -protocol, or 0 - */ - if (ret > 0) - return -ret; - return 0; + return ret; } if (rt->rt_flags & (RTCF_BROADCAST|RTCF_MULTICAST)) @@ -2189,22 +2206,8 @@ int __udp4_lib_rcv(struct sk_buff *skb, saddr, daddr, udptable, proto); sk = __udp4_lib_lookup_skb(skb, uh->source, uh->dest, udptable); - if (sk) { - int ret; - - if (inet_get_convert_csum(sk) && uh->check && !IS_UDPLITE(sk)) - skb_checksum_try_convert(skb, IPPROTO_UDP, uh->check, - inet_compute_pseudo); - - ret = udp_queue_rcv_skb(sk, skb); - - /* a return value > 0 means to resubmit the input, but - * it wants the return to be -protocol, or 0 - */ - if (ret > 0) - return -ret; - return 0; - } + if (sk) + return udp_unicast_rcv_skb(sk, skb, uh); if (!xfrm4_policy_check(NULL, XFRM_POLICY_IN, skb)) goto drop;