Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp9986685ybi; Wed, 24 Jul 2019 13:35:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqyiuMnMEacaEnN35yVYPS8EcMCuvwgfUM8CwZaBTY9zry++IpQKeXP5IiS5pTWDSoxYUOY4 X-Received: by 2002:a17:90a:b115:: with SMTP id z21mr27367874pjq.64.1564000556526; Wed, 24 Jul 2019 13:35:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564000556; cv=none; d=google.com; s=arc-20160816; b=q2EbWmDKGg7h1z1guO45LHQ0LsJqcmDATAXVGqSQZhs2WEB30shmNiAbMnqOyFivGJ yVUOjcUNvr9buoNK/4sAf+FyFiT7yAbugr/g5Sdmno8fvvm9u49ztqT2wJw0SMGRFi6a EERqbE+dFmQ/1EGCF08gd+JQcE3rLsw0Y/jM8GZ2qhssNsqA9lpY9o3GqAo/5kwxTTIb WviiMfXyRQILgjz22xvW3tYQQ6c0hOAGFFk+gim0PNQKhDdnKIHp6OmuvzQ230ACAhNQ mI+7zVxi4c90ONlX3mUCcrRmrmSYqqqX81xBZitWMtIR+oHTrOqG3VhbAqeAqZQIZv53 yEQQ== 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=T4pH2OESPxQyn5mwSFroF6tirtMYaoRZVvBm1+gzP54=; b=ZRApNb9KYaqpvab44KE/b6g8XQjhzT+TMTYTtOGuN63x97Wi14ro+UHoHYJeMrYoHN 7MUHsaln1M1G+zkWM3TunKyfRLhYIHm3vdqOVKr6bOv8G8114Ds/B8yVDv0UAxstQMXj vk4d+5je8iuu1SfD56AsQnCZhlFv9KtJgUnvSh7G7tYXX5ePpWSKrgiOWbzchiehekZz JCA12UiKO6yeVDhX4A0nXWV5nhp6zVvRVW5BEYxal2wk65WbXpS7/IopIcbGX4ssEoC1 ZQ0MieSWW7/aX35KS5Du1d2qSlUitKs2DJPv+nCJBmuWWYKJD1Zk6a20LcbrcibH5NtM hsFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=QFOXLq4F; 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 a186si14485374pge.365.2019.07.24.13.35.41; Wed, 24 Jul 2019 13:35:56 -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=QFOXLq4F; 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 S1729250AbfGXT0j (ORCPT + 99 others); Wed, 24 Jul 2019 15:26:39 -0400 Received: from mail.kernel.org ([198.145.29.99]:43792 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388101AbfGXT0e (ORCPT ); Wed, 24 Jul 2019 15:26:34 -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 E401B229F3; Wed, 24 Jul 2019 19:26:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563996393; bh=sz2ZYePl3x0TRaJajIi2pFcuuEW6vMkb+ikfHr5szMg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QFOXLq4FjhZoR+3bR8kZgPv/ouyjX/in8sfpfMDgIvohj3GXCkYo7+jF4rkF1mFth fQ6AZ9gcWkuSmWF78+b6T/E88ANevZ51heXZywM/hXTNxBFx5g+TMEsD6RTQgjmI35 6aeikknn0QQGQ2vBCiwYvyWaKz+17gmblhz+lTPM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Anirudh Gupta , Herbert Xu , Steffen Klassert , Sasha Levin Subject: [PATCH 5.2 040/413] xfrm: Fix xfrm sel prefix length validation Date: Wed, 24 Jul 2019 21:15:31 +0200 Message-Id: <20190724191738.472275619@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190724191735.096702571@linuxfoundation.org> References: <20190724191735.096702571@linuxfoundation.org> User-Agent: quilt/0.66 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 [ Upstream commit b38ff4075a80b4da5cb2202d7965332ca0efb213 ] Family of src/dst can be different from family of selector src/dst. Use xfrm selector family to validate address prefix length, while verifying new sa from userspace. Validated patch with this command: ip xfrm state add src 1.1.6.1 dst 1.1.6.2 proto esp spi 4260196 \ reqid 20004 mode tunnel aead "rfc4106(gcm(aes))" \ 0x1111016400000000000000000000000044440001 128 \ sel src 1011:1:4::2/128 sel dst 1021:1:4::2/128 dev Port5 Fixes: 07bf7908950a ("xfrm: Validate address prefix lengths in the xfrm selector.") Signed-off-by: Anirudh Gupta Acked-by: Herbert Xu Signed-off-by: Steffen Klassert Signed-off-by: Sasha Levin --- net/xfrm/xfrm_user.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c index 173477211e40..76ad7e201626 100644 --- a/net/xfrm/xfrm_user.c +++ b/net/xfrm/xfrm_user.c @@ -151,6 +151,22 @@ static int verify_newsa_info(struct xfrm_usersa_info *p, err = -EINVAL; switch (p->family) { + case AF_INET: + break; + + case AF_INET6: +#if IS_ENABLED(CONFIG_IPV6) + break; +#else + err = -EAFNOSUPPORT; + goto out; +#endif + + default: + goto out; + } + + switch (p->sel.family) { case AF_INET: if (p->sel.prefixlen_d > 32 || p->sel.prefixlen_s > 32) goto out; -- 2.20.1