Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3655285pxb; Mon, 24 Jan 2022 14:33:45 -0800 (PST) X-Google-Smtp-Source: ABdhPJy+1AUojDzNOxIxInG8bESMsAar8rTh7zgz71FN7mB5YVCoeQ9n8VnvthDJRVWaC3Mg7zbd X-Received: by 2002:a63:6b42:: with SMTP id g63mr13013501pgc.345.1643063625170; Mon, 24 Jan 2022 14:33:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643063625; cv=none; d=google.com; s=arc-20160816; b=rB1t8L/6EDNw7vcW8Va1Je2Pho2Tfq/hYsSnBv3UBAX2rXo5qx9xSCfgLgfMcjHJMT LwDajUwBP4sZAgIRDqIc1+Z6eS40zjA6+m/5qj6tkgZwioYU5PCUTXxRWpjwdIHIrZlG ifBD56EDJmg2jDQv4WiMlZImyIW+tVrUwvWGYy4ZDo9WIqvaaWCB5UNXduTk15jozB6E Q4xAzhw7+3KZg2bifHnVk9VDwp1qo2g0Pd0CQHnugAZHI9loyipbUOF/s66GFz4bv+rT /20/c/7deEhIalJuvz4YSq+paNIBkIFqqWb3bB0+r3gGFEsihVQmf4/1gQjsam5kdYUL 7N7Q== 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=SYS5PdHzkajXJ9WpbDqKMB0AC4PVuQCOV4yjThj9N7oRliC5ZIoEPpzeswHq/kQtjW h/hOuaN+ZG2sbNA/x10gKe4YBETn+MfLTtl4SX9q2kk1oX+j1PJGGbzOnBN+VerFGbX4 69qXX1pmUz7RRd9Q2tTL647jgeS6uqMx5kfHFWSXSJuj6/e4gw/qYGBZmNRXBi5vV4JQ W82EuUkHdh/nsGPNZ0x2eHLT4lf7d8togRJn4mDmfGB6137SGYFUNRd9gJdhbJnhOS+d 3VhJ656SNtfeyfcjgqgxsxxeUmvQYjIQewOLAATCtC+DktZxnukTYkA1KJ22zfwFCdNZ OZJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Rn9xlBFq; 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 w184si1460502pgd.9.2022.01.24.14.33.31; Mon, 24 Jan 2022 14:33:45 -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=Rn9xlBFq; 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 S1355772AbiAXWbu (ORCPT + 99 others); Mon, 24 Jan 2022 17:31:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55242 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1456527AbiAXVj3 (ORCPT ); Mon, 24 Jan 2022 16:39:29 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 34B13C0417C2; Mon, 24 Jan 2022 12:24:31 -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 ams.source.kernel.org (Postfix) with ESMTPS id F1245B8121A; Mon, 24 Jan 2022 20:24:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 124B5C340E5; Mon, 24 Jan 2022 20:24:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643055868; bh=sfLZiX02BJ5cJ5jesEuIRjHJpSQs6iwfZWTLM8msD+o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Rn9xlBFq7t0SJdB/G7UOt4q35sVk+rQWdigK4EBoTm7JT+X64KLQ/TTqc1IyGGpP3 7vpSEkRn+F6uHl2P/ZdQh76vuubCQb8+62mp8wVDV8WTqHdu1/W9MSk01439HjpxO3 actV2pR31ztOUTSEqe++VpNa15R7nhApza8rIb00= 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.15 259/846] xfrm: interface with if_id 0 should return error Date: Mon, 24 Jan 2022 19:36:16 +0100 Message-Id: <20220124184109.861648019@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184100.867127425@linuxfoundation.org> References: <20220124184100.867127425@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