Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3572037pxb; Mon, 24 Jan 2022 12:31:17 -0800 (PST) X-Google-Smtp-Source: ABdhPJxgxMRw/qY1/4pEvlDnaEFhM7Q/Ps/p76Bgl8yXuSUwNvnZ+08ju/wS40OE7clt2MoCL5pu X-Received: by 2002:a05:6a00:16c7:b0:4a4:edfe:4625 with SMTP id l7-20020a056a0016c700b004a4edfe4625mr15529284pfc.58.1643056277566; Mon, 24 Jan 2022 12:31:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643056277; cv=none; d=google.com; s=arc-20160816; b=a1wUhAqCAmCbLSlYJmC4aI3vFlzIPAB8sEvqSf4gKtzufzfFd7RI9Nz3Anl9u2XLpN Hf6rM1dlASa//dd3JtUt1H3Zy2O7cd+NIVSoscVQ8WJD68v8GMWqDn2IsqPWxdO+GdlQ V1CK6R65ufzEZBRlllL4rvb95ivLoJsqufUO5XzIor2oWD8MlVG1rjEy8GXIz5WLy3b8 lb0asi9OoA/swWZdkuBa9E9AdKSMQd/TV3nyqCVSXHI9LeWSoAY04MNQro/VFO8jAO5S 98G9o5/pyCnFg9jNfQMJuxqG7fLCo39v3eHBMydaCKKuXZ+v2AUdLX/teJBPb+x4fBgm sOXQ== 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=5pK23P/GBA9KSp0w8sUOI0Z/r1rcVsGz2sS9LvtRmPs=; b=r16ywomTWXphUBh2FF0z9KEBkHIeK7Zpx0qczm2fBrv+08IpfLqPQKlWmhNCTZ1gVq RaBPXl0AMeOiS7IbhNtg32cB2FsqbOebEK5psgzb+PEVXN6l071xHNQy2h/NM6PCaZCs Oo22vOaWR2Bp7bvWJ+eE7POIDMw9nSnrV0mnnqMVjp+BZ9LB6FAfU+mFi3dViupu2/Ax GPxckme3zrvMsbv4HE7kpnpjE0C1g8MHeZLvyFjYagRED90gZtdO4UzuRXFMZABK4En+ +VOivXpnKXHHecxQNVZsLJ87uBxbpoa6HrVijYXahk4y3Bw1NIopRi+huSJ28BZDpLi2 PV6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=jjwZ4GHq; 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 v201si10399682pfc.5.2022.01.24.12.31.05; Mon, 24 Jan 2022 12:31:17 -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=jjwZ4GHq; 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 S1353823AbiAXTf0 (ORCPT + 99 others); Mon, 24 Jan 2022 14:35:26 -0500 Received: from dfw.source.kernel.org ([139.178.84.217]:56514 "EHLO dfw.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344466AbiAXT2y (ORCPT ); Mon, 24 Jan 2022 14:28:54 -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 804976129A; Mon, 24 Jan 2022 19:28:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 64A69C340E5; Mon, 24 Jan 2022 19:28:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643052532; bh=oZ9fV1EcOdeX0gDXQYcufvalv4b+Oij4mIKQz1XPDRc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jjwZ4GHqZxfqIH0PPaUQqbvcoNXHlM5OiGxO5LOcE6CIUJ9Srw6nQSHT9zFCiJP18 ChrPAFaT6o7srHJl1PPvsOS1jbGT6Q1zu+p4JLGUnJ6hLZkgix48InUnBAyC/Y6d7O qjbvwxsRqHhd/Lm2HPbrOkB7WwjVGC9eoQJBXfAU= 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.4 089/320] xfrm: interface with if_id 0 should return error Date: Mon, 24 Jan 2022 19:41:13 +0100 Message-Id: <20220124183956.767515091@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124183953.750177707@linuxfoundation.org> References: <20220124183953.750177707@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 74e90d78c3b46..08343201513a9 100644 --- a/net/xfrm/xfrm_interface.c +++ b/net/xfrm/xfrm_interface.c @@ -659,11 +659,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; @@ -688,7 +693,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