Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1622661

[PATCH net-next] l2tp: device MTU setup, tunnel socket needs a lock

Path csiph.com!aioe.org!bofh.it!news.nic.it!robomod
From "R. Parameswaran" <parameswaran.r7@gmail.com>
Newsgroups linux.kernel
Subject [PATCH net-next] l2tp: device MTU setup, tunnel socket needs a lock
Date Thu, 13 Apr 2017 03:40:01 +0200
Message-ID <tvBTP-49F-1@gated-at.bofh.it> (permalink)
X-Original-To netdev@vger.kernel.org
Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:date:to:cc:subject:message-id:user-agent:mime-version; bh=Dzzn2cd7BBgAdwOIqKmiVo1LW1nqBgFdynhnPqCGhEg=; b=eQm9rWUN/7jv8oKGr8rk5kSV9i5VD4RHZaT92fpgE7mIiUrnbPZILaaAU2zuVZ0kOv qljwE47CiQXgtqGhcnRbTLDAjDBReCGCqta560tuT22wgjGV3EI6l9oAfouTxN58XnRx TawHmMpUac3f5LAaY01oSIBe0I9IO6w5y3hBwOjmw88raeUK+HTicjpuSP6u9SDvTA73 NdF2IPu++Tv7rS+QZlKN86sQ263/76KgT5p52+WOt3W1OIHeC3yWHr5UTSOgmkT03TEw CNiL8ElNJtcMq+0/aTMbdd87okIX5ou5S/g9AI4Cby1zAi05BTzvsrIqfUFjtf1RYSd1 Z10Q==
X-Google-Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:date:to:cc:subject:message-id:user-agent :mime-version; bh=Dzzn2cd7BBgAdwOIqKmiVo1LW1nqBgFdynhnPqCGhEg=; b=Y3cXy7iOeEA28LfqUWBzWC4zLD+S49zIi10WVZb3/HMiR8T2RPFIxuxzbY/KyC8IE0 d8FZmQrelTusgQOgSdaoCZPYnN5F7TspJIl+8aSCEKlEZbxJEp3PsyOb88la0ZW4OtWZ NePnTWv2m7chTbYbdL1vC+ryFGC251pplJ1c1ulHeAXyFvMhEyTEVgJ7s2WObMy0YJzB ZJUc98Z4v3Kx6QsFtQDbtsI8pbEnpHIMHERX25nwWjDEHn7S4ayq06n/QhtbtzX5u7gs 7IcTva5ySWUVlGanKbsj5IbD88bNcPM36z/J/HRZUQoQk6iukPbZ+8HD6gsZmfHF41A/ KqeA==
X-Gm-Message-State AN3rC/7pB4W0EYe7bGW1bSIj9jt6yCUG7/2YDSL/OIhV9O4pfhscL5Xb bWDOqD12jRhXRg==
X-Received by 10.84.222.8 with SMTP id w8mr792790pls.103.1492047064431; Wed, 12 Apr 2017 18:31:04 -0700 (PDT)
X-Google-Original-From "R. Parameswaran" <nelson@eng.brocade.com>
X-X-Sender nelson@nelson51.eng.vyatta.net
User-Agent Alpine 2.11 (DEB 23 2013-08-11)
MIME-Version 1.0
Content-Type TEXT/PLAIN; charset=US-ASCII
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 58
Organization linux.* mail to news gateway
X-Original-Cc kleptog@svana.org, jchapman@katalix.com, davem@redhat.com, nprachan@brocade.com, rshearma@brocade.com, stephen@networkplumber.org, sdietric@brocade.com, ciwillia@brocade.com, lboccass@brocade.com, dfawcus@brocade.com, bhong@brocade.com, jblunck@brocade.com, g.nault@alphalink.fr, linux-kernel@vger.kernel.org
X-Original-Date Wed, 12 Apr 2017 18:31:04 -0700 (PDT)
X-Original-Message-ID <alpine.DEB.2.11.1704121825410.1923@nelson51.eng.vyatta.net>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref csiph.com linux.kernel:1622661

Show key headers only | View raw


The MTU overhead calculation in L2TP device set-up
merged via commit b784e7ebfce8cfb16c6f95e14e8532d0768ab7ff
needs to be adjusted to lock the tunnel socket while
referencing the sub-data structures to derive the
socket's IP overhead.

Reported-by: Guillaume Nault <g.nault@alphalink.fr>
Tested-by: Guillaume Nault <g.nault@alphalink.fr>
Signed-off-by: R. Parameswaran <rparames@brocade.com>
---
 include/linux/net.h | 2 +-
 net/l2tp/l2tp_eth.c | 2 ++
 net/socket.c        | 2 +-
 3 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/include/linux/net.h b/include/linux/net.h
index a42fab2..abcfa46 100644
--- a/include/linux/net.h
+++ b/include/linux/net.h
@@ -298,7 +298,7 @@ int kernel_sendpage(struct socket *sock, struct page *page, int offset,
 int kernel_sock_ioctl(struct socket *sock, int cmd, unsigned long arg);
 int kernel_sock_shutdown(struct socket *sock, enum sock_shutdown_cmd how);
 
-/* Following routine returns the IP overhead imposed by a socket.  */
+/* Routine returns the IP overhead imposed by a (caller-protected) socket. */
 u32 kernel_sock_ip_overhead(struct sock *sk);
 
 #define MODULE_ALIAS_NETPROTO(proto) \
diff --git a/net/l2tp/l2tp_eth.c b/net/l2tp/l2tp_eth.c
index 138566a..b722d55 100644
--- a/net/l2tp/l2tp_eth.c
+++ b/net/l2tp/l2tp_eth.c
@@ -225,7 +225,9 @@ static void l2tp_eth_adjust_mtu(struct l2tp_tunnel *tunnel,
 		dev->needed_headroom += session->hdr_len;
 		return;
 	}
+	lock_sock(tunnel->sock);
 	l3_overhead = kernel_sock_ip_overhead(tunnel->sock);
+	release_sock(tunnel->sock);
 	if (l3_overhead == 0) {
 		/* L3 Overhead couldn't be identified, this could be
 		 * because tunnel->sock was NULL or the socket's
diff --git a/net/socket.c b/net/socket.c
index eea9970..c2564eb 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -3360,7 +3360,7 @@ EXPORT_SYMBOL(kernel_sock_shutdown);
 /* This routine returns the IP overhead imposed by a socket i.e.
  * the length of the underlying IP header, depending on whether
  * this is an IPv4 or IPv6 socket and the length from IP options turned
- * on at the socket.
+ * on at the socket. Assumes that the caller has a lock on the socket.
  */
 u32 kernel_sock_ip_overhead(struct sock *sk)
 {
-- 
2.1.4

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

[PATCH net-next] l2tp: device MTU setup, tunnel socket needs a  lock "R. Parameswaran" <parameswaran.r7@gmail.com> - 2017-04-13 03:40 +0200
  Re: [PATCH net-next] l2tp: device MTU setup, tunnel socket needs a  lock David Miller <davem@davemloft.net> - 2017-04-17 19:10 +0200

csiph-web