Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3630661pxb; Mon, 24 Jan 2022 13:58:02 -0800 (PST) X-Google-Smtp-Source: ABdhPJwAtYZSPJuijqgRi2z+ALanyYLS/07PHlTkZvWSQVVvWxab620MXkwF2J3h+3679A6y1FbK X-Received: by 2002:a17:90b:1bc1:: with SMTP id oa1mr318803pjb.209.1643061482246; Mon, 24 Jan 2022 13:58:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643061482; cv=none; d=google.com; s=arc-20160816; b=I4UHtRKmcCR1TfBIDvDyCpczkj2yJOURf91yRG/OG2/zesGtYx59SV6c4BR6qE++TI QvUdhABPO0+NBFQ5RJwGwI0UB9O8UEGnbVanyk/ojAmkLqMf6TI7ee6eE1HFeD9GXraR kGASKcrVzRXM2udzrJaetOZI4jY5ee1bcgQpKPnu4RQHBgj99mb7lEhk/Os8GTYx1jFu eTmhD/uOBsaDw49MKc2k2014Jg8Fpelnq0+ZWfTwIKgrlKaEKpfLlg0AfcXarcK+nBqi X9d91vr+oN2zBNupPe7sTmZICGDElPrALtJeSVwGB4Oanr4fC5crtSfnzFJLi5IFt65P O2Wg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Wm0YhcbkfoO+tkai/sEV99BNfJLCsyJ7CeQX7IPfTYI=; b=MxHRGBXYm1cjWX92uDDM/cwLFKQmWEYgGhrX912yUNF7pi0U/PtxNp2Sre+BvxUwxt +a/l2mi0XqkhIO3j6Z6lZWRSqlBl3OuXpo+4QpuHvXCnRRwA72y0KvgkSHmd+NyaHgpB zfF5X5ihr/VMknr3VmJJExNt1pk0dnEnspnZzVsCnHihTNdg3DQWFCiB4PSF5w2oSqT+ CDosVfHpqnMgdT6DtIlA2IKGcupBG+BgzCCDwXaOXz3O09oDvNxMxUdrnK5aVAker5+1 4hsSoPJ2wcBHWi5AHnXuVQnrjtMjXrjv0bnBDWSiMp4DPF31IuHFlQSAZ5oJ1Y2Hn3Co qO7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=JLG84KrX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d9si14905970pgb.583.2022.01.24.13.57.49; Mon, 24 Jan 2022 13:58:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=JLG84KrX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1573670AbiAXVpf (ORCPT + 99 others); Mon, 24 Jan 2022 16:45:35 -0500 Received: from dfw.source.kernel.org ([139.178.84.217]:33566 "EHLO dfw.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1446902AbiAXVJi (ORCPT ); Mon, 24 Jan 2022 16:09:38 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 78E766131F; Mon, 24 Jan 2022 21:09:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 58730C340E5; Mon, 24 Jan 2022 21:09:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643058577; bh=sfLZiX02BJ5cJ5jesEuIRjHJpSQs6iwfZWTLM8msD+o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JLG84KrXYqW81gHyoXl/MWNcRx/6Xsude0XoPyl1RaInZYfzdv3DzzFyRZHAU5vmb MEUYgKtCbR1qi2DbugsoJ0zlidXpO9JvrKXAAjGalJzNl5CWFoULrgrUT/4OJaP1v7 GGB6hodEayK0IcEeIsOTZHWaCsVm+3tNuwQ1ODS4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Antony Antony , Eyal Birger , Steffen Klassert , Sasha Levin Subject: [PATCH 5.16 0301/1039] xfrm: interface with if_id 0 should return error Date: Mon, 24 Jan 2022 19:34:50 +0100 Message-Id: <20220124184135.429986884@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184125.121143506@linuxfoundation.org> References: <20220124184125.121143506@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Antony Antony [ Upstream commit 8dce43919566f06e865f7e8949f5c10d8c2493f5 ] xfrm interface if_id = 0 would cause xfrm policy lookup errors since Commit 9f8550e4bd9d. Now explicitly fail to create an xfrm interface when if_id = 0 With this commit: ip link add ipsec0 type xfrm dev lo if_id 0 Error: if_id must be non zero. v1->v2 change: - add Fixes: tag Fixes: 9f8550e4bd9d ("xfrm: fix disable_xfrm sysctl when used on xfrm interfaces") Signed-off-by: Antony Antony Reviewed-by: Eyal Birger Signed-off-by: Steffen Klassert Signed-off-by: Sasha Levin --- net/xfrm/xfrm_interface.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/net/xfrm/xfrm_interface.c b/net/xfrm/xfrm_interface.c index 41de46b5ffa94..57448fc519fcd 100644 --- a/net/xfrm/xfrm_interface.c +++ b/net/xfrm/xfrm_interface.c @@ -637,11 +637,16 @@ static int xfrmi_newlink(struct net *src_net, struct net_device *dev, struct netlink_ext_ack *extack) { struct net *net = dev_net(dev); - struct xfrm_if_parms p; + struct xfrm_if_parms p = {}; struct xfrm_if *xi; int err; xfrmi_netlink_parms(data, &p); + if (!p.if_id) { + NL_SET_ERR_MSG(extack, "if_id must be non zero"); + return -EINVAL; + } + xi = xfrmi_locate(net, &p); if (xi) return -EEXIST; @@ -666,7 +671,12 @@ static int xfrmi_changelink(struct net_device *dev, struct nlattr *tb[], { struct xfrm_if *xi = netdev_priv(dev); struct net *net = xi->net; - struct xfrm_if_parms p; + struct xfrm_if_parms p = {}; + + if (!p.if_id) { + NL_SET_ERR_MSG(extack, "if_id must be non zero"); + return -EINVAL; + } xfrmi_netlink_parms(data, &p); xi = xfrmi_locate(net, &p); -- 2.34.1