Received: by 2002:ac0:950c:0:0:0:0:0 with SMTP id f12csp2292029imc; Tue, 12 Mar 2019 10:43:42 -0700 (PDT) X-Google-Smtp-Source: APXvYqyXIagKM2HdzjkVRcXnzjZrykBs0u7rfhSXkeef0YCramMtb4WdzJdDS3f/cDhRvyu1IIeQ X-Received: by 2002:a62:54c5:: with SMTP id i188mr38868390pfb.188.1552412622281; Tue, 12 Mar 2019 10:43:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552412622; cv=none; d=google.com; s=arc-20160816; b=evK06igOU6UqAenPIk7NdVk+Y1HxNA/vik5peBpJWfNQnzbUiYPi41xO4AoqaZBTYM COkD5foVMK2QASHwK45CVx8M+bm8LOMVEbCowvprg3sMRd7dzLhPHmcrrirzD2808X3P eN3dDpALfgFw4L5mvzlNTRmSKbg4eElsf5SfjvTTh/0ceYtbpTbNj43h4NTtQDmHPvDn EgBAKlxfiVaUILBE9Q9uXAwgEdqHKmjEcTmPGKD7/9JgRoN/fVuStfgFkQPp86DCJWrq f4dHC4eh8r5lOdG8JdiTqhU/Il75iAsEJbx+5E9AFQemqBQ/3B86tBhCclo2/DK1tpXr M9VA== 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=w+ab29RTr5MBJ900N6/hErqmQVJPxMkma02wo6GdF8I=; b=HSbi48ES4rW+5Ch5bWkX7CmB+FaMA6Xs2ryUvYBtGFhrciudPrZmZFNmSrCd+znhcS XYmfQ4U5BacFYC4cYl5NtE+MDwLO1DDtNL+N48nerUCd1ukKS7K0we8oW/uMaWKfCth+ r75zR3XaYI/3K+EfpylkFO78lmFeZy0pbo663rehP8y/s/NQl3Z0EN6Ul6/CqcLZUk+d xN0HUwZVS838ZcbyO+fQxqgfk2/LSEwBr88OmkQYqbSml8pjIlklxfO9lKv+cp74qN76 pnYavSaEBNMtxUrnXBmj73TYMNqNyCe5NguYl5sP9NmwY/fqCXySngV1JwtlGTR11cQK 9efw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=0yCkDIbA; 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 p18si8678508plq.130.2019.03.12.10.43.26; Tue, 12 Mar 2019 10:43:42 -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=0yCkDIbA; 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 S1729251AbfCLRm2 (ORCPT + 99 others); Tue, 12 Mar 2019 13:42:28 -0400 Received: from mail.kernel.org ([198.145.29.99]:57292 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728940AbfCLRP6 (ORCPT ); Tue, 12 Mar 2019 13:15:58 -0400 Received: from localhost (unknown [104.133.8.98]) (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 43FDD217D4; Tue, 12 Mar 2019 17:15:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1552410957; bh=7Is0rueDIq6J2yu3F3DD+mkiYZ9srEkdZ6V2LnYR3Zo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0yCkDIbACVRc4ek2oU0MsjUr3iTfQJ1pD7LHSdpPfHdw5KgHGlWVqjEKlOK1yKjrt u54663dT43wr4f9Kiz6YmgmDWtoM+s3Im+lFtokSAbWO1IlIftzppMtxD94cZkfwlh HA6x+zXSIfKTwvouBii/2+k+4Eb1qKSYiwcK5tP8= 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.14 027/135] net: avoid use IPCB in cipso_v4_error Date: Tue, 12 Mar 2019 10:07:54 -0700 Message-Id: <20190312170343.653075789@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190312170341.127810985@linuxfoundation.org> References: <20190312170341.127810985@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.14-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 @@ -593,6 +593,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); /*