Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp132229ybm; Tue, 26 May 2020 12:34:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz3JITz39XEXKJsXBrPWy29rQcpTl4jWCLlYxJIFVHHAX9zgd4WSdJooilupKux4KwjREQn X-Received: by 2002:a17:906:4d45:: with SMTP id b5mr2421893ejv.146.1590521672151; Tue, 26 May 2020 12:34:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590521672; cv=none; d=google.com; s=arc-20160816; b=jNbNFiobpsqk39tIQd+nYi6qyd9ClPLKlfVAq+1pe9XWXXMTQN3hmT8eyj+nteJO+X SCuqKvXo4IFNqtof2wbXOp6qdgSSQY+EPAy2EExSFcA5h5bzyuElnBGu0BjgS5kkP3pi jKLS461+Zw2Zwp/gpZuxzxpSjDSaaAQYH1niZq7ibFT12IgQDhSwPuEgXT9aHf3JxsrV Uxzgk0W4AHCSUoxCMw0lEcLvjKVCGW3zjbL2HgVZResic9EKgyiXNWrEi7HZIbp+Hy91 ld2VKwI8DbnzK7bsId9TQHAvQCbn8f0itrjJ8dlFoTFW6IxfXMyWgmoCKP3dhGQwb9YW Hfew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=oGlPZzjhGMGYGkf5GpZy91cs4IT9L/j7WNT8SJY7GAs=; b=v2tCQOZ77vjKcnc3KUuyY2jarklq75yXDAszBUYbMJs6QdGE5Hjl9iyIQdo/XDwRoO LmoDnndorZ/0QdfuifKf+kjB3W+XdvsIApC/vH5V5+zuV8g3b2nyDzOMR3Hncax4LQ9D X+CSQKhjh9EDfwKqXPW+FUt3sp4iLaxToDPzhpxlM0fmtwVUCCrShNvt2CLVixMfyWII pGIfsbuTsUzzNgvNpE8DmdkuTmLKpLS188HB6/A0wTbNEoJfs6plUObaY2qKBSjwjuvo AosupvsMg5u7axuz7h/sadwyn5pKNwl+LcYMpXGTG3ELeLKSy18bA2S8oVEnp9Vj2V7P II3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Q2mYKCU9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id jr11si414606ejb.602.2020.05.26.12.34.06; Tue, 26 May 2020 12:34:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Q2mYKCU9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390511AbgEZS7Y (ORCPT + 99 others); Tue, 26 May 2020 14:59:24 -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) {