Received: by 2002:ac0:aa62:0:0:0:0:0 with SMTP id w31-v6csp1964445ima; Thu, 25 Oct 2018 07:39:51 -0700 (PDT) X-Google-Smtp-Source: AJdET5cuSo17d8/TYlPFsmzupA03ByRex9y+FTU5lW0jgScfJO/N+HlQ+i/sSkpxkLvADyESBooh X-Received: by 2002:a17:902:ba8d:: with SMTP id k13-v6mr1820541pls.12.1540478391839; Thu, 25 Oct 2018 07:39:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540478391; cv=none; d=google.com; s=arc-20160816; b=ZVHu3f5zBL0SNfE0ko5oMUadkbvDNhbofVQHfaDebJLL9zpf57I6ME2NGIGFfSafIO rho6IImU/pox+8x7lm20GCzwlqIisKVVUHrYSw/tSPaLIhhMLuTIKk57HX2QY7/IUvn1 NqO8njtG3AlV05gLJ2FYHBmaUCXF2v/2c4YAzsnYl35DbKlSsugmFRtdMsts8P7/PDnK uFALsPsl2giRnqIzF0595VmG9v7/XpeG5/0GUfhjp7KFA3Rd7I0cpS/fX6ivT0sDU4kV DKW02THmNybiX0YZipb9kyqRPFooyM/OE2mj6pGsyIIzO0mfynrPUtVcDTiWryrzgpiX yLBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=TDgjit6spK3F5UpdwJJgGADtnoCTQ4D3irSMybLIar8=; b=SPjA5eaqsWM9Eru/S/o8r2RWFtENt/fJRAcZzwtkFJKqCKeKdFBFiilRG2c7K5GxeT wO/8NomtV7DgfZi8ThlF53xJtBxxYKRaREhcv4wYD2wAdyWWvGBE9gmZC8yVpopjj62J N2agoPBOHOOM2u1EEPgTcetPKla5KFvdEecFWx90gKjv27pGiftWHcTomMVWQZhM/w1E Qurp2pIxJ95FmAN6n2iSo8GqloOb30oVItGzm7pytVCDSWk8gUUAX8MYIcbmCpQa55VH aRWUxOw2S78oDB5qUIuk+NUlhmHUwHdHjGwPBB0M3E4GOhQJ4X+lOlsBjMsqwIZ2gHbM XvlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=MAaqsd3j; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f35-v6si7995202plh.357.2018.10.25.07.39.33; Thu, 25 Oct 2018 07:39:51 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=MAaqsd3j; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729320AbeJYWtR (ORCPT + 99 others); Thu, 25 Oct 2018 18:49:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:58318 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729294AbeJYWtQ (ORCPT ); Thu, 25 Oct 2018 18:49:16 -0400 Received: from sasha-vm.mshome.net (unknown [167.98.65.38]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id ADD2F208A3; Thu, 25 Oct 2018 14:16:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1540476979; bh=3JLCtVfHLvTJnwkceLFvxyF1yPsi0vCi/NRcZsiaXuQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MAaqsd3j91XjaFO+Cyion0MN+8TklglDNw+UkMwNFBKaf6kOJ6yN7g+LABZD17WlR CtEel6XTGUa2HRm8z7TLLd9rLoEFex5hloOtxCr0UDiK0LrL8KzVKOK1xKFnmP8pqX 8QDlGUdenN5JuNz63p0dv25mm1mz+tvRD2VIbFYc= From: Sasha Levin To: stable@vger.kernel.org, linux-kernel@vger.kernel.org Cc: James Chapman , "David S . Miller" , Sasha Levin Subject: [PATCH AUTOSEL 4.9 79/98] l2tp: remove configurable payload offset Date: Thu, 25 Oct 2018 10:14:04 -0400 Message-Id: <20181025141423.213774-79-sashal@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181025141423.213774-1-sashal@kernel.org> References: <20181025141423.213774-1-sashal@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: James Chapman [ Upstream commit 900631ee6a2651dc4fbaecb8ef9fa5f1e3378853 ] If L2TP_ATTR_OFFSET is set to a non-zero value in L2TPv3 tunnels, it results in L2TPv3 packets being transmitted which might not be compliant with the L2TPv3 RFC. This patch has l2tp ignore the offset setting and send all packets with no offset. In more detail: L2TPv2 supports a variable offset from the L2TPv2 header to the payload. The offset value is indicated by an optional field in the L2TP header. Our L2TP implementation already detects the presence of the optional offset and skips that many bytes when handling data received packets. All transmitted packets are always transmitted with no offset. L2TPv3 has no optional offset field in the L2TPv3 packet header. Instead, L2TPv3 defines optional fields in a "Layer-2 Specific Sublayer". At the time when the original L2TP code was written, there was talk at IETF of offset being implemented in a new Layer-2 Specific Sublayer. A L2TP_ATTR_OFFSET netlink attribute was added so that this offset could be configured and the intention was to allow it to be also used to set the tx offset for L2TPv2. However, no L2TPv3 offset was ever specified and the L2TP_ATTR_OFFSET parameter was forgotten about. Setting L2TP_ATTR_OFFSET results in L2TPv3 packets being transmitted with the specified number of bytes padding between L2TPv3 header and payload. This is not compliant with L2TPv3 RFC3931. This change removes the configurable offset altogether while retaining L2TP_ATTR_OFFSET for backwards compatibility. Any L2TP_ATTR_OFFSET value is ignored. Signed-off-by: James Chapman Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- net/l2tp/l2tp_core.c | 14 ++++---------- net/l2tp/l2tp_core.h | 3 --- net/l2tp/l2tp_debugfs.c | 4 ++-- net/l2tp/l2tp_netlink.c | 3 --- 4 files changed, 6 insertions(+), 18 deletions(-) diff --git a/net/l2tp/l2tp_core.c b/net/l2tp/l2tp_core.c index a5333f6cb65a..b96dbe38ecad 100644 --- a/net/l2tp/l2tp_core.c +++ b/net/l2tp/l2tp_core.c @@ -845,10 +845,8 @@ void l2tp_recv_common(struct l2tp_session *session, struct sk_buff *skb, } } - /* Session data offset is handled differently for L2TPv2 and - * L2TPv3. For L2TPv2, there is an optional 16-bit value in - * the header. For L2TPv3, the offset is negotiated using AVPs - * in the session setup control protocol. + /* Session data offset is defined only for L2TPv2 and is + * indicated by an optional 16-bit value in the header. */ if (tunnel->version == L2TP_HDR_VER_2) { /* If offset bit set, skip it. */ @@ -856,8 +854,7 @@ void l2tp_recv_common(struct l2tp_session *session, struct sk_buff *skb, offset = ntohs(*(__be16 *)ptr); ptr += 2 + offset; } - } else - ptr += session->offset; + } offset = ptr - optr; if (!pskb_may_pull(skb, offset)) @@ -1141,8 +1138,6 @@ static int l2tp_build_l2tpv3_header(struct l2tp_session *session, void *buf) } bufp += session->l2specific_len; } - if (session->offset) - bufp += session->offset; return bufp - optr; } @@ -1827,7 +1822,7 @@ void l2tp_session_set_header_len(struct l2tp_session *session, int version) if (session->send_seq) session->hdr_len += 4; } else { - session->hdr_len = 4 + session->cookie_len + session->l2specific_len + session->offset; + session->hdr_len = 4 + session->cookie_len + session->l2specific_len; if (session->tunnel->encap == L2TP_ENCAPTYPE_UDP) session->hdr_len += 4; } @@ -1878,7 +1873,6 @@ struct l2tp_session *l2tp_session_create(int priv_size, struct l2tp_tunnel *tunn session->recv_seq = cfg->recv_seq; session->lns_mode = cfg->lns_mode; session->reorder_timeout = cfg->reorder_timeout; - session->offset = cfg->offset; session->l2specific_type = cfg->l2specific_type; session->l2specific_len = cfg->l2specific_len; session->cookie_len = cfg->cookie_len; diff --git a/net/l2tp/l2tp_core.h b/net/l2tp/l2tp_core.h index 42419f1c24cf..86356a23a0a7 100644 --- a/net/l2tp/l2tp_core.h +++ b/net/l2tp/l2tp_core.h @@ -68,7 +68,6 @@ struct l2tp_session_cfg { int debug; /* bitmask of debug message * categories */ u16 vlan_id; /* VLAN pseudowire only */ - u16 offset; /* offset to payload */ u16 l2specific_len; /* Layer 2 specific length */ u16 l2specific_type; /* Layer 2 specific type */ u8 cookie[8]; /* optional cookie */ @@ -94,8 +93,6 @@ struct l2tp_session { int cookie_len; u8 peer_cookie[8]; int peer_cookie_len; - u16 offset; /* offset from end of L2TP header - to beginning of data */ u16 l2specific_len; u16 l2specific_type; u16 hdr_len; diff --git a/net/l2tp/l2tp_debugfs.c b/net/l2tp/l2tp_debugfs.c index d100aed3d06f..2d2a73280ec2 100644 --- a/net/l2tp/l2tp_debugfs.c +++ b/net/l2tp/l2tp_debugfs.c @@ -181,8 +181,8 @@ static void l2tp_dfs_seq_session_show(struct seq_file *m, void *v) session->lns_mode ? "LNS" : "LAC", session->debug, jiffies_to_msecs(session->reorder_timeout)); - seq_printf(m, " offset %hu l2specific %hu/%hu\n", - session->offset, session->l2specific_type, session->l2specific_len); + seq_printf(m, " offset 0 l2specific %hu/%hu\n", + session->l2specific_type, session->l2specific_len); if (session->cookie_len) { seq_printf(m, " cookie %02x%02x%02x%02x", session->cookie[0], session->cookie[1], diff --git a/net/l2tp/l2tp_netlink.c b/net/l2tp/l2tp_netlink.c index ee03bc866d1b..d6fccfdca201 100644 --- a/net/l2tp/l2tp_netlink.c +++ b/net/l2tp/l2tp_netlink.c @@ -536,9 +536,6 @@ static int l2tp_nl_cmd_session_create(struct sk_buff *skb, struct genl_info *inf } if (tunnel->version > 2) { - if (info->attrs[L2TP_ATTR_OFFSET]) - cfg.offset = nla_get_u16(info->attrs[L2TP_ATTR_OFFSET]); - if (info->attrs[L2TP_ATTR_DATA_SEQ]) cfg.data_seq = nla_get_u8(info->attrs[L2TP_ATTR_DATA_SEQ]); -- 2.17.1