Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp5898129imb; Fri, 8 Mar 2019 05:02:52 -0800 (PST) X-Google-Smtp-Source: APXvYqzbCKOlkax4t74pN7WdxQj+s9gbsGG/By8An0gpcRsMQK3hypomctGu9l7XU7EYG5plOks2 X-Received: by 2002:a17:902:7614:: with SMTP id k20mr18605229pll.298.1552050171920; Fri, 08 Mar 2019 05:02:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1552050171; cv=none; d=google.com; s=arc-20160816; b=S0gj/QqITplZn9zc7GzhH5X7GvzquZnciGkwZ0s+8P2K0npLhneNDcErjZXdl9bCm8 GbDCzYLYLQGfTlboCAnLehkyQ7pa6vxS4zfE8SIjd5Msim2MqU+dGTxu3fsrZ446tp9d U4wdW5oxsK5EUYZFMM42zqNoRCsLghF5A3sUZRXeIU7Ny19R/N8rv6ulgP+JN/2xJ4Dt JIVSOiPtZtgNZwQHHfH0k3nLTjFi7378PFi6GElNmK0JHd2vwG9UucP8owZXx1erW0N1 sf4b1DDcz02ckZ3OI9gi/pv2+LcsOiKwkyBc/jEm6PSJRoIoQBbzBCiCahRd/0ff6s2f iZZA== 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=QXawufj/Afl4BQjepLTpTCf3A6cxtFAdSM/ebAbUfGs=; b=lBnagkyF2RfU8dN1S70XfVb3gVGuz0xlk9S82QVRR1J/QJFsVlKtcP+UOexMrrXj1h Eco8RwDb6xW4/MPzkIL41cAIksUP2DdG6FbZSuOq6mOe6q0i0/EwhS9cg0VzPOKCubIH //qaLSt81xzDQWSiMyr9K5sIjytLJAlmrMHxt0L8+6Ka6e2LjID0TRpLr36ftTp0VZvO qfw1x7I7ndoYw3OZLWAnRU5OvE1jXLwDT3eTNRrItr8WdlrfSclVbmYtAbkLJvdHls9w cXXbQzMPK8yXy9woWBIQMRlUllLjt7Qg//iXlnQO6TU0ZpBFgAXJRykjuzC6g20s4pu2 s3OQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Ac75dO+r; 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 i6si6549061pgq.423.2019.03.08.05.02.35; Fri, 08 Mar 2019 05:02:51 -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=Ac75dO+r; 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 S1727512AbfCHNBJ (ORCPT + 99 others); Fri, 8 Mar 2019 08:01:09 -0500 Received: from mail.kernel.org ([198.145.29.99]:38312 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728319AbfCHNBG (ORCPT ); Fri, 8 Mar 2019 08:01:06 -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 BEA66214AE; Fri, 8 Mar 2019 13:01:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1552050065; bh=JbJqeOia4R7QHIFHKqpUuAcYzNZYojxlNLepwDpmHPY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ac75dO+r7dhju5LsJgEGuhKVZL0KoJDigUOEnod35oF89yFARS5TZeU96X6/pSLcT mLiXON5TuooHQlo0JR17VPJUpSg9lSpbAgipbLWGtB1VuTYluuvNQAZu7ysnJUBOK1 hojUeDBC4USQgwq6z6OtD9v/dM4vz+W4Qk8S3PAk= 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.19 43/68] net: avoid use IPCB in cipso_v4_error Date: Fri, 8 Mar 2019 13:50:13 +0100 Message-Id: <20190308124912.820469319@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190308124910.696595153@linuxfoundation.org> References: <20190308124910.696595153@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.19-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 @@ -638,6 +638,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); /*