Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3821201ybi; Mon, 29 Jul 2019 13:16:44 -0700 (PDT) X-Google-Smtp-Source: APXvYqwU0gLlNNhSrq8pw3b6O+OGThGDV9bykUaTXK1IIdvaSDFsjSgK79wTGH5lfUXacQSdQq9f X-Received: by 2002:aa7:8102:: with SMTP id b2mr38767325pfi.105.1564431404585; Mon, 29 Jul 2019 13:16:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564431404; cv=none; d=google.com; s=arc-20160816; b=eoYqTePnmF8oYwbn3lI2GaxVqmdeYlMDS+WveNB9pT7OY12yQQTzAp6BTLGHpnKdEP 4ilu/obwqkNWi4FJT911dKpWuaKR8a/L59vY6u6DLfcEX8a1POIGYZVgXhfFw95kSTKx CPeNTN4W+eCxokcroyumIe53FB4TAnAbpShcY/D6LHFAjg2ebR2C0LQJpfM9gj4vQgcD Le2yc2kSoPHAA3oj2G4BSACXfDhEPG9a8Ol7JnqwuqdEsp6betKpKD877+Bvliu5oqH3 azY+7FWisHA5hFGQvGFRjUm4nMHxO6MOhPF06reg5dsm81s07HMYZuhLKbkRCmN1gbs/ 3uWQ== 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=sJ6t3UkL8nEAl1N84/BF6jMCjxc/sjgbmiz/8GqZ5gY=; b=e2as27wMydaHsFWfd+a0/SJbncUCYBa3vm16eeqgk45JnsMsWohyohLvdqQam+LJCZ nJeShElGT6kHWImZDzZ/pUMmBfsSOenWdo4e3hOdELrQq74QC9caZbfxa2kYj4pRuvJI VkcrDZ6cOiabZOhozwtOSKQVrehkWwkB3sc5AqjcP1SeLwjV/ubyx8mhxD4tdxhu8kt4 7Ee+yPYe0wOw1puKH1+OX2U1cpgYrUJW0zw+d3HBkDCEaOgaTp1AALUY9kpjRd7f+Joa /aS6iPP6sT5gWPuks8/fv1gc7BajNtXJa3J8OXlpaDFHK6Eabl8xPb5WO0tfiiUHPaIN K+9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=E+2kQ7TE; 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 p1si31333284pff.250.2019.07.29.13.16.29; Mon, 29 Jul 2019 13:16: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=E+2kQ7TE; 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 S1729789AbfG2T0g (ORCPT + 99 others); Mon, 29 Jul 2019 15:26:36 -0400 Received: from mail.kernel.org ([198.145.29.99]:38994 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728513AbfG2T0e (ORCPT ); Mon, 29 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 7D68021655; Mon, 29 Jul 2019 19:26:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564428393; bh=5zrgH3212XZxlRA9/bHkdArtyD4muCdJKVSnbNKioVk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=E+2kQ7TEP7deOIEtNMZUd354z44dQFaxYNpTJCWNYsYdsmimjgf4+swO7pDKar/jj Uuik4KdXzX8/6hR/F3w9rnzcDE9+a5dbvJmclW3Kdf6+irswtCki7X9khYL+rAfBFM Ihvca84Bh80fJEsZkx53VDv+tBzaSE3zHmqKsefo= 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.14 023/293] xfrm: Fix xfrm sel prefix length validation Date: Mon, 29 Jul 2019 21:18:34 +0200 Message-Id: <20190729190822.916090014@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190729190820.321094988@linuxfoundation.org> References: <20190729190820.321094988@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 919b8406028c..b25b68ae7c74 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