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 78C6CC433E0 for ; Tue, 26 May 2020 18:57:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 56AC02084C for ; Tue, 26 May 2020 18:57:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1590519436; bh=n/NqSZUexd3WmAYJCy5QjSeuALoNAEoTCx58MVGOB5w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=IWPiHfYuhW/ZSyv/0dnQZOQlj1kHlcxxjBzAYHvoEnTw/A5Ee3WYLjq6ZGQ5r/095 QRk058MEQdOUcVjfHeqpASYbHskzCjdPwFyj/ISfP1DWziqPkjY7+e7rPnl5ljH4PO plr24z/H8kcb/ejHcgGCSlefpLCVRsL2wmn8O0Tk= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390040AbgEZS5L (ORCPT ); Tue, 26 May 2020 14:57:11 -0400 Received: from mail.kernel.org ([198.145.29.99]:50302 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390011AbgEZS5J (ORCPT ); Tue, 26 May 2020 14:57:09 -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 03FAC20849; Tue, 26 May 2020 18:57:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1590519428; bh=n/NqSZUexd3WmAYJCy5QjSeuALoNAEoTCx58MVGOB5w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OfSbckdJOnTqUsvxfEQo4EVaeCbkFMQ8CDmvsF+HtHk6rsHA5vJcTor/kto5f7od/ HPplY9xDnwuTlLbLFweH/MtGZpDD/WOriiNd7djYpd2xcO9JbKgTfPYY/98HAMAWo7 HpwiHn2R68Ict/daoHwFvKIalQWursHpuUi5GUyw= 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.4 65/65] l2tp: device MTU setup, tunnel socket needs a lock Date: Tue, 26 May 2020 20:53:24 +0200 Message-Id: <20200526183929.373249014@linuxfoundation.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200526183905.988782958@linuxfoundation.org> References: <20200526183905.988782958@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 @@ -291,7 +291,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 @@ -3308,7 +3308,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) {