l2tp: device MTU setup, tunnel socket needs a lock
authorR. Parameswaran <parameswaran.r7@gmail.com>
Thu, 13 Apr 2017 01:31:04 +0000 (18:31 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 27 May 2020 14:42:00 +0000 (16:42 +0200)
commit 57240d007816486131bee88cd474c2a71f0fe224 upstream.

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>
Signed-off-by: David S. Miller <davem@davemloft.net>
Cc: Giuliano Procida <gprocida@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
include/linux/net.h
net/l2tp/l2tp_eth.c
net/socket.c

index 2c8b092f3f17268876e0a7d4158f0cbd12844209..54270c4707cf238211acd06ac6361d1b12208685 100644 (file)
@@ -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) \
index 60764ac2ddea23f2756052ed0caa854e8734af7d..8b8fc2337960cd466f4b93b2c0ecec297482f5e1 100644 (file)
@@ -240,7 +240,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
index 4892719a8a660e7fa7e80b881c1a65ae31ffdf7e..88abc72df2a69b119593c99774249510cea9b9f1 100644 (file)
@@ -3325,7 +3325,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)
 {