From nobody Thu Apr 2 10:44:28 2026 Received: from out-179.mta0.migadu.com (out-179.mta0.migadu.com [91.218.175.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5288030F547 for ; Sun, 29 Mar 2026 11:23:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774783419; cv=none; b=lq/a6LlbJgeo4m+Qr204H7rskPvqs7IoMOrFuD2blLeylHmkqJc6THfT0sd0iuQ34hkDPM0fIBr2yFVqS1CZTCfTWFE/I0Z/lrL5Fk3+vg2h8s8WxLHiq8JFKJXFjID3wh1MhRt3T8HSLB8LCFRsoZuNW+UuwcBJntSr/g6OOt0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774783419; c=relaxed/simple; bh=BRIP1mTZDCMHEU04QrDwkcuyDCBEWWQgkhGzpNxjuEw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=K661myVy5AW0iAYGDd/KKlykvxcvNDCeTpoI0AkNhg606eH1674fQq5DHdY1StjltNbH4pxOBDBCThVkpyrhCJEgP/FOTCAuRN2foLxoA/VmRh1wJW720LwXenACk3IU/LMyUPLgYvRKB5ig0UR8m5dWhpjPqCOHkYG0LPZMS74= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=f9t9OqlY; arc=none smtp.client-ip=91.218.175.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="f9t9OqlY" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1774783416; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=u347+uD3sb5mTEYMpGjCMcCICUQJttgR0qXNZxV+wWk=; b=f9t9OqlYqMHMRVJWR4cBjdICD6izP9wDw2hUVaKw+g4ouQoQhTq3FfVtynikpn2qMe15cP jw/xSUHEIwGMHEa6PDNWK8oddDtnNvirB+Y2jSrKTB2WeS8G6/2isOpeOZyVKhQRc4mc8m yHai/rdNn3cB5MQ7jmjRzfHgAD6TI1k= From: luka.gejak@linux.dev To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, netdev@vger.kernel.org Cc: horms@kernel.org, fmaurer@redhat.com, liuhangbin@gmail.com, linux-kernel@vger.kernel.org, luka.gejak@linux.dev Subject: [PATCH net-next v3 1/4] net: hsr: serialize seq_blocks merge across nodes Date: Sun, 29 Mar 2026 13:23:10 +0200 Message-ID: <20260329112313.17164-2-luka.gejak@linux.dev> In-Reply-To: <20260329112313.17164-1-luka.gejak@linux.dev> References: <20260329112313.17164-1-luka.gejak@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" From: Luka Gejak During node merging, hsr_handle_sup_frame() walks node_curr->seq_blocks to update node_real without holding node_curr->seq_out_lock. This allows concurrent mutations from duplicate registration paths, risking inconsistent state or XArray/bitmap corruption. Fix this by locking both nodes' seq_out_lock during the merge. To prevent ABBA deadlocks, locks are acquired in order of memory address. Reviewed-by: Felix Maurer Signed-off-by: Luka Gejak --- net/hsr/hsr_framereg.c | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/net/hsr/hsr_framereg.c b/net/hsr/hsr_framereg.c index 577fb588bc2f..d09875b33588 100644 --- a/net/hsr/hsr_framereg.c +++ b/net/hsr/hsr_framereg.c @@ -123,6 +123,40 @@ static void hsr_free_node_rcu(struct rcu_head *rn) hsr_free_node(node); } =20 +static void hsr_lock_seq_out_pair(struct hsr_node *node_a, + struct hsr_node *node_b) +{ + if (node_a =3D=3D node_b) { + spin_lock_bh(&node_a->seq_out_lock); + return; + } + + if (node_a < node_b) { + spin_lock_bh(&node_a->seq_out_lock); + spin_lock_nested(&node_b->seq_out_lock, SINGLE_DEPTH_NESTING); + } else { + spin_lock_bh(&node_b->seq_out_lock); + spin_lock_nested(&node_a->seq_out_lock, SINGLE_DEPTH_NESTING); + } +} + +static void hsr_unlock_seq_out_pair(struct hsr_node *node_a, + struct hsr_node *node_b) +{ + if (node_a =3D=3D node_b) { + spin_unlock_bh(&node_a->seq_out_lock); + return; + } + + if (node_a < node_b) { + spin_unlock(&node_b->seq_out_lock); + spin_unlock_bh(&node_a->seq_out_lock); + } else { + spin_unlock(&node_a->seq_out_lock); + spin_unlock_bh(&node_b->seq_out_lock); + } +} + void hsr_del_nodes(struct list_head *node_db) { struct hsr_node *node; @@ -432,7 +466,7 @@ void hsr_handle_sup_frame(struct hsr_frame_info *frame) } =20 ether_addr_copy(node_real->macaddress_B, ethhdr->h_source); - spin_lock_bh(&node_real->seq_out_lock); + hsr_lock_seq_out_pair(node_real, node_curr); for (i =3D 0; i < HSR_PT_PORTS; i++) { if (!node_curr->time_in_stale[i] && time_after(node_curr->time_in[i], node_real->time_in[i])) { @@ -455,7 +489,7 @@ void hsr_handle_sup_frame(struct hsr_frame_info *frame) src_blk->seq_nrs[i], HSR_SEQ_BLOCK_SIZE); } } - spin_unlock_bh(&node_real->seq_out_lock); + hsr_unlock_seq_out_pair(node_real, node_curr); node_real->addr_B_port =3D port_rcv->type; =20 spin_lock_bh(&hsr->list_lock); --=20 2.53.0 From nobody Thu Apr 2 10:44:28 2026 Received: from out-184.mta0.migadu.com (out-184.mta0.migadu.com [91.218.175.184]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AD32635DA51 for ; Sun, 29 Mar 2026 11:23:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.184 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774783421; cv=none; b=heBaLnE7LWCMidhD6uPo7ICG1bTVNFhhSbEcYzAusj8Nv0VOrOAbOCzWGHzQtdv2gtsdEwzmVE2Mlrgood3emSQQdI4VzKqVliluJTbo7sr27SCKkd4/zYZ7F8SvcIGs4DDeS09yfZJiwjSkd+2h4deA9DhPsXQqp3NMS8QNZX4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774783421; c=relaxed/simple; bh=PIuYIprfouppkQZ7QeNiFpoaRkQAOKuyzHEJqlLVsCQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=c16bwgtgYgOeVrlP1QomnoTWgz56HgrHbkwqkrNACn++v8CEupVJ4CKmJ5Ap3hQ7yvRusqaX4CTiFiGVtYr4+IMki3i4Ylu0JtqoT4+Y8oj/ZwYvJtuYhleNIZu7Jah0/356PhZ+udFVcGQZcbwGwhSFqLppf9rtlC09DD+CoOY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=AL42Lqzh; arc=none smtp.client-ip=91.218.175.184 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="AL42Lqzh" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1774783418; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KSHMJQQ8DMWFQEe3KshqgTve/RGG6/L+xVBKnqvidjI=; b=AL42LqzhKfMk6JkvEzGhY87/anTYEb48GDnPCxaRJD9M5BDLd82C/UbqYnsQ58sFhZR7dJ 36v1JdeG5D1rwWHyhHPQISWjjI1x7XfowABoZGMsF95GVMLIkbXXfpPen6hMvQoGZVBvS5 7fGQAaHdcZVmkgarNXAv7xRoT+iIR9U= From: luka.gejak@linux.dev To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, netdev@vger.kernel.org Cc: horms@kernel.org, fmaurer@redhat.com, liuhangbin@gmail.com, linux-kernel@vger.kernel.org, luka.gejak@linux.dev Subject: [PATCH net-next v3 2/4] net: hsr: fix VLAN add unwind on slave errors Date: Sun, 29 Mar 2026 13:23:11 +0200 Message-ID: <20260329112313.17164-3-luka.gejak@linux.dev> In-Reply-To: <20260329112313.17164-1-luka.gejak@linux.dev> References: <20260329112313.17164-1-luka.gejak@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" From: Luka Gejak When vlan_vid_add() fails for a secondary slave, the error path calls vlan_vid_del() on the failing port instead of the peer slave that had already succeeded. This results in asymmetric VLAN state across the HSR pair. Fix this by switching to a centralized unwind path that removes the VID from any slave device that was already programmed. Signed-off-by: Luka Gejak --- net/hsr/hsr_device.c | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/net/hsr/hsr_device.c b/net/hsr/hsr_device.c index 5c3eca2235ce..8ee30fc32612 100644 --- a/net/hsr/hsr_device.c +++ b/net/hsr/hsr_device.c @@ -532,8 +532,8 @@ static void hsr_change_rx_flags(struct net_device *dev,= int change) static int hsr_ndo_vlan_rx_add_vid(struct net_device *dev, __be16 proto, u16 vid) { - bool is_slave_a_added =3D false; - bool is_slave_b_added =3D false; + struct net_device *slave_a_dev =3D NULL; + struct net_device *slave_b_dev =3D NULL; struct hsr_port *port; struct hsr_priv *hsr; int ret =3D 0; @@ -549,33 +549,35 @@ static int hsr_ndo_vlan_rx_add_vid(struct net_device = *dev, switch (port->type) { case HSR_PT_SLAVE_A: if (ret) { - /* clean up Slave-B */ netdev_err(dev, "add vid failed for Slave-A\n"); - if (is_slave_b_added) - vlan_vid_del(port->dev, proto, vid); - return ret; + goto unwind; } - - is_slave_a_added =3D true; + slave_a_dev =3D port->dev; break; - case HSR_PT_SLAVE_B: if (ret) { - /* clean up Slave-A */ netdev_err(dev, "add vid failed for Slave-B\n"); - if (is_slave_a_added) - vlan_vid_del(port->dev, proto, vid); - return ret; + goto unwind; } - - is_slave_b_added =3D true; + slave_b_dev =3D port->dev; break; default: + if (ret) + goto unwind; break; } } =20 return 0; + +unwind: + if (slave_a_dev) + vlan_vid_del(slave_a_dev, proto, vid); + + if (slave_b_dev) + vlan_vid_del(slave_b_dev, proto, vid); + + return ret; } =20 static int hsr_ndo_vlan_rx_kill_vid(struct net_device *dev, --=20 2.53.0 From nobody Thu Apr 2 10:44:28 2026 Received: from out-186.mta0.migadu.com (out-186.mta0.migadu.com [91.218.175.186]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 657A235F19C for ; Sun, 29 Mar 2026 11:23:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.186 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774783422; cv=none; b=C9pXyAf/pnsuV1KQyocgAQA8zaK2Uxhlux3bO01g1pnkUnRuA9gtYLfS3b+ZKu2i3xWrid2fZWTarZAW1zF8Bz3vhFYTzg97iVY01dIxpmZ3+7v7KAlGFR+3tZDS4aLBEzvSARGSxN5L0Ef+xs5oyFDRpSy1yw6BYCYc4PiQBNU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774783422; c=relaxed/simple; bh=FKvTpO1SluKtjSMrTLWTBN3s/9HEwJe1ge0E6tvCeNg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gcM+hf95wuR77cmq7IhsG5sXylTk/6/6jaAVFGS121hOAMDoun7+sZl1u3pX2gQ+GYqh1WCQnGkjqOMupBHG29NuKGAr6k0MuyrZM8nmedxV8HtkUzT4NCjw/Dyus8FOpogZF7judnAImpiKUl8ePb62eiQD8QRzITKROoRxpqg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=e1KEBXTa; arc=none smtp.client-ip=91.218.175.186 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="e1KEBXTa" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1774783419; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Cz51yi/FiPlzZs1MA69fyINR+7e40BLTFJSWXlWlNIo=; b=e1KEBXTajsVUm7rZ9TVIPSVJ72GiNPMrClmEJOv2GWWt4Km/nKIae5418LliSuJrOGCHa1 ibnuKCuAMwU5gaj9XJ9Q35Yyv2ZXdsLDG1ZGtYi8VS/UHyA+tzmcF+ip0BVGjfIc22iuaw SG/6GRsg7l/JSWzK4HBL2OywfTw3siw= From: luka.gejak@linux.dev To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, netdev@vger.kernel.org Cc: horms@kernel.org, fmaurer@redhat.com, liuhangbin@gmail.com, linux-kernel@vger.kernel.org, luka.gejak@linux.dev Subject: [PATCH net-next v3 3/4] net: hsr: require valid EOT supervision TLV Date: Sun, 29 Mar 2026 13:23:12 +0200 Message-ID: <20260329112313.17164-4-luka.gejak@linux.dev> In-Reply-To: <20260329112313.17164-1-luka.gejak@linux.dev> References: <20260329112313.17164-1-luka.gejak@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" From: Luka Gejak Supervision frames are only valid if terminated with a zero-length EOT TLV. The current check fails to reject non-EOT entries as the terminal TLV, potentially allowing malformed supervision traffic. Fix this by strictly requiring the terminal TLV to be HSR_TLV_EOT with a length of zero. Reviewed-by: Felix Maurer Signed-off-by: Luka Gejak --- net/hsr/hsr_forward.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/hsr/hsr_forward.c b/net/hsr/hsr_forward.c index aefc9b6936ba..d26c7d0e8109 100644 --- a/net/hsr/hsr_forward.c +++ b/net/hsr/hsr_forward.c @@ -110,7 +110,7 @@ static bool is_supervision_frame(struct hsr_priv *hsr, = struct sk_buff *skb) } =20 /* end of tlvs must follow at the end */ - if (hsr_sup_tlv->HSR_TLV_type =3D=3D HSR_TLV_EOT && + if (hsr_sup_tlv->HSR_TLV_type !=3D HSR_TLV_EOT || hsr_sup_tlv->HSR_TLV_length !=3D 0) return false; =20 --=20 2.53.0 From nobody Thu Apr 2 10:44:28 2026 Received: from out-188.mta0.migadu.com (out-188.mta0.migadu.com [91.218.175.188]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ECB9635F60F for ; Sun, 29 Mar 2026 11:23:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.188 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774783425; cv=none; b=oT/pQYC7mFW7j+aOLPGWdgyiwFNzBA1eQvEjtw8bn1mzhES68Q9OHwC0F/AwryPizRA3wJ2A7/twFM6ocSmLZe6sjSiV7zV0eFBGY3pweJ2N1/cWngTNORfbjsBK42sv5grCYmh7NAdcknESZrTAuJoALBogrWF6njXyuaTQe8E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774783425; c=relaxed/simple; bh=VKCyhqMVXE+KSqjXVeG+3hvSNLI273PUuk32Xdv7S5Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EiCicF/dvbLkwYRLR3TzsW1/fE1f8c+Mh9BVSkWCmObtY9w6jbxnZzLdx/Q9k1yV5t0CTXo5UQjU0ayqa/jCXYuVNp8FeG6qAA1vwMCPAfOHvqLQaaglYS3WtVdr6YpfY2TF6HnxixLnSs9RPX+UdcwwgY2F6Gu/6/bKdjOIwM8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=qZGYf98q; arc=none smtp.client-ip=91.218.175.188 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="qZGYf98q" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1774783421; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=OXNLfi3VDWQRurd0FK4vAiq2uw5ZAgnel28YQEol3sw=; b=qZGYf98qDzH/XrSDpmsRSmQPC6jJ7ujqElb9DTolYikrak3n2fiP7ruhalUQqHtSEzm7Ax MdcTemMo/klrKgqCWtDAsmgNjXgX+ZYUn9+OG0fLg6rdlYfedXPdvfh7VOIy0go8EgbTU4 aTJb665WMEvh/96ZmRERXFqpqM1mJkU= From: luka.gejak@linux.dev To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, netdev@vger.kernel.org Cc: horms@kernel.org, fmaurer@redhat.com, liuhangbin@gmail.com, linux-kernel@vger.kernel.org, luka.gejak@linux.dev Subject: [PATCH net-next v3 4/4] net: hsr: reject unresolved interlink ifindex Date: Sun, 29 Mar 2026 13:23:13 +0200 Message-ID: <20260329112313.17164-5-luka.gejak@linux.dev> In-Reply-To: <20260329112313.17164-1-luka.gejak@linux.dev> References: <20260329112313.17164-1-luka.gejak@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" From: Luka Gejak In hsr_newlink(), a provided but invalid IFLA_HSR_INTERLINK attribute was silently ignored if __dev_get_by_index() returned NULL. This leads to incorrect RedBox topology creation without notifying the user. Fix this by returning -EINVAL and an extack message when the interlink attribute is present but cannot be resolved. Reviewed-by: Felix Maurer Signed-off-by: Luka Gejak --- net/hsr/hsr_netlink.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/net/hsr/hsr_netlink.c b/net/hsr/hsr_netlink.c index db0b0af7a692..f0ca23da3ab9 100644 --- a/net/hsr/hsr_netlink.c +++ b/net/hsr/hsr_netlink.c @@ -76,9 +76,14 @@ static int hsr_newlink(struct net_device *dev, return -EINVAL; } =20 - if (data[IFLA_HSR_INTERLINK]) + if (data[IFLA_HSR_INTERLINK]) { interlink =3D __dev_get_by_index(link_net, nla_get_u32(data[IFLA_HSR_INTERLINK])); + if (!interlink) { + NL_SET_ERR_MSG_MOD(extack, "Interlink does not exist"); + return -EINVAL; + } + } =20 if (interlink && interlink =3D=3D link[0]) { NL_SET_ERR_MSG_MOD(extack, "Interlink and Slave1 are the same"); --=20 2.53.0