Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3580079pxb; Mon, 24 Jan 2022 12:43:00 -0800 (PST) X-Google-Smtp-Source: ABdhPJyZkNYZz9BAG1n2vL2TMFwopnkVxV6Fs6+UiJgKSl0CMi9HGhKgguRbfGTybQ9HyL3HAKNf X-Received: by 2002:a17:90b:4f4c:: with SMTP id pj12mr91466pjb.102.1643056979866; Mon, 24 Jan 2022 12:42:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643056979; cv=none; d=google.com; s=arc-20160816; b=AwBaz3ePl8y1FXbfyAUQJ7ANWdQJReUSKUSt3sYvBz0D0edsCpFyesNoBfG05CPigQ Z8ta4QxhE1uGDF51QlI6LQgKrhpJWX/mNbvxs4hrxerP3Qkqrp+JMITC2CuJzNQ7o0o+ u4lEmbeHN41mAlLY4WHzQ42CwFbmYY301WKtKlV9eyD2rSbQTUgPQwjDUVKrrYEwS7DJ Al4EGuW6Xv4FAAi6f4u1lKmJp9CLnutazp6NPqoBH6veo1apUUhyw0yFozf9e1+PYePE Z52lpmnTiYAa+jGKOqwkNsmpGQGS5JPyHex2U0RE5uBn99dJZXpT8AYhz1XPx1QgpSgq 9YLg== 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=qHGdHE2p5U3dgchXP8RU88vLvl47VA99WB6lw5zYjsM=; b=gsv3MpIaJAQsL8lfCTU29wUmGTOFxVuDW3EuEq4iUDNiHEEDEaEByEDnu1J87iNgis +EbVrJxlWatR1NyHVV879w91oawPEfbCRwms37l7IWEViMgUEk/ZZz6RZGHWMpAt1ugX twrmDWhZdVY49avUPdQgS19sB7sTq7BNCNsNqffezUSikYeEi4fK7KlXVb5T0thV+6Lb 3x3MIYl2tiEtFRQuFGr5P8Az5KG3V0b4hZDBZ4Q+VbzmTYFEnz2gGkdkgLMhNIugCiui ZxvQ0gCaXR5ON542ysRjYGCwmA7ASYwZNx8Ucnxjr5fCtrf6YAv5iaUHyDo6hB4e0idV VijA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=PCaVoPgz; 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 u12si4091567pgb.667.2022.01.24.12.42.37; Mon, 24 Jan 2022 12:42:59 -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=PCaVoPgz; 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 S1346225AbiAXUA1 (ORCPT + 99 others); Mon, 24 Jan 2022 15:00:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54222 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349361AbiAXTi6 (ORCPT ); Mon, 24 Jan 2022 14:38:58 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C7810C003665; Mon, 24 Jan 2022 11:17:47 -0800 (PST) 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 6709B61302; Mon, 24 Jan 2022 19:17:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3BB1CC340E7; Mon, 24 Jan 2022 19:17:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643051866; bh=Om5sd+3e1cpnSZ+/leGsmM2f/cQJeIzDtq0QRpYDL1c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PCaVoPgz9O9WkQ4E3CS9KRVpi7tsPlxt0KoCk1J0eiGUNGZF938GnAHak3eOngNxR Ew2ALeKQJ+hRyZPecKmtvq57mf/WoZt55nzImUzRmBqo/eHdlLtrbpYrbh7705q69r tgnR5qWajfW5dUPiWA9QUqyzt3gj4JOIxoDdKW8w= 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 4.19 079/239] xfrm: interface with if_id 0 should return error Date: Mon, 24 Jan 2022 19:41:57 +0100 Message-Id: <20220124183945.629660706@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124183943.102762895@linuxfoundation.org> References: <20220124183943.102762895@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 35a020a709852..054897358d904 100644 --- a/net/xfrm/xfrm_interface.c +++ b/net/xfrm/xfrm_interface.c @@ -662,11 +662,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; @@ -691,7 +696,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