Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp576817img; Fri, 22 Mar 2019 04:23:44 -0700 (PDT) X-Google-Smtp-Source: APXvYqyipv7tMF1eH3sNeXQwF3on/Gw1j9cVnA5UbLdy7niJF5u//ljXYLGUYEkWTVT7ACXiMmq+ X-Received: by 2002:a63:6e4c:: with SMTP id j73mr8608175pgc.276.1553253824557; Fri, 22 Mar 2019 04:23:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553253824; cv=none; d=google.com; s=arc-20160816; b=kb/DHboMQHY8BD1ui/Q4AM5lbSaZPTrJ0Q8jHIzZu8lkE9lsr136xkKq41ifPuw/Qv YXghmE+/JKAi+4HN9uCwQWeRf9D53xtZAL/Zmim+J+ia3Ly9VaCnr4nmdLRK09GWmFuj ePnEHnIABxkNgB08Xw/4tEHWXDOyea5lk4iGkgtMk7bgfam3vgzrWnPOPPZyLrFTMR4U Mzs3ugoWMZ9vMWqjwa2qFvmJGl0f9LpRAStgnTPDGqI+KYc1uI2YhAO2YCEb5nq6cRGE pDc2MCrX/nGMuRLaMEa3ECEz0LXG7QTPuNm5ia3za6fGKc/Kx92qZFyRhYyWQfyjgqem wQWA== 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=vvVbY+n5MKn1XvQhAjK5zUQk1b/+5h3ot7KGWYp5AXg=; b=HQTYgQJKm9dLXMNJo1pGnlr8q2HLnpXD8AHdCTZbbc3b09TDJVQQz5xbrxjZBhlxZX Is6FmhImNOX7L5igW5Bj4bS4DlDpugiEONo6KHh3oveiTcVGqfz3XgswdzjmkjLs0u0h 4+nskAhJVr5NRf7f18gWKFez6h4BsyXCJZfBNlpOgJ3IqqqEtps9pzk/gN2Y6cokgwVD crw9UzdpFfMzUmaXKHFluxDMk3fhY0su0EjiBOBqhJYlywa+RSLVa+FsOxBYFWcDPajA m3COfxy4ynVNeULghmXwpce6VxYxR+OVqsi8YmRc1j6K2wtC/51iHP8wsft2qdvGD2Ws sJqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=GCwuGxT7; 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 t6si975763pgt.476.2019.03.22.04.23.26; Fri, 22 Mar 2019 04:23:44 -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=GCwuGxT7; 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 S1728699AbfCVLV5 (ORCPT + 99 others); Fri, 22 Mar 2019 07:21:57 -0400 Received: from mail.kernel.org ([198.145.29.99]:48494 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728272AbfCVLV4 (ORCPT ); Fri, 22 Mar 2019 07:21:56 -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 8833C218A2; Fri, 22 Mar 2019 11:21:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553253715; bh=w6wuoRYLFjTnx/0udMQ4nk5Zfr19Xp6L/zzKjYGWMG0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GCwuGxT7U479SR5uVFzY3gRENq8TSUQoNd8OOufoiyaodzfA4oTx8zaWmBn9WjTXV D26G4IyGDaa8vFjrP8Pg2PUMMaXRSyCFG+gS14Tay4tabgWQydBWwRuUa9mrSm5CDL jfQk2cMX4Q+/X8MPTKgk1YrSSOvi9v19igEKB+Dc= 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 3.18 049/134] net: avoid use IPCB in cipso_v4_error Date: Fri, 22 Mar 2019 12:14:22 +0100 Message-Id: <20190322111213.485518717@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190322111210.465931067@linuxfoundation.org> References: <20190322111210.465931067@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 3.18-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 @@ -512,6 +512,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 @@ -1803,13 +1803,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 @@ -253,8 +253,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; @@ -470,11 +471,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); /*