stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org, Paolo Abeni <pabeni@redhat.com>,
	"David S. Miller" <davem@davemloft.net>
Subject: [PATCH 4.9 23/44] udp4: fix IP_CMSG_CHECKSUM for connected sockets
Date: Thu, 27 Sep 2018 11:04:12 +0200	[thread overview]
Message-ID: <20180927090121.158006866@linuxfoundation.org> (raw)
In-Reply-To: <20180927090117.997362691@linuxfoundation.org>

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Paolo Abeni <pabeni@redhat.com>

[ 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 <pabeni@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 net/ipv4/udp.c |   49 ++++++++++++++++++++++++++-----------------------
 1 file changed, 26 insertions(+), 23 deletions(-)

--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -1730,6 +1730,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.
  */
@@ -1776,14 +1798,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))
@@ -1791,22 +1808,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;

  parent reply	other threads:[~2018-09-27  9:04 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-27  9:03 [PATCH 4.9 00/44] 4.9.130-stable review Greg Kroah-Hartman
2018-09-27  9:03 ` [PATCH 4.9 01/44] NFC: Fix possible memory corruption when handling SHDLC I-Frame commands Greg Kroah-Hartman
2018-09-27  9:03 ` [PATCH 4.9 02/44] NFC: Fix the number of pipes Greg Kroah-Hartman
2018-09-27  9:03 ` [PATCH 4.9 03/44] ASoC: cs4265: fix MMTLR Data switch control Greg Kroah-Hartman
2018-09-27  9:03 ` [PATCH 4.9 04/44] ALSA: bebob: fix memory leak for M-Audio FW1814 and ProjectMix I/O at error path Greg Kroah-Hartman
2018-09-27  9:03 ` [PATCH 4.9 05/44] ALSA: bebob: use address returned by kmalloc() instead of kernel stack for streaming DMA mapping Greg Kroah-Hartman
2018-09-27  9:03 ` [PATCH 4.9 06/44] ALSA: emu10k1: fix possible info leak to userspace on SNDRV_EMU10K1_IOCTL_INFO Greg Kroah-Hartman
2018-09-27  9:03 ` [PATCH 4.9 07/44] ALSA: firewire-digi00x: fix memory leak of private data Greg Kroah-Hartman
2018-09-27  9:03 ` [PATCH 4.9 08/44] ALSA: firewire-tascam: " Greg Kroah-Hartman
2018-09-27  9:03 ` [PATCH 4.9 09/44] ALSA: fireworks: fix memory leak of response buffer at error path Greg Kroah-Hartman
2018-09-27  9:03 ` [PATCH 4.9 10/44] ALSA: oxfw: fix memory leak for model-dependent data " Greg Kroah-Hartman
2018-09-27  9:04 ` [PATCH 4.9 11/44] ALSA: oxfw: fix memory leak of discovered stream formats " Greg Kroah-Hartman
2018-09-27  9:04 ` [PATCH 4.9 12/44] ALSA: oxfw: fix memory leak of private data Greg Kroah-Hartman
2018-09-27  9:04 ` [PATCH 4.9 13/44] platform/x86: alienware-wmi: Correct a memory leak Greg Kroah-Hartman
2018-09-27  9:04 ` [PATCH 4.9 14/44] xen/netfront: dont bug in case of too many frags Greg Kroah-Hartman
2018-09-27  9:04 ` [PATCH 4.9 15/44] xen/x86/vpmu: Zero struct pt_regs before calling into sample handling code Greg Kroah-Hartman
2018-09-27  9:04 ` [PATCH 4.9 16/44] Revert "PCI: Add ACS quirk for Intel 300 series" Greg Kroah-Hartman
2018-09-27  9:04 ` [PATCH 4.9 17/44] ring-buffer: Allow for rescheduling when removing pages Greg Kroah-Hartman
2018-09-27  9:04 ` [PATCH 4.9 18/44] mm: shmem.c: Correctly annotate new inodes for lockdep Greg Kroah-Hartman
2018-09-27  9:04 ` [PATCH 4.9 19/44] gso_segment: Reset skb->mac_len after modifying network header Greg Kroah-Hartman
2018-09-27  9:04 ` [PATCH 4.9 20/44] ipv6: fix possible use-after-free in ip6_xmit() Greg Kroah-Hartman
2018-09-27  9:04 ` [PATCH 4.9 21/44] net/appletalk: fix minor pointer leak to userspace in SIOCFINDIPDDPRT Greg Kroah-Hartman
2018-09-27  9:04 ` [PATCH 4.9 22/44] net: hp100: fix always-true check for link up state Greg Kroah-Hartman
2018-09-27  9:04 ` Greg Kroah-Hartman [this message]
2018-09-27  9:04 ` [PATCH 4.9 24/44] neighbour: confirm neigh entries when ARP packet is received Greg Kroah-Hartman
2018-09-27  9:04 ` [PATCH 4.9 25/44] scsi: target: iscsi: Use hex2bin instead of a re-implementation Greg Kroah-Hartman
2018-09-27  9:04 ` [PATCH 4.9 26/44] ocfs2: fix ocfs2 read block panic Greg Kroah-Hartman
2018-09-27  9:04 ` [PATCH 4.9 27/44] drm/nouveau/drm/nouveau: Fix bogus drm_kms_helper_poll_enable() placement Greg Kroah-Hartman
2018-09-27  9:04 ` [PATCH 4.9 28/44] drm/nouveau/drm/nouveau: Use pm_runtime_get_noresume() in connector_detect() Greg Kroah-Hartman
2018-09-27  9:04 ` [PATCH 4.9 29/44] drm/nouveau/drm/nouveau: Prevent handling ACPI HPD events too early Greg Kroah-Hartman
2018-09-27  9:04 ` [PATCH 4.9 30/44] drm/vc4: Fix the "no scaling" case on multi-planar YUV formats Greg Kroah-Hartman
2018-09-27  9:04 ` [PATCH 4.9 31/44] tty: vt_ioctl: fix potential Spectre v1 Greg Kroah-Hartman
2018-09-27  9:04 ` [PATCH 4.9 32/44] ext4: check to make sure the rename(2)s destination is not freed Greg Kroah-Hartman
2018-09-27  9:04 ` [PATCH 4.9 33/44] ext4: avoid divide by zero fault when deleting corrupted inline directories Greg Kroah-Hartman
2018-09-27  9:04 ` [PATCH 4.9 34/44] ext4: recalucate superblock checksum after updating free blocks/inodes Greg Kroah-Hartman
2018-09-27  9:04 ` [PATCH 4.9 35/44] ext4: fix online resizes handling of a too-small final block group Greg Kroah-Hartman
2018-09-27  9:04 ` [PATCH 4.9 36/44] ext4: fix online resizing for bigalloc file systems with a 1k block size Greg Kroah-Hartman
2018-09-27  9:04 ` [PATCH 4.9 37/44] ext4: dont mark mmp buffer head dirty Greg Kroah-Hartman
2018-09-27  9:04 ` [PATCH 4.9 38/44] ext4: show test_dummy_encryption mount option in /proc/mounts Greg Kroah-Hartman
2018-09-27  9:04 ` [PATCH 4.9 39/44] sched/fair: Fix vruntime_normalized() for remote non-migration wakeup Greg Kroah-Hartman
2018-09-27  9:04 ` [PATCH 4.9 40/44] HID: sony: Update device ids Greg Kroah-Hartman
2018-09-27  9:04 ` [PATCH 4.9 41/44] HID: sony: Support DS4 dongle Greg Kroah-Hartman
2018-09-27  9:04 ` [PATCH 4.9 42/44] PCI: aardvark: Size bridges before resources allocation Greg Kroah-Hartman
2018-09-27  9:04 ` [PATCH 4.9 43/44] vmw_balloon: include asm/io.h Greg Kroah-Hartman
2018-09-27  9:04 ` [PATCH 4.9 44/44] iw_cxgb4: only allow 1 flush on user qps Greg Kroah-Hartman
2018-09-27 18:59 ` [PATCH 4.9 00/44] 4.9.130-stable review Nathan Chancellor
2018-09-27 19:51 ` Rafael David Tinoco
2018-09-27 20:14 ` Shuah Khan
2018-09-27 21:58 ` Guenter Roeck

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180927090121.158006866@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=davem@davemloft.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).