From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F1DC7C433E2 for ; Tue, 26 May 2020 18:59:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CE4E42086A for ; Tue, 26 May 2020 18:59:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1590519565; bh=hJiJ03o0lZ1z/xkUa7Dz3X3U5LU6LHP3tzsv86V5xNg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=L4SrcJ2NjJtbhh/TdiZioVnJYVj5QJbF2YqhykmDjIOn3VkburQiNpaSgLCN+p4iY ALwT2NHNxVCinFR0e87d56nVSmHNwFxkDQb7TqQ0iL6vZQOI+C0gjYF6fYmmIFy8IT QT+p3J+J6qVxZ4AIUYYjdUMchnrLTcH0KcnGDbSg= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389692AbgEZS7Z (ORCPT ); Tue, 26 May 2020 14:59:25 -0400 Received: from mail.kernel.org ([198.145.29.99]:53034 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389903AbgEZS7T (ORCPT ); Tue, 26 May 2020 14:59:19 -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 E5D832086A; Tue, 26 May 2020 18:59:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1590519558; bh=hJiJ03o0lZ1z/xkUa7Dz3X3U5LU6LHP3tzsv86V5xNg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Q2mYKCU9jlDEWdpeMjjxgH+Y/k+IvxuC8gE6GPkOw1AnJhXkTJoo5CNurlIwQi0cR orZkfWR4GVuBnCCyLAtfjnG5EGsV4OMfLGGfyuWc5fz3irszj5gzWnprgL1ztvHeL1 iopSVo/uBd5WjNeUZutQzbQpGxCvVi4MbTCr95Uc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Guillaume Nault , "R. Parameswaran" , "David S. Miller" , Giuliano Procida Subject: [PATCH 4.9 51/64] l2tp: device MTU setup, tunnel socket needs a lock Date: Tue, 26 May 2020 20:53:20 +0200 Message-Id: <20200526183930.465216226@linuxfoundation.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200526183913.064413230@linuxfoundation.org> References: <20200526183913.064413230@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: R. Parameswaran 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 Tested-by: Guillaume Nault Signed-off-by: R. Parameswaran Signed-off-by: David S. Miller Cc: Giuliano Procida Signed-off-by: Greg Kroah-Hartman --- include/linux/net.h | 2 +- net/l2tp/l2tp_eth.c | 2 ++ net/socket.c | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) --- a/include/linux/net.h +++ b/include/linux/net.h @@ -298,7 +298,7 @@ int kernel_sendpage(struct socket *sock, 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) \ --- a/net/l2tp/l2tp_eth.c +++ b/net/l2tp/l2tp_eth.c @@ -240,7 +240,9 @@ static void l2tp_eth_adjust_mtu(struct l 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 --- a/net/socket.c +++ b/net/socket.c @@ -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) {