Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp583165img; Fri, 22 Mar 2019 04:32:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqyp5l9X4qrNar48AvXeSrDFP/ZM5tIUruTjnOuqxLocZx/PLay9zAooZ6a2OEXfnGYG6Y5l X-Received: by 2002:a17:902:f209:: with SMTP id gn9mr9067833plb.50.1553254326694; Fri, 22 Mar 2019 04:32:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553254326; cv=none; d=google.com; s=arc-20160816; b=w/F/a5aky3BeyQTtoTbFEaMjuB25H74kMCme5hcKR8jrIistW/Fbsmla/MfYkFhDp0 jNZNtcq59gc4ywgH6EC/S1qfLBHzvT7AKuNhx4eElth8vi4daaDiFU66sH2CqjZPkGCM uUSHmrzUQ8zrHlMEBCg6T3guMlYIJeItg4hwPZee4hAnUFoNBCV4rXgpUpXvKu1Bwbsw mdIrxHPyMq5t+3yocn7x6VIhbZF80wLPvZ/eg2lprxTiolBV/1ODO1aOsEHSkJ6KiPCW AdJdgUG9oACyHJ16I0wK4k5RVF3N2qOcz8N8/c0cqKLYs/TQY68C89XJAf0EvA0biKYb DBpQ== 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=k6P2J8kF2uJHnv5pkjRMPqZbe5FzOkNNgOGtppmH4v8=; b=fy003rFx71VquUafOTSCmVmqpMUHg/TFU+bvHh023b0H0ibBcnP7bmC7wuT3rLm3ww 7GISqaxIFaySMVWU1xfWE7MeqGvel4UzLaQJOYF9aZ4gA8DphlwErz0Ao7SgfBVFNlqi m4IXaO/7Syv+pKrjtw8oACZU6H/UNeQ1MI6jCV6T56rnGPxIo7hmjNJ5CyuDv64QqU8a N9FJBnR+D+rSV2IqLaFAaByR8KDF0vgqM5PH4Q1SZ9OnqlW/d9FXOzXsE/OnsOZClOAB FgM+uJNoMKGqFzePhZdxBRMr3+IVp9fQtWozg0F2kvVC1lfrDZxp2WmJqUD9SDgwCNYW JG2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="d9/VfbAR"; 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 p2si6234645pfd.257.2019.03.22.04.31.49; Fri, 22 Mar 2019 04:32:06 -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="d9/VfbAR"; 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 S1729954AbfCVLab (ORCPT + 99 others); Fri, 22 Mar 2019 07:30:31 -0400 Received: from mail.kernel.org ([198.145.29.99]:58440 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729944AbfCVLaZ (ORCPT ); Fri, 22 Mar 2019 07:30:25 -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 34F0F2183E; Fri, 22 Mar 2019 11:30:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553254224; bh=LDqmSADztmthWpA9ec2cubVmB/5fucOjbTUOJuY/ftw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=d9/VfbARJ2qKvAaUvWOXrG05xZtmK9+MJQyyuxAP20RnMZxFy+zLX/TxQUO2s8W9o nqmT49B51xk8+Kxv6zL25/yYzfUI9AzI0bUBfes0IzIeyt8F/wFG15XjeLDFo4Gy7Q +E0jNjuGo7QUWRnbTKxGJejMjYyXRgPBbHbARDJk= 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.4 070/230] net: avoid use IPCB in cipso_v4_error Date: Fri, 22 Mar 2019 12:13:28 +0100 Message-Id: <20190322111241.591763555@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190322111236.796964179@linuxfoundation.org> References: <20190322111236.796964179@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.4-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 @@ -546,6 +546,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 @@ -1805,13 +1805,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 @@ -254,8 +254,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; @@ -472,11 +473,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); /*