Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp1104903ybi; Fri, 2 Aug 2019 09:22:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqwTSkheTt+WUjgzL8cPZaPuyIrooEV1vPBbb/Er4oTkFgCOhZr8Nhtvlwdmhs3BNkaaK8wR X-Received: by 2002:a63:553:: with SMTP id 80mr128409624pgf.280.1564762966215; Fri, 02 Aug 2019 09:22:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564762966; cv=none; d=google.com; s=arc-20160816; b=yC3OMF1LfLlbHqxNEDoeOLfW/shJ6Cfb8wDdaCLW1v3fLzGmwgy7iZKx2LWTi6qjRF kRJJN08YaG/rHu4nio/qJOPV7S5BpqA5meN527+hbZnVaz1+Jo6eYXt69pcPhbn5oYUg sGUjc7kZF5zKBfFPbaf2xdYQOzmHzk7W+vlN5PAMIFnsT7HovhJHDtUbqPum5cRJfp1c c/W3tNNFX+fZ/wWCaRi2VopzAurd6w9rl+/AoHm7CFcUBTmAxzVwGn3aVMF888/AnzWO I4pk8iNzFqsU2JWVdc55VtihHywUIUV5m0e5NMxC4blGjgHBcdM4QMQ87Kv9wc5+yASj Vz3A== 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=STtqtWrsVL+Gfs3osWa9XRSYb5pxxZD96pFHmP8jBHw=; b=wGkGJtof4UxOYtkWSpi/gE/U56RJUNDXEHK0l49Gcsw8RM9oCnzS/5JHgP2KPNaG6c bBDVv3kohIA1LMdNOI5NFAKcYvaoLw8lfz8y+Y2+bwI7rQceZBhsewweJYuRF7367GC5 XOC9zhtJuwiosJvLa3eY7B4FZ3bgNLZ14guIQkkZmUWAjwKefqq/mN85tkjJtPvNkJfz gnHYg4b2HYvJCWB8kv5BvJeajrxbuR5ax5ky1BBt62jt0FIvD04J3lgzRGKUy004GtSn e5BpA5SwS+OJFpdpjLOQwk/o14BIfilOJO50kasYGFTF7YRB2Q7IZoeo0wjPBSkcPw23 pZNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=B8OFWOfO; 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 h32si36623192pld.402.2019.08.02.09.22.30; Fri, 02 Aug 2019 09:22:46 -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=B8OFWOfO; 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 S2404588AbfHBJla (ORCPT + 99 others); Fri, 2 Aug 2019 05:41:30 -0400 Received: from mail.kernel.org ([198.145.29.99]:43106 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391825AbfHBJl2 (ORCPT ); Fri, 2 Aug 2019 05:41:28 -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 C1B20217D6; Fri, 2 Aug 2019 09:41:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564738887; bh=QU/dUSVzQEWwEMHAx9CqbQrPAjeBGL0aT6VT5mf72hs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=B8OFWOfOj6DUrmUNUXyWmfVn1v2G/xdljhosuWqMmpunND04mpbNQ5Lrqhunl2cTb JJh1+WmW39j7XAbvmpPnrzlNU0gi/QqYf46/L319ovg79pkgP7D54nQcXzutVvx6Tx Ec9TJA9Dd/w02uJhOqlenZcTeltQ9i6RvEHlqYmI= 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 4.9 019/223] xfrm: Fix xfrm sel prefix length validation Date: Fri, 2 Aug 2019 11:34:04 +0200 Message-Id: <20190802092240.312947118@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190802092238.692035242@linuxfoundation.org> References: <20190802092238.692035242@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 ca5c79bfd9a5..df4b7fc721f6 100644 --- a/net/xfrm/xfrm_user.c +++ b/net/xfrm/xfrm_user.c @@ -150,6 +150,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