Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp5894459imb; Fri, 8 Mar 2019 04:58:21 -0800 (PST) X-Google-Smtp-Source: APXvYqxoxqqFiMRw5rNhIag7Gh12kx/oFEmByuIXyZh7q7+1wTt9VMN8Clywl+X+eUsPywind7/S X-Received: by 2002:a65:6098:: with SMTP id t24mr8516534pgu.57.1552049901506; Fri, 08 Mar 2019 04:58:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1552049901; cv=none; d=google.com; s=arc-20160816; b=vRFkwML/Euhu2VfcU22XrRGzPTWTQSausq0JvUMz0evNX/WwLpEG2qVVC40U7kMq+H fNnKRpH0s0fURNWBftXiIVyliCyGi+ykrD4js5BUXGgqYlDKM6kcvVfx+6+g7LPVRT97 /t66obmEI7kNwpmc8ulTEDV7FuMaHoTAGkAAQ9c5g8XFcGwXXs8UnSoLzob19sTxSH8+ Zvp46zKe39WsAb1+g7MnqgvVI17VyhQa8OGkdoeI6QZirjBT2q5+O5R1Og77naj4XFVi Psp00eY6JcTAwjt08FF96vTSECD0xd47SXttmVLa5oWJjg404pcXBJwyR5OJMCfPzqVb hl3Q== 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=m9ZAOcEFeQOPU3+BMcNAPhpZkGqIWGfm7alUL1jLtaw=; b=tp1nzxF+GQhijbvkmJ90n4Xst3URYXkf0we2gjxVmdJB9SciLcZ81Xu4Du5b5E6YC7 WJjYRz8Rg9sueudj00+fU0kWXxCwsbIhWGjBuwWmv79g0eEGQAqC/mlzjoTRILMHokND QIUh6o7d7+6iUDksoxEbhGBkDM8SwLkyv4xbIx/MrhNQ59XsSIQLCtYCqKjlmNINBH1N CdfKCOUFknrWiO59xwwSASgTZpyIw1o+LhntVE7IeESf7f1EYEffKUIcLzPVzX/f1egX gxRSCbrCrYD6GBOvL96nf9IRwbMOWrVq8D78XBJgZngRx9r1DWav2FtfEttZV01O+jwT J9EQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=fU4XZ9uW; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b6si6350215pgw.475.2019.03.08.04.58.06; Fri, 08 Mar 2019 04:58:21 -0800 (PST) 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=fU4XZ9uW; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727558AbfCHMzp (ORCPT + 99 others); Fri, 8 Mar 2019 07:55:45 -0500 Received: from mail.kernel.org ([198.145.29.99]:59848 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726856AbfCHMzn (ORCPT ); Fri, 8 Mar 2019 07:55:43 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.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 AB32F20449; Fri, 8 Mar 2019 12:55:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1552049743; bh=5Uu9HhoF6zpuPAf42qg5I6QjdkLAz9Zt8+FvmvpJUwo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fU4XZ9uWqVzuZRlPmjc8iLVlyQTNrpasmh0okxCls2fxqq+mQXDbARLAY0C0921Q0 U2Un5Enl7khTYaxmLWkHaoZeD+dKOzZIlbYrfxO4Rwwr+jt+SVYX58ybwPg7kE9VcS IJh4yUxOT4/0IFp1HUaaGxGCTUslMAwIDnm7Ijk4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sergey Nazarov , Paul Moore , "David S. Miller" Subject: [PATCH 4.20 50/76] net: avoid use IPCB in cipso_v4_error Date: Fri, 8 Mar 2019 13:50:02 +0100 Message-Id: <20190308124916.582948026@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190308124914.789210760@linuxfoundation.org> References: <20190308124914.789210760@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore 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 4.20-stable review patch. If anyone has any objections, please let me know. ------------------ From: Nazarov Sergey [ Upstream commit 3da1ed7ac398f34fff1694017a07054d69c5f5c5 ] Extract IP options in cipso_v4_error and use __icmp_send. Signed-off-by: Sergey Nazarov Acked-by: Paul Moore Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- include/net/ip.h | 2 ++ net/ipv4/cipso_ipv4.c | 17 +++++++++++++++-- net/ipv4/ip_options.c | 22 +++++++++++++++++----- 3 files changed, 34 insertions(+), 7 deletions(-) --- a/include/net/ip.h +++ b/include/net/ip.h @@ -665,6 +665,8 @@ static inline int ip_options_echo(struct } void ip_options_fragment(struct sk_buff *skb); +int __ip_options_compile(struct net *net, struct ip_options *opt, + struct sk_buff *skb, __be32 *info); int ip_options_compile(struct net *net, struct ip_options *opt, struct sk_buff *skb); int ip_options_get(struct net *net, struct ip_options_rcu **optp, --- a/net/ipv4/cipso_ipv4.c +++ b/net/ipv4/cipso_ipv4.c @@ -1736,13 +1736,26 @@ validate_return: */ void cipso_v4_error(struct sk_buff *skb, int error, u32 gateway) { + unsigned char optbuf[sizeof(struct ip_options) + 40]; + struct ip_options *opt = (struct ip_options *)optbuf; + if (ip_hdr(skb)->protocol == IPPROTO_ICMP || error != -EACCES) return; + /* + * We might be called above the IP layer, + * so we can not use icmp_send and IPCB here. + */ + + memset(opt, 0, sizeof(struct ip_options)); + opt->optlen = ip_hdr(skb)->ihl*4 - sizeof(struct iphdr); + if (__ip_options_compile(dev_net(skb->dev), opt, skb, NULL)) + return; + if (gateway) - icmp_send(skb, ICMP_DEST_UNREACH, ICMP_NET_ANO, 0); + __icmp_send(skb, ICMP_DEST_UNREACH, ICMP_NET_ANO, 0, opt); else - icmp_send(skb, ICMP_DEST_UNREACH, ICMP_HOST_ANO, 0); + __icmp_send(skb, ICMP_DEST_UNREACH, ICMP_HOST_ANO, 0, opt); } /** --- a/net/ipv4/ip_options.c +++ b/net/ipv4/ip_options.c @@ -251,8 +251,9 @@ static void spec_dst_fill(__be32 *spec_d * If opt == NULL, then skb->data should point to IP header. */ -int ip_options_compile(struct net *net, - struct ip_options *opt, struct sk_buff *skb) +int __ip_options_compile(struct net *net, + struct ip_options *opt, struct sk_buff *skb, + __be32 *info) { __be32 spec_dst = htonl(INADDR_ANY); unsigned char *pp_ptr = NULL; @@ -468,11 +469,22 @@ eol: return 0; error: - if (skb) { - icmp_send(skb, ICMP_PARAMETERPROB, 0, htonl((pp_ptr-iph)<<24)); - } + if (info) + *info = htonl((pp_ptr-iph)<<24); return -EINVAL; } + +int ip_options_compile(struct net *net, + struct ip_options *opt, struct sk_buff *skb) +{ + int ret; + __be32 info; + + ret = __ip_options_compile(net, opt, skb, &info); + if (ret != 0 && skb) + icmp_send(skb, ICMP_PARAMETERPROB, 0, info); + return ret; +} EXPORT_SYMBOL(ip_options_compile); /*